I am looking to create a closed source CocoaPod. From my research the recommendation seems to be to distribute it as an XCFramework. (source) It seems it should also be possible to make your framework dependent upon other CocoaPods by specifying them in your Podspec file. (source) (source) That will ensure when someone adds this pod to their Podfile and runs pod install
, it will install this framework and its dependencies.
I have created a framework Xcode project and have been developing it inside our app's workspace as a subproject. So at this time, the app has all of the dependencies installed via CocoaPods, which allows the framework in it to utilize them. Now I am ready to prepare the framework for distribution so it can be used in other apps.
From what I understand, I need to create an XCFramework first and then can create a CocoaPod for it. When I go to archive the framework project, I get an error because it cannot find the dependencies, which makes sense. At this point I don't understand how this is supposed to work, because it seems the framework needs the dependencies included in itself in order to successfully create the XCFramework, but I anticipated from my research this would be handled by CocoaPods and not included in the framework itself.
xcodebuild archive \
-scheme MyFramework \
-configuration Release \
-destination 'generic/platform=iOS' \
-archivePath './build/MyFramework.framework-iphoneos.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
/Users/.../AppName/MyFramework/Helpers/Extensions.swift:10:8: error: no such module 'Kingfisher'
import Kingfisher
^
** ARCHIVE FAILED **
Podfile
. Also correct that, while Foo has lines that call functions from Bar, Baz, your Foo.framework is a just a binary of Foo, it won't include Bar,Baz frameworks. The final app that installs Foo, will then link (the pulled and installed) Bar, Baz frameworks... – Taub