美文网首页iOS Developer
Jenkins 自动打包在xcode9的变动

Jenkins 自动打包在xcode9的变动

作者: 离人萧 | 来源:发表于2017-09-16 21:12 被阅读775次

使用xcode 9命令行打包还是和xcode8有一些不同的,有两个小坑。

因为只是要实现自动打包并分发到fir,所以直接就是用了xcodebuild,并没有装其他的插件(毕竟才两行代码←_←)。

这里是使用的脚本

#!/bin/bash -l
set -e
cd $(dirname $0)
echo | pwd

#这里的SHCEME和CONFIGURATION是从外部传入的参数  
SHCEME=$1
CONFIGURATION=$2
WORKSPACE_PATH=xxxxx.xcworkspace
PROFILE_NAME='PROFILE_NAME'
CODE_SIGN='CODE_SIGN'

#如果使用了RN 则需要先打包RN  没有使用则注释掉
cd ReactNative

npm install

react-native bundle --entry-file index.ios.js --bundle-output ./release_ios/main.jsbundle --platform ios --assets-dest ./release_ios --dev false

cd ..

pod install

TIME_STAMP=`date "+%Y%m%d%H"`
ArchivePath=JenkinsPackage/${SHCEME}.xcarchive
PacktName=JenkinsPackage/${SHCEME}_${TIME_STAMP}

sed -i '' 's/ProvisioningStyle = Automatic;/ProvisioningStyle = Manual;/' ${WORKSPACE_PATH}/project.pbxproj

xcodebuild archive -workspace EFunShop.xcworkspace -scheme ${SHCEME} -configuration ${CONFIGURATION} -sdk iphoneos -archivePath ${ArchivePath} CODE_SIGN_IDENTITY=${CODE_SIGN} PROVISIONING_PROFILE_SPECIFIER=${PROFILE_NAME}

xcodebuild -exportArchive -archivePath ${ArchivePath} -exportPath ${PacktName} -exportOptionsPlist ExportOptions.plist

#这里是用fir 发布的测试包 -T是后台配置的token 
fir publish ${PacktName}/${SHCEME}.ipa -T xxxxxxxx

ExportOptions.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>provisioningProfiles</key>
    <dict>
        <key>com.XXX.BundleID</key>
        <string>provisioningProfiles_NAME</string>
    </dict>
    <key>compileBitcode</key>
    <false/>
    <key>method</key>
    <string>ad-hoc</string>
    <key>teamID</key>
    <string>YOU TEAM ID</string>
</dict>
</plist>

最后是两个小坑
坑1:
xcode9不能使用自动生成的provisioning profile。so,自己手动创建一个provisioning profile。

坑2:
xcode9 的ExportOptions.plist 里需要provisioningProfiles这个字段,这是一个字典。里面包含的参数key是APP的BundleID,value是provisioning profile。

相关文章

网友评论

    本文标题:Jenkins 自动打包在xcode9的变动

    本文链接:https://www.haomeiwen.com/subject/tejusxtx.html