1.clean 工程
使用以下命令clean工程:
??xcodebuild clean -project TestAutoPacking.xcodeproj -scheme TestAutoPacking -configuration Release
如果你的工程pod了第三方庫楞遏,那么你的工程目錄下會有".xcworkspace"文件冰木,你將使用這個文件來打開你的項目工程岁忘,我們需要替換下我們的命令:
??xcodebuild clean -workspace TestAutoPacking.xcworkspace -scheme TestAutoPacking -configuration Release
上面的命令中:
??-project TestAutoPacking.xcodeproj:編譯項目名稱
??-workspace TestAutoPacking.xcworkspace:編譯工作空間名稱
??-scheme TestAutoPacking:scheme名稱(一般會與你的項目名稱相同)
??-configuration Release:(Debug/Release)
例如:
xcodebuild clean -workspace /twpt-ios/twpt-ios.xcworkspace -scheme twpt-ios
2.archive導(dǎo)出.xcarchive文件
使用下面的命令archive導(dǎo)出.xcarchive文件:
??xcodebuild archive -project TestAutoPacking.xcodeproj -scheme TestAutoPacking -archivePath /User/.../TestAutoPacking.xcarchive
或者:
??xcodebuild archive -workspace TestAutoPacking.xcworkspace -scheme TestAutoPacking -archivePath /User/.../TestAutoPacking.xcarchive
上面的命令中:
??-project TestAutoPacking.xcodeproj:同clean步驟中一樣
??-workspace TestAutoPacking.xcworkspace:同clean步驟中一樣
??-scheme TestAutoPacking:同clean步驟中一樣
??-archivePath /dandy/xmeAutoArchive/TestAutoPacking.xcarchive:導(dǎo)出.xcarchive文件的目錄以及文件名稱
例如:
xcodebuild archive -workspace /twpt-ios/twpt-ios.xcworkspace -scheme twpt-ios -archivePath /Users/.../testPacking.xcarchive
3.導(dǎo)出ipa包
命令如下:
xcodebuild -exportArchive -exportOptionsPlist xxx/Info.plist -archivePath xxx.xcarchive -exportPath ~/Desktop/
實際使用:
xcodebuild -exportArchive -exportOptionsPlist ../ExportOptions.plist -archivePath ../testPacking.xcarchive -exportPath ./autoPackage -allowProvisioningUpdates
Xcode7之后取消了原來的-exportFormat罕偎,而是使用exportOptionsPlist 來取代躏将,具體的使用方法可以在Terminal打xcodebuild –help查看硬毕。
我們需要自己創(chuàng)建一個plist作為Export Options呻引,只要有這個配置文件,那我們在使用這個命令的時候就能打出跟手動用Xcode Archive之后export出的ipa一樣了
打包需要指定以下信息吐咳,才能完成export操作:
- provisioningProfiles
- compileBitcode
- method
- signingCertificate
- signingStyle
- stripSwiftSymbols
- teamID
- thinning
ExportOptionsPlist文件:
image.png