我没有勾选entitlements 中的” com.apple.security.network.server“和” com.apple.security.device.usb“,但是确实在打包时又自动出现在包里,我现在无法解决这个问题,我需要帮助,谢谢
我的.entitlements 文件如下: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.security.app-sandbox</key> <true/> <key>com.apple.security.device.bluetooth</key> <true/> <key>com.apple.security.network.client</key> <true/> </dict> </plist>
排查命令:
codesign -d --entitlements :- ./Device\ Guard.app
Executable=/Users/zhanghai/Library/Developer/Xcode/DerivedData/MacGuardApp-fvfnspyxcojxojdfclyohrnupgsh/Build/Products/Debug/Device Guard.app/Contents/MacOS/Device Guard warning: Specifying ':' in the path is deprecated and will not work in a future release <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>com.apple.security.app-sandbox</key><true/><key>com.apple.security.device.bluetooth</key><true/><key>com.apple.security.device.usb</key><true/><key>com.apple.security.get-task-allow</key><true/><key>com.apple.security.network.client</key><true/><key>com.apple.security.network.server</key><true/></dict></plist>
OK.
The .entitlements
file is source code. Xcode does a lot of processing on its content before it passes it along to codesign
to apply to your app. So it’s not uncommon to see problems like this.
Most folks upload there app in two stages:
-
Choose Product > Archive to create an Xcode archive (
.xcarchive
) of the app. -
In the Xcode organiser, select that archive and click Distribute App to actually upload the app.
Are you doing that here?
If so, the Xcode archive makes a good test point, that is, you can dump the entitlements in the archive to see if they’re correct. If they are, you know that the problem was with step 2. Alternatively, if the entitlements in the archive are wrong, you know the problem is with step 1.
To dump the entitlements in the archive:
-
Select it in the Xcode organiser.
-
Control click and choose Show in Finder.
-
In Terminal, dump the entitlements of the enclosed app.
For example, here’s what I see in step 3 for a test app I created in my office:
% codesign -d --entitlements - …/Test790246\ 27-06-2025\,\ 12.54.xcarchive/Products/Applications/Test790246.app
…
[Dict]
[Key] com.apple.security.app-sandbox
[Value]
[Bool] true
[Key] com.apple.security.network.client
[Value]
[Bool] true
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"