基于xcodebuild的iOS自动化打包实现

   |   1 minute read   |   Using 313 words

macOS & Xcode

由于iOS系统的特殊性,要实现自动打包的前提是你得有一台运行macOS的苹果电脑,至于是白苹果还是黑苹果都无所谓。

这里我们使用macOS系统自带的xcodebuild命令行工具来实现打包,可以通过在终端输入以下命令来查看xcodebuild的使用详情:

man xcodebuild   

因为xcodebuild这个工具依赖于Xcode,所以你还需要安装Xcode,可以直接从App Store里安装,也可以从开发者网站下载安装,安装多个版本也是可以的,使用的时候可以通过xcode-select来选中你想使用的Xcode版本。

Archive

xcodebuild -workspace ***.xcworkspace -scheme ***Scheme*** -configuration release -archivePath ~/Your/Project/***.xarchive CODE_SIGN_IDENTITY="iPhone Distribution: *** E-Commerce Co. Ltd." PROVISIONING_PROFILE="********-****-****-****-************" clean archive   

Export ipa

xcodebuild -exportArchive -archivePath ~/Your/Project/***.xarchive -exportOptionsPlist ~/Your/Options/***.plist -exportPath ~/Your/Export/Path/***.ipa   

exportOptionsPlist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>enterprise</string>
<key>compileBitcode</key>
<false/>
<key>uploadSymbols</key>
<true/>
<key>teamID</key>
<string>***YOUR TEAM ID***</string>
<key>provisioningProfiles</key>
	<dict>
		<key>com.***.***</key>
		<string>DistributionInHouse-***</string>
	</dict>
	<key>singingCertficate</key>
	<string>iPhone Distribution</string>
</dict>
</plist>   


comments powered by Disqus