是否有一种简单的方法可以在Xcode项目中使用每个配置的应用程序组权利字符串?
我们正在尝试使用" app group"在iOS应用程序和今天的扩展程序之间共享设置。两个目标中的权利。
我们遇到的问题是,我们使用不同的捆绑和团队ID构建应用程序,具体取决于它是企业还是发布版本。
当我使用Xcode 6的功能屏幕时,应用程序组以红色字体显示,我看不到单独更改每个配置的字符串的方法。
我认为以下其中一项可行,但我不知道应该先尝试哪一项:
建议?
答案 0 :(得分:21)
您可以为每个配置使用不同的权利文件。这可以在Xcode“Build Settings”用户界面中指定,也可以通过构建配置文件(.xcconfig)完成。
示例xcconfig:
CODE_SIGN_ENTITLEMENTS = Debug.entitlements
CODE_SIGN_ENTITLEMENTS
的值指向此配置的正确权利文件。您可以在Xcode中创建任意数量的配置。默认情况下,Xcode会创建Debug和Release,您可以添加Enterprise并使用构建配置文件,该文件将CODE_SIGN_ENTITLEMENTS
指向企业版本的正确权利文件。
Xcode“Capabilities”用户界面将创建和管理以您的构建产品命名的权利文件。如果需要,您可以直接编辑此文件。
CODE_SIGN_ENTITLEMENTS
设置填充xcconfig文件。
如果您在其中看到粗体文字,请突出显示该构建设置并点击删除。这将删除覆盖xcconfig设置的Xcode构建设置。
答案 1 :(得分:5)
您可以通过"构建设置"进行设置。与设置不同的捆绑ID相同。
步骤:
答案 2 :(得分:0)
Xcode 8似乎有一个错误,因为此问题中的评论表明。
我认为我有一个非常粗暴和危险但工作的解决方法。
我们的想法是只拥有Xcode 8所看到的1个权利文件 有一个脚本将其替换为配置的正确文件 你正在努力建设。
此解决方法有许多步骤,并非所有步骤都可能是必需的。 我将尝试更新此帖子,因为获得了更多信息。 如果你敢于测试这样的东西,请添加评论。
此外,可能需要删除旧的配置文件 在重新打开Xcode 8之前。
在打开Xcode 8之前删除派生数据似乎也有帮助。
警告!自行承担测试风险。这可能会造成不可挽回的损害
设置这个黑色
脚本模板:
#!/bin/bash
echo
if [ ! -n "$BASH" ] ;then echo Please run this script $0 with bash; exit 1; fi
if [ $# -ne 1 ]; then
echo
echo "ERROR: one of the following expected as parameter: release alpha debug"
echo
exit -2
fi
chosen=$1
echo "You have chosen build configuration $chosen"
echo
echo "This script is a workaround for Xcode 8 bug in handling different build configs and app groups."
echo "(This scenario is most likely not on Apples list of things that developers are expected to do.)"
echo
echo "See comments in this SO answer"
echo "http://stackoverflow.com/a/25734318/1148030"
echo
echo "1) This script must be run with Xcode 8 shut down."
echo "2) All old provisioning profiles will be deteled. Xcode 8 will recreate them with hopefully correct build config."
echo
echo
echo "WARNING: This will delete ALL provisioning profiles for all apps!"
echo "WARNING: This will delete ALL MyProject named DerivedData."
echo
read -n 1 -s -p "Press any key to continue or Ctrl-C to cancel"
echo
# NOTE ABOUT DELETING DERIVED DATA
# Deleting derived data fixes 2 bugs:
# 1) Xcode 8 stubbornly generating some distribution profiles for old entitlements files
# 2) Install from HockeyApp fails due to signing verification error
echo "Deleting derived datas"
rm -vrf /Users/pelam/Library/Developer/Xcode/DerivedData/MyProject-*
echo
echo "Deleting provisioning profiles"
rm -v ~/Library/MobileDevice/Provisioning\ Profiles/*.mobileprovision
echo
echo "Replacing target entitlements files"
echo
cp -v "./MyProjectTarget/MyProjectTarget.$chosen.entitlements" "./MyProjectTarget/MyProjectTarget.entitlements" || exit -1
cp -v "./MyProjectAnotherTarget/MyProjectAnotherTarget.$chosen.entitlements" "./MyProjectAnotherTarget/MyProjectAnotherTarget.entitlements" || exit -1
echo ADD COPY COMMANDS FOR OTHER TARGETS HERE
echo
echo "SUCCESS! Now run Xcode and verify that correct profiles are created."
echo
echo "NOTE:"
echo "Running following command after starting Xcode 8 and waiting a bit can show you what appgroup is selected in each profile."
echo "There should only the one correct app group or the release group. No duplicates in one file or mixed."
echo "If you are not using multiple app groups, you can view the provisioning profile files in text editor to see that they contain correct settings for the configuration you are trying to build"
echo "grep -a appgroup ~/Library/MobileDevice/Provisioning\ Profiles/*.mobileprovision"
echo
echo