一、前言
在使用了ios打包成静态库之后,我们需要使用CI持续集成服务器自动打包测试,在熟悉xcodebuild命令的基础上进行了一下的尝试,以及最后的完成脚本。
二、bundle打包命令
#build bundle
xcodebuild -workspace TestWorkspace.xcworkspace -scheme libLocalTest -configuration Release CONFIGURATION_BUILD_DIR=${WORKSPACE}/build/bundle/ clean build
CONFIGURATION_BUILD_DIR:代表着打包后的输出目录
三、lib包(.a)的打包命令
1.真机版本
xcodebuild -workspace TestWorkspace.xcworkspace -scheme StaticTestCanyin -sdk iphoneos -configuration Release CONFIGURATION_BUILD_DIR=${WORKSPACE}/build/lib/ios/ clean build
2.模拟器版本
xcodebuild -workspace TestWorkspace.xcworkspace -scheme StaticTestCanyin -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=9.2,name=iPhone 5' -configuration Release CONFIGURATION_BUILD_DIR=${WORKSPACE}/build/lib/simulator/ clean build
sdk可以为iphoneos、iphonesimulator代表真机版、模拟器版, destination:代表模拟器版本的适合平台
3.真机版和模拟器版合并命令
#lipo create
rm -rf ${WORKSPACE}/build/lib/LocalTestStaticLib.a lipo -create ${WORKSPACE}/build/lib/ios/libStaticLocalShopTest.a ${WORKSPACE}/build/lib/simulator/libStaticLocalShopTest.a -output ${WORKSPACE}/build/lib/LocalTestStaticLib.a
4.archive命令打发行版本.a包
#build lib with archive
xcodebuild -workspace TestWorkspace.xcworkspace -scheme StaticLocalTest -configuration Release CONFIGURATION_BUILD_DIR=${WORKSPACE}/build/lib/ clean archive
四、打包app
app打archive包
#build app
xcodebuild -workspace TestWorkspace.xcworkspace -scheme TestFirst -configuration Release -sdk iphoneos -archivePath ${WORKSPACE}/build/app/TestFirst-${BUILD_NUMBER} clean archive
这里使用的是默认的证书打包成archive文件
CODE_SIGN_IDENTITY='iPhone Distribution: Beijing ** Agency Co., Ltd.'
PROVISIONING_PROFILE='aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
CODE_SIGN_IDENTITY:证书名称,PROVISIONING_PROFILE:证书本地id
从archive包输出ipa包
xcodebuild -exportArchive -exportFormat IPA -archivePath ${WORKSPACE}/build/app/TestFirst-${BUILD_NUMBER}.xcarchive -exportProvisioningProfile "TestDev" -exportPath /Users/jack/Desktop/ipa/Test-${BUILD_NUMBER} -exportSigningIdentity "iPhone Developer: ****"
exportProvisioningProfile:profile文件名称,exportPath:输出目录,exportSigningIdentity:开发者描述名称
五、pods的lib项目打包完整脚本
#!/bin/bash -l
cd ${WORKSPACE}/LocalShopAndTestLib/Example
pod install
cd ${WORKSPACE}/LocalShopAndTestLib/Example/pods
xcodebuild -scheme LocalShopAndTestLib -sdk iphoneos -configuration Release ARCHS="armv7 armv7s arm64" CONFIGURATION_BUILD_DIR=${WORKSPACE}/build/lib/os clean build
xcodebuild -scheme LocalShopAndTestLib -sdk iphonesimulator -configuration Release CONFIGURATION_BUILD_DIR=${WORKSPACE}/build/lib/simulator clean build
rm -rf ${WORKSPACE}/build/lib/libLocalShopAndTestLib.a
lipo -create ${WORKSPACE}/build/lib/os/libLocalShopAndTestLib.a ${WORKSPACE}/build/lib/simulator/libLocalShopAndTestLib.a -output ${WORKSPACE}/build/lib/libLocalShopAndTestLib.a
mkdir /Users/jack/Desktop/TestIOS/release/ios/Test-${BUILD_NUMBER}
cp -rf ${WORKSPACE}/build/lib/libLocalShopAndTestLib.a /Users/jack/Desktop/TestIOS/release/ios/Test-${BUILD_NUMBER}
cp -rf ${WORKSPACE}/build/lib/os/LocalShopAndTestLib.bundle /Users/jack/Desktop/TestIOS/release/ios/Test-${BUILD_NUMBER}
cd ${WORKSPACE}/LocalShopAndTestLib/Example
xcodebuild -workspace LocalShopAndTestLib.xcworkspace -scheme LocalShopAndTestLib-Example -configuration Release -sdk iphoneos -archivePath ${WORKSPACE}/build/app/TestFirst-${BUILD_NUMBER} ARCHS="armv7 armv7s arm64" clean archive
/Users/jack/Desktop/TestIOS/xcbuild.sh -exportArchive -exportOptionsPlist /Users/jack/Desktop/TestIOS/testpods.plist -archivePath ${WORKSPACE}/build/app/TestFirst-${BUILD_NUMBER}.xcarchive -exportPath /Users/jack/Desktop/TestIOS/ipa/Test-${BUILD_NUMBER}/
xcbuild.sh
#!/bin/bash --login
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" rvm use system xcodebuild "$@"
testpods.plist
<?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>uploadSymbols</key> <true/> <key>uploadBitcode</key> <false/> <key>method</key> <string>development</string> <key>teamID</key> <string>759SFQ3J47</string> </dict> </plist>
pods的lib项目小提示
pods的lib项目打包时由于一些原因,会使用到rvm,这里用xcbuild.sh文件来处理。
testpods.plist文件主要用在最后的打包输出中,类似xcode输出包后的导出步骤。
barryhippo的原创
网友评论