What's the correct way to create an xcframework from a CocoaPod pod you own?

181 views Asked by At

Suppose I have a pod named Honey. It has its own example app. Much like how it's shown here: https://github.com/CocoaPods/CocoaPodsExampleLibrary

In that case I have a root project directory structure as:

Example 
   Honey
   Honey.xcodeproj
   Honey.xcworkspace
   Podfile
   Podfile.lock
   Pods
     Pods.xcodeproj

Which of the choices should I use to create the xcarchive so that I can later create the xcframework?

Option 1 - Example project with Honey scheme

xcodebuild archive -workspace "Example/Honey.xcworkspace" -scheme "Honey" 
-destination "generic/platform=iOS Simulator" -configuration Release
only_active_arch=no -archivePath "build/iOS-Sim" SKIP_INSTALL=NO
BUILD_LIBRARY_FOR_DISTRIBUTION=YES OTHER_SWIFT_FLAGS="-Xfrontend -module-interface-preserve-types-as-written"

Option 2 - Pods Project with

xcodebuild archive -project "Example/Pods/Pods.xcodeproj" -scheme "Honey (Pods Project)"
-destination "generic/platform=iOS Simulator" -configuration Release
only_active_arch=no -archivePath "build/iOS-Sim" SKIP_INSTALL=NO
BUILD_LIBRARY_FOR_DISTRIBUTION=YES OTHER_SWIFT_FLAGS="-Xfrontend -module-interface-preserve-types-as-written"

My guess is that both would work. Because you only pull in public symbols (types, functions, variables). And in a normal world you won't have public symbols in your Example folder. Nor would the Honey Pod be referencing code from the Example app. So the final xcframework would have identical APIs

However only the 2nd option is correct. Because it even never attempts to include code from the Example Project.

0

There are 0 answers