Entitlements are not used for simulator builds
See original GitHub issueEntitlements are ignored for buck builds targeting the simulator. For example, if you have entitlements that specify an app group for your app and extension, the app and extension will not be able to communicate in simulator builds.
For simulator builds, xcode uses adhoc codesigning but embeds the specified entitlements in the (__TEXT,__entitlements)
section of the binary. This can be verified by:
otool -s __TEXT __entitlements -X /path/to/app/binary | xxd -r
Inserting entitlements into the binary requires passing additional linker flags at link time:
-sectcreate __TEXT __entitlements /path/to/entitlements.xcent
This means that entitlements would affect the binary and not the bundle, but the AppleBinary
steps are run before the containing AppleBundle
steps, which is currently what knows about entitlements.
I’m thinking about making a PR to fix the handling of entitlements for simulator builds but I’m not sure what the right approach is. Potentially, AppleBinary
could be given a reference to the entitlements file and use -sectcreate __TEXT __entitlements
flags when targeting appropriate architectures. Is that the right way to go?
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (8 by maintainers)
Top GitHub Comments
We’ve fixed this issue in e79dfd20fafcc9008cbfb2d2526bd77ac38623ba.
apple_binary
now takes a optionalentitlements_file
argument which will add the proper linker flags for simulator builds. Codesigning will also use this entitlement if specified.This has helped us as well. Here is our syntax that worked: