ios - 如何构建包含 Mac Catalyst 的 Fat Framework?

标签 ios frameworks xcode11 mac-catalyst

如何构建一个包含构建 Mac Catalyst 应用程序所需架构的胖框架?

最佳答案

Apple 引入了一个(未记录?)新目标:x86_64-apple-ios13.0-macabi

如何构建此目标取决于您的框架构建环境。

1) XC框架

如果您的框架是 Xcode 项目:

  • 在 Xcode 中选择目标
  • 选择“常规”标签
  • 在“部署信息”下,勾选“Mac”复选框: enter image description here
  • 构建

2) 外部构建

如果您在 Xcode 之外构建框架,例如一个 C lib,而不是为 x86_64 和 iphonesimulator 构建,而是为新目标 x86_64-apple-ios13.0-macabi 和 macosx 构建。

使用 make 的 C Lib 示例:

MIN_IOS_VERSION="10.0"
LIB_NAME= "theNameOfYourLib"

# The build function
build()
{
ARCH=$1
TARGET=$2
HOST=$3
SDK=$4
SDK_PATH=`xcrun -sdk ${SDK} --show-sdk-path`

export PREFIX=build/${ARCH}
export CFLAGS="-arch ${ARCH} -isysroot ${SDK_PATH} -miphoneos-version-min=${MIN_IOS_VERSION} -std=c99 -target ${TARGET}"
export LDFLAGS="-arch ${ARCH}"
export CC="$(xcrun --sdk ${SDK} -f clang) -arch ${ARCH} -isysroot ${SDK_PATH}"

PKG_CONFIG_ALLOW_CROSS=1 PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig ./configure --host=${HOST} --prefix=$PREFIX

make
make install
}

# Build for all required architectures

build "armv7" "armv7-apple-ios" "arm-apple-darwin" "iphoneos" # MIN_IOS_VERSION must be one of arm7 supported ones to. Else remove this line.
build "arm64" "aarch64-apple-ios" "arm-apple-darwin" "iphoneos"
# build "x86_64" "x86_64-apple-ios" "x86_64-apple-darwin" "iphonesimulator" #obsolete due to x86_64-apple-ios13.0-macabi
build "x86_64" "x86_64-apple-ios13.0-macabi" "x86_64-apple-darwin" "macosx"
build "i386" "i386-apple-ios" "i386-apple-darwin" "iphonesimulator" # same as arm7:  MIN_IOS_VERSION must be one of arm7 supported ones.

# Now find all the artefacts created above (e.g. build/arm64/lib/${LIB_NAME}.a,  build/x86_64/lib/${LIB_NAME}.a ...) and merge them together to a fat lib using lipo

OUTPUT_DIR="fatLib"
lipo -create -output $OUTPUT_DIR/lib/${LIB_NAME}.a build/x86_64/lib/${LIB_NAME}.a build/arm64/lib/${LIB_NAME}.a build/armv7/lib/${LIB_NAME}.a build/i386/lib/${LIB_NAME}.a

# You may also need the header files
cp -R build/armv7/include/* $OUTPUT_DIR/include/
<小时/>

注意:您必须/不能将 x86_64-apple-iosx86_64-apple-ios13.0-macabi 添加到胖库。两者都是 x86_64。仅使用 x86_64-apple-ios13.0-macabi 的那个。

关于ios - 如何构建包含 Mac Catalyst 的 Fat Framework?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58703754/

相关文章:

php - 登录、 session 、用户管理、日志记录模块

html - CSS 框架——现成的还是自己开发的?

core-data - 在 @FetchRequest 中输入一个动态值,以从 SwiftUI 中的核心数据中获取单个实体

ios - 为什么 Swift 不将此 Int 数组文字转换为正确的类型?

ios - 用户拒绝初始提示时的 Apple 推送通知注册回调?

ios - URLSession dataTask返回无错误无数据,导致SwiftyStoreKit.ReceiptError错误1

objective-c - iOS 13 中的 AES 加密 CryptLib 不起作用

ios - PageViewController 显示黑屏

javascript - 在 Angular4 中包含第三方和自定义 JS 文件的最佳方式是什么

ios - 将固定大小设置为图像