全部
我有一个脚本来构建和存档我的iPhone应用程序项目,然后将Enterprise软件包导出以复制到公共Web空间。我想进行设置,以便每晚进行测试。尽管它可以从命令行完美运行,但在cron中根本无法运行-进入签名阶段,然后找不到配置文件。
我的脚本-敏感细节被删除(appdeploy目录是映射到Web服务器的samba共享):
#!/bin/bash
cd ${HOME}/logistics-phonegap
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
security unlock-keychain -p $(base64 -D <<<"**REDACTED**") login.keychain
echo "securty unlock-keychain completed with return code $?"
GITDESC=$(git describe)
IFS='v.-' read empty major minor patch depth hash <<<"$GITDESC"
if [ $1 ]
then
CHANNEL=$1
else
CHANNEL=stable
fi
hash=$(printf "%d" 0x${hash:1:7})
EXPORTPLIST=export.$$.plist
pushd platforms/ios
cat > ${EXPORTPLIST} <<EOF
<?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.myapp.myapp</key>
<string>In House Distribution</string>
</dict>
</dict>
</plist>
EOF
ARCHIVEPATH=${PWD}/build/${major}.${minor}.${patch}.${depth}/"MyApp".xcarchive
EXPORTPATH=~/Exports/${major}.${minor}.${patch}.${depth}
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${major}.${minor}.${patch}.${depth}" "MyApp/MyApp-Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${major}.${minor}.${patch}.${depth}.${hash}" "MyApp/MyApp-Info.plist"
echo '*******************************************************************************'
echo '******************************** Build Package ********************************'
echo '*******************************************************************************'
xcodebuild -workspace "MyApp".xcworkspace -scheme "MyApp" -sdk iphoneos -configuration AppStoreDistribution archive -archivePath "${ARCHIVEPATH}"
mkdir -p ${EXPORTPATH}
echo '*******************************************************************************'
echo '******************************* Export Archive ********************************'
echo '*******************************************************************************'
xcodebuild -exportArchive -archivePath "${ARCHIVEPATH}" -exportPath ${EXPORTPATH} -exportOptionsPlist ${EXPORTPLIST}
if [ -a ${EXPORTPATH}/"MyApp.ipa" ]
then
cat > ${EXPORTPATH}/manifest.plist <<EOF
<?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>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>https://api.myapp.com/app/${CHANNEL}/EmployeePortal.ipa</string>
</dict>
<dict>
<key>kind</key>
<string>display-image</string>
<key>url</key>
<string>https://api.myapp.com/app/icon.57x57.${CHANNEL}.png</string>
</dict>
<dict>
<key>kind</key>
<string>full-size-image</string>
<key>url</key>
<string>https://api.myapp.com/app/icon.512x512.${CHANNEL}.png</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>com.myapp.myapp</string>
<key>bundle-version</key>
<string>$major.$minor.$patch.$depth</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>MyApp</string>
</dict>
</dict>
</array>
</dict>
</plist>
EOF
cp -v "${EXPORTPATH}/MyApp.ipa" ~/appdeploy/${CHANNEL}/MyApp.ipa
cp -v ${EXPORTPATH}/manifest.plist ~/appdeploy/${CHANNEL}
fi
rm ${EXPORTPLIST}
popd
编辑:脚本的输出(带有-x标志和stderr传递到stdout)在此处(对于堆栈溢出来说太长了):https://gist.github.com/thirdwheel/5a6f3b3626fd382c5a1bf16cb2bba2fb
答案 0 :(得分:0)
Crontab无权解锁钥匙串
security unlock-keychain -p $(base64 -D <<<"**REDACTED**") login.keychain
答案 1 :(得分:0)
答案似乎是使用launchd
,而不是cron
。启动后可以使用您的帐户访问钥匙串-cron显然不能,因为它以root身份运行,并且放弃了以各种用户身份运行并允许运行作业的权限。
<?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>Label</key>
<string>com.mycompany.myapp.auto</string>
<key>ProgramArguments</key>
<array>
<string>/Users/developer/myapp-phonegap/deployIOS.sh</string>
<string>test</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>0</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/developer/deployIOS-test.err</string>
<key>StandardOutPath</key>
<string>/Users/developer/deployIOS-test.out</string>
</dict>
</plist>