XCode 15 创建 xcframework

方法:

使用 .a 创建

A_FILE_1="./ext/intel/libXXX.a"
A_FILE_2="./ext/apple/libXXX.a"

# Set the path to the output XCFramework bundle
OUTPUT_DIR="./XXX.xcframework"
rm -rf $OUTPUT_DIR

# Create the output directory if it doesn't exist
mkdir -p $OUTPUT_DIR

# Generate the XCFramework bundle
xcodebuild -create-xcframework \
  -library $A_FILE_1 \
  -library $A_FILE_2 \
  -output $OUTPUT_DIR

使用 .framework 创建

xcodebuild -create-xcframework \
    -framework path/to/FrameworkA.framework \
    -framework path/to/FrameworkB.framework \
    -output output_directory

坑:

为了让使用 intel 和 m1 芯片的同学都能使用模拟器或真机, 我们需要两个 .a: intel.a ( iphoneos arm64 + simulator x86_64 ), apple.a ( simulator arm64 ), 然后使用 xcodebuild 命令创建 xcframework
但是升级到 XCode 15 之后, 同样的文件, 同样的命令, 却报错了:

error: binaries with multiple platforms are not supported

各种尝试, 搜索, 最终找到了解决办法:


image.png

删除上面红框中的设置, XCode 15 在 intel 电脑上可以创建所有我们需要的 .a 文件 ( iphoneos arm64 + simulator x86_64 + simulator arm64 ), 不再需要在 m1 电脑上创建 .a
最后, 使用 xcodebuild 创建 xcframework 成功

希望能帮到遇到同样问题的人~

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。