如何从自有CocoaPod(Honey)创建xcframework?正确归档方式解析
问题:选择哪种方式创建xcarchive以生成xcframework?
我有一个名为Honey的CocoaPod,附带示例应用,项目根目录结构如下:
Example Honey Honey.xcodeproj Honey.xcworkspace Podfile Podfile.lock Pods Pods.xcodeproj
我应该选择以下哪种方式创建xcarchive,用于后续生成xcframework?
选项1 - 使用示例项目的Honey scheme
xcodebuild archive -workspace "Example/Honey.xcworkspace" -scheme "Honey" -destination "generic/platform=iOS Simulator" -configuration Release only_active_arch=no -archivePath "build/iOS-Sim" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES OTHER_SWIFT_FLAGS="-Xfrontend -module-interface-preserve-types-as-written"
选项2 - 使用Pods项目
xcodebuild archive -project "Example/Pods/Pods.xcodeproj" -scheme "Honey (Pods Project)" -destination "generic/platform=iOS Simulator" -configuration Release only_active_arch=no -archivePath "build/iOS-Sim" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES OTHER_SWIFT_FLAGS="-Xfrontend -module-interface-preserve-types-as-written"
结论与原因
我原本以为两种方式都可行——毕竟只会引入公开符号(类型、函数、变量),正常情况下示例文件夹里没有公开符号,Honey Pod也不会引用示例代码,最终生成的xcframework API应该一致。但实际只有选项2是正确的,因为它完全不会尝试引入示例项目的代码,从根源上避免了可能的冗余代码或编译问题。
内容的提问来源于stack exchange,提问作者mfaani
相关产品推荐
相关产品推荐

