Xcode 8从终端添加功能

时间:2016-11-17 06:02:38

标签: ios xcode bash

我能否从bash中启用推送通知功能? 我的构建使用CI的问题。 如果我使用provision构建调试版本,那就是带有通配符的app bundle * 我将在功能中启用推送通知 debug 构建将无法编译。因为通配符不支持推送通知

但我需要使用正常规定进行发布构建。在这种情况下,我需要在功能中启用推送通知。 如果它是真的,我想用脚本启用它,仅用于发布。

如果有人知道另一种方法会很高兴听到。 如有任何帮助,将不胜感激。 感谢

1 个答案:

答案 0 :(得分:1)

我写的脚本是为了在Cordova项目中启用推送通知。

您需要修改它以将DevelopmentTeam设置为正确的值。

钩/ before_compile / capabilities.sh

#!/bin/sh

# Abort on Error
set -e

APP_NAME=$(sed -e 's/xmlns.*/>/g' config.xml | xmllint --xpath '/widget/name/text()' -)
PROJECT=`find platforms/ios/${APP_NAME} -name project.pbxproj`

# Exit if not required
grep 'TargetAttributes' ${PROJECT} > /dev/null && exit

# Backup
set -x
cp ${PROJECT} ${PROJECT}.orig

# Get ID
ID=`grep -A 1 'Begin PBXNativeTarget section' ${PROJECT} | tail -n 1 | cut -d ' ' -f 1 | tr -d '\t'`

# Inject
sed -i '' -e "/LastUpgradeCheck.*$/a\\
TargetAttributes = {\\
${ID} = {\\
DevelopmentTeam = ABCD1234YZ;\\
SystemCapabilities = {\\
com.apple.Push = {\\
enabled = 1;\\
};\\
};\\
};\\
};" ${PROJECT}

# Compare
diff ${PROJECT}.orig ${PROJECT}