Injecting external frameworks into private private frameworks in Swift

I created a framework using Xcode 6 and Swift, and my framework uses SwiftyJSON as dependencies - added via Carthage . I zipped my framework and created an assembly for both simulators and iOS devices using lipo

, and when trying to use my framework in a blank app, I get a runtime crash:

dyld: Library not loaded: @rpath/SwiftyJSON.framework/SwiftyJSON
Referenced from: /Users/hd/Library/Developer/CoreSimulator/Devices/324FD1CD-4A06-459B-AE6D-318197B5697E/data/Containers/Bundle/Application/555871BB-7AA1-4AED-90CE-EE0A628A794F/CollaborativeTodo.app/Frameworks/XXXXX.framework/XXXXX
Reason: no suitable image found.  Did find:
/Users/hd/Library/Developer/CoreSimulator/Devices/324FD1CD-4A06-459B-AE6D-318197B5697E/data/Containers/Bundle/Application/555871BB-7AA1-4AED-90CE-EE0A628A794F/CollaborativeTodo.app/Frameworks/SwiftyJSON.framework/SwiftyJSON: no matching architecture in universal wrapper

      

Here's what my dungeon looks like - my framework name is intentionally blurry:

Project arborescence

General tab:

General

Build phases: Build Phases

This works if I have included SwiftyJSON using Carthage in my project, but I don't want the user to be forced to include third party libraries. How do I embed SwiftyJSON into my framework and tell Xcode to use the inline version at runtime instead of trying to find the framework in the project?

+3


source to share


1 answer


You cannot avoid directly connecting your SwiftlyJSON app. Better to say, you shouldn't avoid having your application include SwiftlyJSON. If the application already has SwiftlyJSON for some other reason, you will be causing them a huge amount of pain due to duplicate characters. Depending on how they do it, they might not get errors, only undefined behavior, which is worse. Auto power on is a feature that is very nice until it explodes completely and no one can figure out how to fix it. If you are looking at "duplicate ios symbols" here on StackOverflow, I believe that about half of it has to do with the framework trying to automatically include a sub-framework (often SBJSON

).



Document what you rely on and include it in your Cartfile as a nested dependency. Carthage will build it for them (they still have to drag it into their project).

+5


source







All Articles