正如这个问题中的评论所表明的那样,Xcode 8 似乎有一个错误。
我认为我有一个非常粗糙和危险的,但可行的解决方法。
这个想法是只有 1 个 Xcode 8 看到的权利文件,并有一个脚本将其替换为您尝试构建的配置的正确文件。
此解决方法有许多步骤,并非所有步骤都是必需的。随着获得更多信息,我将尝试更新这篇文章。如果你敢测试这样的东西,请添加评论。
此外,在重新打开 Xcode 8 之前,可能需要删除旧的配置文件。
在打开 Xcode 8 之前删除派生数据似乎也有帮助。
警告!自行承担测试的风险。这会造成不可挽回的损害
设置这个黑客
- 将此脚本保存到您的项目文件夹中。
- 修补您的项目名称和目标名称,其中它读取 MyProject*
- 修补您的配置名称
- 检查此脚本尝试在 MyProject.entitlements 之上复制的每个配置权利文件名
- 在所有配置中将 MyProject.entitlements 配置为权利文件
- 对所有目标执行相同操作(如果您有例如 watchkit 应用程序)
- 在运行脚本之前:
- 在 Xcode 中选择正确的方案
- 关闭 Xcode
脚本模板:
#!/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