1.打开终端,输入 cd ,并将工程所在文件夹拖入cd 后面,回车。
2.在终端继续输入xcodebuild clean,回车等待,clean成功后截图如下。

3.在终端继续输入xcodebuild archive -project /Users/tliu/Desktop/newDemo/StrategyPattern/StrategyPattern.xcodeproj -scheme StrategyPattern -archivePath bin/StrategyPattern.xcarchive 按回车等待。
其中“/Users/tliu/Desktop/newDemo/StrategyPattern/StrategyPattern.xcodeproj“为工程路径
-scheme 后面为工程名
bin/StrategyPattern.xcarchive 为生成》.xcarchive文件的目标路径可以自己自由设置。
注意: 还有一个坑,如果你的项目使用了Cocoapods那么就输入如下命令:
xcodebuild archive -workspace /Users/tliu/Desktop/newDemo/StrategyPattern/StrategyPattern.xcworkspace -scheme StrategyPattern -archivePath bin/StrategyPattern.xcarchive
参数意思同上。

4.继续输入:xcodebuild -exportArchive -exportOptionsPlist (plist文件路径) -archivePath (.xcarchive文件路径) -exportPath (ipa文件目标路径)
其中关键就是exportOptionsPlist 文件需要在之前通过xcode打包导出ipa时的文件夹中去copy一个出来放在当前工程目录中,然后将其拖入-exportOptionsPlist 后面即可。
网友评论