XCFramework制作

Xcode13制作纯swift写的framework时,引用到oc项目时,一只报无法引用头文件错误,改变策略制作xcframework解决问题

生成fat包

1. Buliding Settings -> Architectures -> Build Active Architecture Only 设置为NO
2.Buliding Settings -> Linking -> Mach-O Type 设置为 Static Library
3.Buliding Settings -> Linking -> Dead Code Stripping 设置为 NO

导出Release版本

edit Scheme ->run -> Build configuration 设置为 Release

编译出来command + B ,生成x86_64 arm64 和i386

Xcode->Product->Show Build Folder in Finder

合并文件

xcodebuild -create-xcframework -framework [-framework ] -output

xcodebuild -create-xcframework -framework /Users/xxx/Desktop/Release-iphonesimulator/TrafficClassSDK.framework -framework /Users/xxx/Desktop/Release-iphoneos/TrafficClassSDK.framework -output /Users/xxx/Desktop/XCF/TrafficClassSDK.xcframework

输出结果

xcframework successfully written out to: /Users/xxx/Desktop/XCF/TrafficClassSDK.xcframework

用法和framework一样

你可能感兴趣的:(XCFramework制作)