如何从Release构建中移除com.apple.security.get-task-allow权限?
解决Release构建移除com.apple.security.get-task-allow权限的方法
检查项目Entitlements文件配置
- 打开Xcode项目,找到
Entitlements.plist文件(没有的话右键项目→New File→搜索"Property List",命名为Entitlements.plist) - 找到
com.apple.security.get-task-allow键值对,右键选择"Add Conditional Value" - 给Debug配置设值为
YES,Release配置设值为NO - 如果是通过Signing & Capabilities面板添加的权限,点击权限旁的"Info"按钮,只勾选Debug配置,取消Release的勾选
- 打开Xcode项目,找到
确认Build Settings里的Entitlements路径
- 进入项目Build Settings,搜索
Code Signing Entitlements - 确保Debug和Release配置都正确指向你的
Entitlements.plist路径(比如$(SRCROOT)/YourProjectName/Entitlements.plist) - 要是不同配置用不同Entitlements文件,得分别设置,保证Release对应的文件里没有这个权限或者值为NO
- 进入项目Build Settings,搜索
清理缓存重新构建
- 执行
Product -> Clean Build Folder(快捷键Shift+Command+K) - 删除DerivedData目录(就是你命令里的
/Users/user/Library/Developer/Xcode/DerivedData/LABService-emdoarcsbzcuepbrkkkpbcckcaqx) - 重新用Release配置构建,之后再用以下命令验证:
codesign -d --entitlements - --xml /Users/user/Library/Developer/Xcode/DerivedData/LABService-emdoarcsbzcuepbrkkkpbcckcaqx/Build/Products/Release/MyAppName
- 执行
内容的提问来源于stack exchange,提问作者c00000fd
相关产品推荐
相关产品推荐

