利用xcode的命令行工具
xcdeobulid
进行项目的编译打包,生成ipa包,并上传到fir
前言
现在网上的自动打包教程几乎都还是xcodebuild + xcrun
的方式先生成.app
包 再生成.ipa
包,结果弄了一整天硬是没成功~
后来发现PackageApplication is deprecated
,悲剧。然后手动压缩的 .ipa
包因为签名问题无法装到手机上。
后来用了archive + -exportArchive
终于可以了~
首先确保 ruby 的版本不是 2.4.0
在 ruby2.4.0
下,由 archive 生成 ipa包 时会发生错误,需要切换 2.4.0
以下的版本(如 2.3.3
)。
查看项目详情
xcodebuild 的使用可以用 man xcodebuild
查看。
查看项目详情
# cd 项目主目录
xcodebuild -list
输出项目的信息
Information about project "StackGameSceneKit":
Targets:
StackGameSceneKit
StackGameSceneKitTests
Build Configurations:
Debug
Release
If no build configuration is specified and -scheme is not passed then "Release" is used.
Schemes:
StackGameSceneKit
要留意 Configurations
,Schemes
这两个属性。
打包流程
生成 archive
生成archive的命令是 xcodebuild archive
xcodebuild archive -workspace ${project_name}.xcworkspace \
-scheme ${scheme_name} \
-configuration ${build_configuration} \
-archivePath ${export_archive_path}
-
参数一:项目类型,,如果是混合项目 workspace 就用
-workspace
,如果是 project 就用-project
-
-scheme
:项目名,上面xcodebuild -list
中的Schemes
-
-configuration
:编译类型,在configuration
选择,Debug
或者Release
-
-archivePath
:生成 archive 包的路径,需要精确到xx/xx.archive
首先需要创建一个AdHocExportOptions.plist
文件
导出 ipa包
导出ipa包这一步,在ruby2.4.0版本中会报错,所以请使用其他版本的ruby
导出ipa包使用命令:xcodebuild -exportArchive
xcodebuild -exportArchive \
-archivePath ${export_archive_path} \
-exportPath ${export_ipa_path} \
-exportOptionsPlist ${ExportOptionsPlistPath}
-
archivePath
:上面生成 archive 的路径 -
-exportPath
:导出 ipa包 的路径 -
exportOptionsPlist
:导出 ipa包 类型,需要指定格式的plist
文件,分别是AppStroe
、AdHoc
、Enterprise
,如下图

选择这三个类别需要分别创建三个plist
文件:
-
AdHocExportOptionsPlist.plist
-
AppStoreExportOptionsPlist.plist
-
EnterpriseExportOptionsPlist.plist
上传到 Fir
将项目上传到 Fir
下载 fir 命令行工具
gem install fir-cli
获取 fir 的 API Token(右上角)

上传
fir publish "ipa_Path" -T "firApiToken"
自动打包脚本
再次提醒,请不要使用 ruby 2.4.0 运行该脚本!
脚本我fork了 jkpang 的脚本进行修改,添加了自动上传到fir的功能。
代码地址:https://github.com/qiubaiying/iOSAutoArchiveScript
网友评论