Skip to content

Latest commit

 

History

History
41 lines (25 loc) · 1.69 KB

xcframework.md

File metadata and controls

41 lines (25 loc) · 1.69 KB

创建并使用 xcframework

一、 创建 framework project

image

二、添加类和方法

image

三、设置项目

Build Settings -> Build Library for Distribution 设置为 YES,否则在创建 xcframework 时会报错: No 'swiftinterface' files found within xx.swiftmodule

image

四、创建不同架构的归档文件

  • 真机
xcodebuild archive -scheme Hei -configuration Release -destination 'generic/platform=iOS' -archivePath './build/Hei.framework-iphoneos.xcarchive' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
  • 模拟器
xcodebuild archive -scheme Hei -configuration Release -destination 'generic/platform=iOS Simulator' -archivePath './build/Hei.framework-iphonesimulator.xcarchive' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

五、合并为 xcframework 文件

xcodebuild -create-xcframework -framework './build/Hei.framework-iphoneos.xcarchive/Products/Library/Frameworks/Hei.framework' -framework './build/Hei.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/Hei.framework' -output './build/Hei.xcframework'

六:使用 xcframework 文件

image image image