Dyld: library not loaded: @ rpath / libswiftSwiftOnoneSupport.dylib

I created a Swift environment, and now I'm trying to start creating a Swift iOS application that will use this infrastructure. I get this error:

dyld: Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib Referenced from: /Users/tdean/Library/Developer/Xcode/DerivedData/NFLApplication-ejmafvjrlqgjaabggwvadjarjjlg/Build/Products/Debug-iphonesimulator/NFLStatsModel.framework/NFLStatsModel Reason: image not found 

I looked through SO and found similar reports and tried the fixes listed there, including:

  • Delete DerivedData li folder>
  • Xcode restart and iPhone simulator
  • Ensuring the installation of Always Embed Swift Standard Libraries = YES , both in my structure and in the settings of my application assembly
  • Ensuring the setting Enable Bitcode=NO , both in my framework and in my application build settings
  • Make sure Runpath Search Paths set to @executable_path/Frameworks , both in my structure and in my application build settings
  • I copied all the libswift files from my Xcode installation to a local copy in my project and added a custom build phase to copy these files to the frameworks folder.

In each case, I get the same error when I try to run the application.

  • Xcode Version 8.1 (8B62)
  • Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)
+23
source share
8 answers

I ended up getting this work using a combination of fixes. I'm not sure that they are all needed, but I am documenting what seemed to work for me here, just in case anyone could benefit from what I found.

  • I set the Always Embed Swift Standard Libraries to YES in the build settings tab for both my Swift infrastructure and the Swift application that uses the framework.
  • I added Foundation.framework to the Related Frames and Libraries section of the General tab for both my Swift infrastructure and the Swift application that uses the framework.
  • I added Foundation.framework to the Embedded Binaries section of the general tab for a Swift application that uses the framework.

With all three of these settings, I can create and run the application without this error.

+42
source

This may not be for everyone, but I solved it by writing code for the main purpose.

I had an empty project, consisting of a framework and a test target, and when I ran the tests I received this error. Obviously, Swift is pretty smart to discover that you really don't need this library, and does not reference libswiftSwiftOnoneSupport.dylib .

To fix this just add the code, I just added:

 class Test { func a() { print ("something") } } 

and libswiftSwiftOnoneSupport.dylib are related.

+25
source

After a few days of focusing on this issue, I finally found something that worked for me; I hope this helps others as well.

It turns out that a specific use of print() anywhere in the code will somehow cause libswiftSwiftOnoneSupport.dylib to be loaded and the problem goes away.

I am using Xcode 10.1, Swift 4.2 and the module that was giving me this problem was Nimble.

By the way, I am aware of @ S2dent's suggestion "just add some code", but in my case there were already several different classes in my environment , so that didn't help me.

+14
source

How do you fix your dependencies?

I had a similar problem:

dyld: Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib Referenced from: <internal framework> Reason: image not found

It turned out that this is due to the optimization of the entire Swift module.

Using Carthage as a dependency manager, they were compiled for Release and thus compiled with an optimization of the whole module that Xcode proposed to include. Running the application on a simulator compiles it for Debug. I assume that dynamic frameworks cannot be at a different level of optimization from an application using it.

The solution was to explicitly indicate the configuration that I wanted to create for Carthage. ( carthage bootstrap --configuration Debug ) Oh, and of course cleaning up my build folder.

+9
source

I had the same problem by adding a library (my own assembly) to the " Linked Frameworks and Libraries tab in the" General "tab of the application, solving the problem.

+2
source

You can also provide a host application for your testing purpose if you do not want to add Foundation.framework to Linked Frameworks or Embedded Binaries.

0
source

You can solve this problem by setting “Always embed Swift standard libraries” to “Yes” in your build’s build settings.

0
source

@rpath stands for Runpath Search Path . In Xcode, this is set with the LD_RUNPATH_SEARCH_PATH setting.

In short: dynamic binding has occurred. Dynamic linking is an operation that occurs when part of the code is distributed across different files and the binary contents of the binary are loaded at runtime.

This means that while we are developing the application, we can skip it until the program starts dyld: Library not loaded: @rpath Reason: image not found

By default, @rpath points to @executable_path/Frameworks

@executable_path - Useful for wireframes embedded in applications, as it allows you to specify the location of the wireframe relative to the application executable. Read more

Source here

0
source

Source: https://habr.com/ru/post/1012923/


All Articles