最近看了下命令行打包哩治,發(fā)現(xiàn)網(wǎng)上文章不全豁生,所以總結(jié)了下碧囊。
- 1 進(jìn)入項(xiàng)目路徑
cd /Users/chentao/Desktop/safeBoxApp/DamoApp - 2 清除
xcodebuild clean -project /Users/chentao/Desktop/safeBoxApp/DamoApp/DamoApp.xcodeproj -configuration ${CONFIGURATION} -alltargets - 2 archive 生成xcarchive文件
xcodebuild archive -project /Users/chentao/Desktop/safeBoxApp/DamoApp/DamoApp.xcodeproj -scheme DamoApp -archivePath bin/DamoApp.xcarchive - 3 根據(jù)相關(guān)配置的plist文件導(dǎo)出相關(guān)的ipa包
xcodebuild -exportArchive -archivePath /Users/chentao/Desktop/safeBoxApp/DamoApp/bin/DamoApp.xcarchive -exportPath /Users/chentao/Desktop/safeBoxApp/DamoApp/DamoApp.a -exportOptionsPlist /Users/chentao/Desktop/safeBoxApp/DamoApp/ExportOptions_adoc.plist
上述內(nèi)容中 DamoApp是我項(xiàng)目的名字帚桩,ExportOptions_adoc.plist 是相關(guān)的配置內(nèi)容特漩。
<?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>compileBitcode</key>
<false/>
<key>method</key>
<string>enterprise</string>
<key>provisioningProfiles</key>
<dict>
<key>com.safeBox.keychan</key>
<string>SafeBoxInhouseCer</string>
</dict>
<key>signingCertificate</key>
<string>iPhone Distribution</string>
<key>signingStyle</key>
<string>manual</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>37DS582758</string>
<key>thinning</key>
<string><none></string>
</dict>
</plist>
打包的方式基本有四種,對(duì)應(yīng)的plist文件的一些參數(shù)也會(huì)不一樣
上架appstore:
method = app-store, compileBitcode = YES, uploadSymbols = YES;
企業(yè)證書(shū)包(企業(yè)內(nèi)部使用):
method = enterprise犹菱,compileBitcode = NO拾稳;
adoc包;
method = enterprise腊脱,compileBitcode = NO访得;
develope 包:
method = development,compileBitcode = NO陕凹;
請(qǐng)注意:項(xiàng)目證書(shū)所需手動(dòng)配置悍抑。
隨后發(fā)現(xiàn)一行行敲打指令很麻煩,就寫(xiě)了個(gè)python腳本代碼如下:
#!/usr/bin/env python
import subprocess
def arriveProject():
archiviCmd ="cd /Users/chentao/Desktop/safeBoxApp/DamoApp";
process = subprocess.Popen(archiviCmd,shell = True);
process.wait()
archivieReturnCode = process.returncode;
if archivieReturnCode != 0 :
else :
cleanProject();
def cleanProject():
archiviCmd ="xcodebuild clean -project /Users/chentao/Desktop/safeBoxApp/DamoApp/DamoApp.xcodeproj -configuration ${CONFIGURATION} -alltargets";
process = subprocess.Popen(archiviCmd,shell = True);
process.wait()
archivieReturnCode = process.returncode;
if archivieReturnCode != 0 :
else :
buildWordSapce();
def buildWordSapce():
archiviCmd = "xcodebuild archive -project /Users/chentao/Desktop/safeBoxApp/DamoApp/DamoApp.xcodeproj -scheme DamoApp -archivePath /Users/chentao/Desktop/safeBoxApp/DamoApp/bin/DamoApp.xcarchive"
process = subprocess.Popen(archiviCmd,shell = True);
process.wait()
archivieReturnCode = process.returncode;
if archivieReturnCode != 0 :
else :
exportIpa();
def exportIpa():
archiviCmd ="xcodebuild -exportArchive -archivePath /Users/chentao/Desktop/safeBoxApp/DamoApp/bin/DamoApp.xcarchive -exportPath /Users/chentao/Desktop/safeBoxApp/DamoApp/DamoAppIpa -exportOptionsPlist /Users/chentao/Desktop/safeBoxApp/DamoApp/ExportOptions_appstore.plist";
process = subprocess.Popen(archiviCmd,shell = True);
process.wait()
archivieReturnCode = process.returncode;
if archivieReturnCode != 0 :
else :
cleanArchiveFile()
cleanArchiveBin()
def cleanArchiveFile():
archiviCmd ="rm -r -f /Users/chentao/Desktop/safeBoxApp/DamoApp/build";
process = subprocess.Popen(archiviCmd,shell = True);
process.wait()
archivieReturnCode = process.returncode;
if archivieReturnCode != 0 :
print ("555555")
else :
print ("00000")
def cleanArchiveBin():
archiviCmd ="rm -r -f /Users/chentao/Desktop/safeBoxApp/DamoApp/bin";
process = subprocess.Popen(archiviCmd,shell = True);
process.wait()
archivieReturnCode = process.returncode;
if archivieReturnCode != 0 :
else :
def main():
arriveProject()
if __name__ == '__main__':
main()
最后杜耙,因?yàn)橛行╉?xiàng)目使用了cocapods搜骡,在這里面打包命令有些修改,如下:
cd /Users/chentao/Desktop/ehDEMO/DamoApp
rm -r -f build/
xcodebuild -workspace DamoApp.xcworkspace -scheme DamoApp -archivePath build/DamoApp.xcarchive archive
xcodebuild -exportArchive -archivePath build/DamoApp.xcarchive -exportPath build -exportOptionsPlist ExportOptions_enterprise.plist