dyld: Library not loaded: @rpath/libswiftCoreAudio.dylib Referenced from:<Framework> Reason: image not found

1.7k Views Asked by At

I've created a Cocoa Touch Framework to centralize my common Swift code and moved some things into it-- and now I'm using it in my other Swift project, in a workspace. At first the main project compiled, but upon startup I got this error:

dyld: Library not loaded: @rpath/libswiftCoreAudio.dylib Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/AppName-guvhnmqtcqhmmndemyhztmwxbkjq/Build/Products/Debug-iphonesimulator/JBS.framework/JBS Reason: image not found

I've found that can fix it by turning on the option Embedded Content Contains Swift Code in the framework, but then I get a bunch of duplicate symbols in the log, like so:

objc[19237]: Class GGLBundleUtil is implemented in both /Users/username/Library/Developer/Xcode/DerivedData/AppName-guvhnmqtcqhmmndemyhztmwxbkjq/Build/Products/Debug-iphonesimulator/JBS.framework/JBS and /Users/username/Library/Developer/CoreSimulator/Devices/CCAD7FCA-BF5F-428A-8122-680B91300618/data/Containers/Bundle/Application/22DC1E4F-B631-450A-A157-A6ADA0126DE6/AppName.app/AppName. One of the two will be used. Which one is undefined.

I don't think I'm supposed to turn on the Embedded Content Contains Swift Code option in the framework, but I don't know why the framework can't find the Swift libraries. Anyone?

Edit:

When I try to run the app on the device, I get a similar but different error. It seems to be complaining that it can't see my framework:

dyld: Library not loaded: @rpath/JBS.framework/JBS Referenced from: /private/var/mobile/Containers/Bundle/Application/C7644037-E5A0-431E-A7DB-D3B124CDC677/AppName.app/AppName Reason: image not found

2

There are 2 best solutions below

0
On BEST ANSWER

The main problem was that when I tried to add the framework into the Embedded Binaries, I didn't pay good enough attention to the section names.

Instead I added it into the section which had the other Linked Frameworks and Libraries, because there were some other ones there already. Once I added it into the Embedded Binaries section (which also re-added it back to the Linked Frameworks and Libraries when I did) it no longer gave me the main error as seen in the title.

I still as of yet, however, haven't figured out how to solve the duplicate symbols error, which occurs all the time now even though Embedded Content Contains Swift Code is turned off everywhere. But that wasn't the main issue in my question.

2
On

Did you test it in device? If so, the bundle id must be the same between your project and your framework.