5

same question asked here : XCFramework with Pods Dependencies but in my case i can't have it as cocoapod, i need it to be XCFramework

Our goal is to create a framework that hides our internal code and provide SDK to our customers. We have thought of creating XCFramework which fulfills our requirement. Umbrella framework is also suggested over the internet but mostly suggested to avoid that approach. Our Framework is dependent on some third-party libraries which we are using via Pods.

Issue: XCFramework does not compile pods framework. We got an error like "Xyz(Pod) module not found". Even if we add pods from the client-side it does not work.

Code to create XCFramework is as bellow

  1. Create an archive for iOS platform

    xcodebuild archive -workspace ABC.xcworkspace
    -scheme ABC
    -sdk iphoneos
    -archivePath "./archives/ios_devices.xcarchive"
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES
    SKIP_INSTALL=NO

  2. Create an archive for iOS-Simulator platform

    xcodebuild archive -workspace ABC.xcworkspace
    -scheme ABC
    -sdk iphonesimulator
    -archivePath "./archives/ios_simulators.xcarchive"
    BUILD_LIBRARY_FOR_DISTRIBUTION=YES
    SKIP_INSTALL=NO

  3. Create an XCFramework from Archives

    xcodebuild -create-xcframework
    -framework ./archives/ios_devices.xcarchive/Products/Library/Frameworks/ABC.framework
    -framework ./archives/ios_simulators.xcarchive/Products/Library/Frameworks/ABC.framework
    -output build/ABC.xcframework We got ABC XCFramework successfully but dependencies are not included in XCFramework. Any solution for this? or Is there any way where we can set framework search path to client-side? or Any alternate approach?

abed
  • 71
  • 7

1 Answers1

3

Try Adding -workspace yourworkspace.xcworkspace. pod dependencies are part of .xcworkpspace. so i guess you require workspace to be included.

Dinesh
  • 929
  • 7
  • 25
  • Thank you for your answer. It helps me with the build of .xcframework, but currently I face another problem when using the .xcframework on my demo project. The error is "Failed to build module 'CustomXCFramework' from its module interface; it may have been damaged or it may have triggered a bug in the Swift compiler when it was produced" – Ly Boung Sep 21 '21 at 16:25
  • From my experience. this error also comes when pod dependencies are not properly included in parent app. Check if parent app has pod dependencies included properly. Also check if your custom framework is properly build or not. – Dinesh Sep 23 '21 at 03:20