vinay yedla
vinay yedla

Reputation: 141

Errors in creating XCFramework using CocoaPods

I am trying to generate a iOS XCFramework from an Xcode framework Project(Project name XCFramework). Project consists of some of the cocoa-pods libraries like Socket IO, SwiftKeyChainWrapper etc. If I generate XCFramework without cocoa-pods, xcodebuild commands are generating the XCFramework successfully for both iOS and iOS Simulator destinations, but when I install pods in the framework project I am getting many errors. It will be really helpful if any one has come across this scenario and succeeded kindly help in generating XCFramework sample project using cocoa-pods.

Note: a) I used a small package called xcframework which generates xcfremwork in command (1) b) If I archive the project directly from Xcode the archive gets successful.

1) Buid command:- xcframework build --project XCFramework.xcodeproj --name XCFramework --iOS EcallXCFramework

...... ...... ** ARCHIVE FAILED **

The following build commands failed: Ld /Users/*******/Library/Developer/Xcode/DerivedData/XCFramework-gccrcnyzlsezmugkrqqlnpusjfci/Build/Intermediates.noindex/ArchiveIntermediates/XCFramework/InstallationBuildProductsLocation/Library/Frameworks/XCFramework.framework/XCFramework normal arm64 (1 failure)

2) Build Command:- xcodebuild archive -scheme XCFramework -destination="generic/platform=iOS" -destination="generic/platform=iOS Simulator" SKIP_INSTALL=NO

...... ....... User defaults from command line: destination = generic/platform=iOS Simulator

Build settings from command line: SKIP_INSTALL = NO

xcodebuild: error: Failed to build project EcallXCFramework with scheme XCFramework. Reason: The run destination My Mac is not valid for Archiving the scheme 'XCFramework'.

3) Build Command:- xcodebuild archive ..... ..... ld: framework not found SwiftKeychainWrapper clang: error: linker command failed with exit code 1 (use -v to see invocation)

** ARCHIVE FAILED **

The following build commands failed: Ld /tmp/EcallXCFramework.dst/Library/Frameworks/EcallXCFramework.framework/EcallXCFramework normal arm64 (1 failure)

Upvotes: 10

Views: 2465

Answers (1)

yonivav
yonivav

Reputation: 1033

I think you might have something wrong in your archive command.

This is how I archive, hope it will help you and others:

// Generate simulator archive
xcodebuild archive \
  -scheme <scheme_name> \
  -sdk iphonesimulator \
  -archivePath "archives/ios_simulators.xcarchive" \
  BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
  SKIP_INSTALL=NO
 
// Generate device archive
xcodebuild archive \
  -scheme <scheme_name> \
  -sdk iphoneos \
  -archivePath "archives/ios_devices.xcarchive" \
  BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
  SKIP_INSTALL=NO
 
// XCFramework generation
xcodebuild -create-xcframework \
    -framework <absolute_path>/archives/ios_devices.xcarchive/Products/Library/Frameworks/<scheme_name>.framework \
    -debug-symbols <absolute_path>/archives/ios_devices.xcarchive/dSYMs/<scheme_name>.framework.dSYM \
    -framework <absolute_path>/archives/ios_simulators.xcarchive/Products/Library/Frameworks/<scheme_name>.framework \
    -debug-symbols <absolute_path>/archives/ios_simulators.xcarchive/dSYMs/<scheme_name>.framework.dSYM \
  -output build/<scheme_name>.xcframework

Upvotes: 0

Related Questions