在构建阶段编辑app.entitlements文件

时间:2017-04-05 12:55:31

标签: ios xcode deep-linking firebase-dynamic-links plistbuddy

我的Xcode项目中有几个目标,每个目标都有一个相关的域但不同的域。

Screenshot a the entitlements file

我希望为我的所有目标设置相同的权利文件,并使用PListBuddy脚本来更改域的值。

我已经有一个可以在Build Phases中正确编辑文件的脚本:

case $TARGET_NAME in
  "EN6") fireBaseUrl="FOO.app.goo.gl";;
  "ES5") fireBaseUrl="BAR.app.goo.gl";;
  "SVT-C4") fireBaseUrl="FOOFOO.app.goo.gl";;
  "PC5") fireBaseUrl="BARBAR.app.goo.gl";;
  *) fireBaseUrl="FOOBAR.app.goo.gl";;
esac

# Universal links used by Firebase
associatedDomainKey="com.apple.developer.associated-domains"
/usr/libexec/PlistBuddy -c "delete ${associatedDomainKey}" app.entitlements
/usr/libexec/PlistBuddy -c "add :${associatedDomainKey} array" -c "add :${associatedDomainKey}:0 string applinks:${fireBaseUrl}" app.entitlements

问题是我有一个"可执行文件是使用无效的权利签署的。"在设备上安装应用程序时出错。

我想这是因为在编辑后,权利文件不再对应于配置文件中包含的权利。

你知道是否有办法做我想做的事吗?使用fastlane,shell脚本或任何东西......(我有40个目标,所以我真的只想获得所有这些目标的一个权利文件)

1 个答案:

答案 0 :(得分:1)

Xcode在对您的应用进行签名之前会使用您的权利创建一个.xcent。您可以添加运行脚本阶段作为最后一步,使用PlistBuddy对其进行修改,如下所示:

echo "Updating ${TARGET_TEMP_DIR}/${FULL_PRODUCT_NAME}.xcent"
/usr/libexec/PlistBuddy -c "add com.apple.developer.icloud-container-environment string Production" "${TARGET_TEMP_DIR}/${FULL_PRODUCT_NAME}.xcent" || exit 1