Errors in creating XCFramework using CocoaPods
Asked Answered
M

1

10

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)

Mclaurin answered 8/3, 2020 at 9:10 Comment(5)
Examine the difference between the Xcode command in the build inspector and your command. You’ll be able to spot the difference there.Panhandle
I managed to create XCFramework using swift package manager not cocoa pods but when I imported the created xcframework into sample project it says "Module 'Socket IO' was not compiled with library evolution support; using it means binary compatibility for '<project>' can't be guaranteed. "Mclaurin
Did you get any solution @vinayyedla ?Checklist
Did you solve this?Hance
The build command seems wrong in 1): xcframework build --project XCFramework.xcodeproj --name XCFramework --iOS EcallXCFramework shouldn't it be xcodebuild build... instead of xcframework build ...?Cartwell
J
0

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
Jairia answered 28/9, 2023 at 8:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.