Home > Enterprise >  Embedding SPM packages inside xcframework
Embedding SPM packages inside xcframework

Time:01-16

I have a xcframework project which has imported a few Swift package manager dependencies. I am building this framework with the following commands to create a universal binary.

xcodebuild -project Proj.xcodeproj archive -scheme Proj -sdk iphoneos -configuration Release clean build -derivedDataPath archives/device BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO ONLY_ACTIVE_ARCH=NO

xcodebuild -project Proj.xcodeproj archive -scheme Proj -sdk iphonesimulator -configuration Release clean build -derivedDataPath archives/simulator BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO ONLY_ACTIVE_ARCH=NO

xcodebuild -create-xcframework -framework archives/device/Build/Products/Release-iphoneos/Proj.framework -framework archives/simulator/Build/Products/Release-iphonesimulator/Proj.framework -output universal/Proj.xcframework

Then I import this into my project. But I cannot resolve the modules installed in xcframework. It says module is not found. What I want to do here is to reuse the bundled SPM packages without importing them to the final project again. Build libraries for Distribution is set to Yes in xcframework Build Settings.

When I import the SPM modules in the project it self it says " Class axyz is implemented in both . One of the two will be used. Which one is undefined." This means the SPM packages seems to be imported but cannot be linked properly.

CodePudding user response:

Answering my own question. Adding @_implementationOnly in each package import in the framework did the trick.

  • Related