在iOS開發中,很多小伙伴會將自已開發的app打包成ipa文件給用戶拿來測試用。當然打包的方式有好幾種。我個人最喜歡還是通過xcodebuild用命令行打包。下面我給大家介紹一下吧。
1.傳統的app打包(沒有使用cocopods)
在打包之前,先把證書和配置文件選好。
step1:打開終端,cd 進入到工程目錄中
step2:xcodebuild clean(如果buid文件存在,就把build過程生產出來的原有文件全部刪除)
step3:xcodebuild -target test -configuration Release(編譯,斜體部分需修改為你自己的工程名)
這一步完成之后,你會發現你的工程目錄里多一個build文件夾,找到里面的.app文件,下一步使用。
step4:xcrun -sdk iphoneos? PackageApplication -v build/Release-iphoneos/test.app -o /Users/apple/Desktop/test.ipa(打包,把.app文件路徑和要打包后文件路徑設置好)
OK,spa文件就打包好了。
2.使用了cocopods后打包
step1:打開終端,cd 進入到工程目錄中
step2:xcodebuild -workspace test.xcworkspace -scheme test -configuration Release(編譯,test為自己的工程名)
step3:xcodebuild -workspace test.xcworkspace -scheme test archive -archivePath /Users/apple/Desktop/test.xcarchive (生成.xcarchive文件)
step4:xcodebuild -exportArchive -exportFormat ipa -archivePath "/Users/apple/Desktop/test.xcarchive" -exportPath "/Users/apple/Desktop/test.ipa" -exportProvisioningProfile "myInHouse" (打包,這里我用的是inHouse證書)
大功告成,打包ipa就這么簡單。