使用 pod 依赖构建 XCFramework

abe*_*bed 5 xcode ios swift

这里问同样的问题:XCFramework with Pods Dependency 但就我而言,我不能将其作为 cocoapod,我需要它是 XCFramework

我们的目标是创建一个隐藏我们内部代码的框架并向我们的客户提供SDK。我们想到创建满足我们要求的XCFramework。互联网上也有人建议采用伞形框架,但大多数建议避免这种方法。我们的框架依赖于我们通过 Pod 使用的一些第三方库。

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?

Din*_*esh 4

尝试添加-workspace yourworkspace.xcworkspace. Pod 依赖项是 .xcworkpspace 的一部分。所以我猜你需要包含工作空间。