The following is for Xcode 7.3.1:
Create
MyApp
project.In the project build settings, set Strip Debug Symbols During Copy (
COPY_PHASE_STRIP
) to No.Set up the
MyApp
target’s code signing in the usual way:
Create a
MyTool
target within the MyApp
project.In the
MyTool
group, create a property list file called MyTool.entitlements
.In that file, add to entries:
both as Booleans with the value set to YES.
IMPORTANT Do not add the file to any targets.
In the
MyTool
build settings, set Code Signing Entitlements (CODE_SIGN_ENTITLEMENTS
) to MyTool/MyTool.entitlements
.Build the tool.
In the
MyApp
target, create a custom Copy Files build phase and:
set Destination to Executables
add MyTool to the list of items to copy
make sure Code Sign On Copy is checked
Build the app.
Now check the entitlements of each item. First, the tool before it was copied into the app.
$ codesign -d --entitlements :- build/Debug/MyTool
Executable=/Users/quinn/Desktop/MyApp/build/Debug/MyTool
<?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.inherit</key>
<true/>
</dict>
</plist>
Next, the tool within the app.
$ codesign -d --entitlements :- build/Debug/MyApp.app/Contents/MacOS/MyTool
Executable=/Users/quinn/Desktop/MyApp/build/Debug/MyApp.app/Contents/MacOS/MyTool
<?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.inherit</key>
<true/>
</dict>
</plist>
Finally, the app itself.
$ codesign -d --entitlements :- build/Debug/MyApp.app
Executable=/Users/quinn/Desktop/MyApp/build/Debug/MyApp.app/Contents/MacOS/MyApp
<?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/>
</dict>
</plist>
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"