一般打包採用xcodebuild和xcrun兩個命令,xcodebuild負責編譯,xcrun負責將app打成ipa。web
/usr/bin/xcodebuild -target targetName clean
/usr/bin/xcodebuild -target targetName
三、打包xcode
/usr/bin/xcrun -sdk iphoneos PackageApplication -v path/To/xxx.app -o xxx.ipa
若是是含簽名的包,上面兩個命令須要增長一些參數。app
xcodebuild -target targetName CODE_SIGN_IDENTITY="iPhone Distribution:XXXXXX" xcrun -sdk iphoneos PackageApplication -v 源app路徑 -o 輸出的ipa路徑 --sign "iPhone Distribution:XXXXXX"
自動打包步驟:iphone
//建立鑰匙鏈 security create-keychain -p myapp myapp.keychain //解鎖,不然回彈框等待輸入密碼 security unlock-keychain -p myapp myapp.keychain //導入證書 security import /opt/myapp.p12 -k myapp.keychain -P mypassword -T /usr/bin/codesign
三、以MyApp.app爲模板,copy一個備份,而後進行各類資源的替換,好比替換了應用的圖片文件等ide
四、替換對應的*.mobileprovision文件到MyApp.app目錄ui
五、刪除MyApp.app下的簽名信息_CodeSignaturespa
六、修改info.plist Bundle indentifier和*.mobileprovision一致code
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>application-identifier</key> <string>Z4LR7CBRUD.com.yesun.vic</string> <key>aps-environment</key> <string>production</string> <key>get-task-allow</key> <false/> </dict> </plist>
八、重簽名codesignorm
/usr/bin/codesign --force --sign 9c8b212f6a2c2382847b104e387a01b246d4ce42 --resource-rules=MyApp.app/ResourceRules.plist --entitlements MyApp.xcent Mkey3G.app
九、生成ipa包xml
/usr/bin/xcrun -sdk iphoneos PackageApplication -v MyApp.app -o MyApp.ipa --sign 9c8b212f6a2c2382847b104e387a01b246d4ce42 --embed MyApp.app/embed.mobileprovision
十、刪除鑰匙鏈
security delete-keychain myapp.keychain