iOS Framework自动打包
2017-08-08 23:08
363 查看
同事写的更好,在此奉上;
参考链接: https://github.com/guojunliu/steve-document/blob/master/SDK%E8%87%AA%E5%8A%A8%E6%89%93%E5%8C%85.md
armv7
armv7s
arm64
Mac处理器
i386
x86_64
命名为
打开新建的
简单版:
# Sets the target folders and the finalframework product.
# 如果工程名称和Framework的Target名称不一样的话,要自定义FMKNAME
# 例如: FMK_NAME = "MyFramework"
FMK_NAME=${PROJECT_NAME}
# SDK目录
INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework
# Working dir will be deleted after the framework creation.
WRK_DIR=build
DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.framework
SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos clean build
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator clean build
# Cleaning the oldest.
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi
mkdir -p "${INSTALL_DIR}"
cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/"
# Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.
lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/${FMK_NAME}"
rm -r "${WRK_DIR}"
open "${SRCROOT}"
参考链接: https://github.com/guojunliu/steve-document/blob/master/SDK%E8%87%AA%E5%8A%A8%E6%89%93%E5%8C%85.md
背景:
由于iOS Framework打包出来是分CPU指令集的,所以需要每个CPU指令集都打包一个Framework,然后使用lipo -create命令将所有CPU指令集合并,才能形成一个兼容所有设备和模拟器的Framework。这样的打包流程复杂而繁琐,对于需要经常打包测试的需求来说明显是不合适的。
解决方案
使用xcodeAggregate工具中的
Run Script自动进行不同CPU指令集打包,并自动合并所有CPU指令集
处理器指令集介绍
ARM处理器armv7
armv7s
arm64
Mac处理器
i386
x86_64
指令集 | 设备 | 支持设备 |
---|---|---|
arm64 | 真机64位 | iPhone6s、iphone6s plus、iPhone6、iPhone6 plus、iPhone5S、iPad Air、 iPad mini2 |
armv7s | 真机32位 | iPhone5、iPhone5C、iPad4(iPad with Retina Display) |
armv7 | 真机32位 | iPhone4、iPhone4S、iPad、iPad2、iPad3(The New iPad)、iPad mini、iPod Touch 3G、iPod Touch4 |
i386 | 模拟器32位 | 针对intel通用微处理器32位处理器 |
x86_64 | 模拟器64位 | 针对x86架构的64位处理器 |
添加 Aggregate
使用Xcode打开打包工程File→
New→
Target→
Cross-platform→
Aggregate
命名为
AvidlyAdsSDKArchive(自由命名)
添加 Run Script
打开AvidlyAdsSDKArchive``Aggregate
BuildPhases→
New→
+→
Cross-platform→
New Run Script Phase
打开新建的
Run Script,在shell中键入打包代码
shell编写打包代码
# 工程名称 # 如果工程名称和Framework的Target名称不一样的 话,要自定义FMKNAME # 例如: FMK_NAME = "MyFramework" FMK_NAME=${PROJECT_NAME} # 工程Info.list路径 InfoPlist=${SRCROOT}/${PROJECT_NAME}/Info.plist # 工程Version Version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" $InfoPlist) Version=${Version//./} # 工程Build Build=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" $InfoPlist) # SDK文件夹名称 SDKFilePath=${SRCROOT}/${PROJECT_NAME}_${Version}_${Build} # 文件路径是否存在 if [ -d "${SDKFilePath}" ] then rm -rf "${SDKFilePath}" fi mkdir -p "${SDKFilePath}" # 当前时间 updataDate=`date +%F` # 将信息写入文件 updataFileName=${SDKFilePath}/version.md touch ${updataFileName} echo 版本:${Version} >> ${updataFileName} echo 编译:${Build} >> ${updataFileName} echo 时间:${updataDate} >> ${updataFileName} echo 更新: >> ${updataFileName} # SDK目录 INSTALL_DIR=${SDKFilePath}/${FMK_NAME}.framework # Working dir will be deleted after the framework creation. WRK_DIR=build DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.framework SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework # -configuration ${CONFIGURATION} # Clean and Building both architectures. xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos clean build xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator clean build # Cleaning the oldest. if [ -d "${INSTALL_DIR}" ] then rm -rf "${INSTALL_DIR}" fi mkdir -p "${INSTALL_DIR}" cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/" # Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product. lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/${FMK_NAME}" rm -r "${WRK_DIR}" open "${SRCROOT}"
简单版:
# Sets the target folders and the finalframework product.
# 如果工程名称和Framework的Target名称不一样的话,要自定义FMKNAME
# 例如: FMK_NAME = "MyFramework"
FMK_NAME=${PROJECT_NAME}
# SDK目录
INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework
# Working dir will be deleted after the framework creation.
WRK_DIR=build
DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.framework
SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos clean build
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator clean build
# Cleaning the oldest.
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi
mkdir -p "${INSTALL_DIR}"
cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/"
# Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.
lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/${FMK_NAME}"
rm -r "${WRK_DIR}"
open "${SRCROOT}"
相关文章推荐
- 腾讯云游戏语音gcloud voice demo,Unity 5.1打包IOS自动添加CoreTelephony.framework和libstdc++.6.0.9.tbd
- 【iOS打ipa包】:使用终端实现自动打包
- ios自动打包
- golang iOS 自动打包,上传到蒲公英
- iOS 自动打包脚本
- IOSFramework打包。
- [iOS 自动打包上传并自动上传蒲公英]
- 【iOS 开发】将自己的框架打包成 Framework 的方法
- iOS自动打包并发布脚本
- IOS-自动打包Shell脚本(支持目录带空格)
- IOS工程自动打包并发布脚本实现
- IOS工程自动打包并发布脚本实现
- iOS- 一键自动打包发布到Fir和AppStore
- iOS配置shell脚本自动打包上传到蒲公英
- Unity3D研究院之IOS全自动编辑framework、plist、oc代码(六十七)
- iOS一键搞定自动打包并发布到AppStore和Fir
- iOS行货自动打包
- iOS 自动生成framework并自动进行模拟器和真机framework合并
- IOS行货自动打包
- IOS工程自动打包并发布脚本实现