Skip to content

feat(targets): write generated.entitlements to ios/ instead of source#192

Open
lars-deploy-bot wants to merge 1 commit intoEvanBacon:mainfrom
lars-deploy-bot:@lars-deploy-bot/apple-targets/generated-entitlements-in-ios
Open

feat(targets): write generated.entitlements to ios/ instead of source#192
lars-deploy-bot wants to merge 1 commit intoEvanBacon:mainfrom
lars-deploy-bot:@lars-deploy-bot/apple-targets/generated-entitlements-in-ios

Conversation

@lars-deploy-bot
Copy link
Copy Markdown

Summary

When the entitlements field is set in an expo-target.config, the generated.entitlements file is now written to ios/<productName>/generated.entitlements (the prebuild output) instead of the target's source directory. CODE_SIGN_ENTITLEMENTS is pointed at that location inside configureTargetWithEntitlements.

This keeps the target's source folder free of derived artifacts that previously needed to be either committed or .gitignore-d. The same approach was applied to Info.plist in #189.

Behavior matrix

User has config entitlements Hand-written *.entitlements in source Result
Yes No Generated file at ios/<productName>/generated.entitlements, source dir untouched
Yes Yes Generated file at ios/<productName>/generated.entitlements. Source file is now left untouched (previously it was overwritten) — log line tells the user it's safe to delete
No Yes Unchanged — existing hand-written file is used directly
No No No entitlements file, CODE_SIGN_ENTITLEMENTS removed (unchanged)

configureTargetWithEntitlements checks for ios/<productName>/generated.entitlements first and falls back to globbing the source target directory, so the hand-written-only flow still works.

Files

Test plan

  • `bunx tsc --noEmit` in `packages/apple-targets`
  • `bunx jest --no-watch` in `packages/apple-targets` (8/8 pass — the entitlements path isn't covered by unit tests yet)
  • Manual: target with config-driven entitlements → confirm `ios//generated.entitlements` is generated and `CODE_SIGN_ENTITLEMENTS` points at it; confirm source target dir contains no `generated.entitlements`
  • Manual: target with no config entitlements but a hand-written `foo.entitlements` in source dir → confirm Xcode still uses it (CODE_SIGN_ENTITLEMENTS = `/foo.entitlements`)
  • Manual: re-run `expo prebuild --clean` — file is regenerated correctly
  • Manual: target with both hand-written file AND config entitlements → confirm hand-written file is left untouched, `ios/` file is used, log line appears
  • e2e build (requires macOS + Xcode)

🤖 Generated with Claude Code

When the user defines `entitlements` in `expo-target.config`, the
`generated.entitlements` file is now written to
`ios/<productName>/generated.entitlements` instead of the target's
source directory. `CODE_SIGN_ENTITLEMENTS` is pointed at the new
location inside `configureTargetWithEntitlements`, which prefers the
generated file under `ios/` and falls back to a hand-written
`*.entitlements` file in the source target directory if no generated
one exists.

Result: targets that drive entitlements from the config no longer leave
a derived artifact in the git-tracked source folder. Existing flows
that hand-write a `*.entitlements` file (without using the config field)
continue to work unchanged. If both a hand-written file and a config
`entitlements` block are present, the config wins and the source file
is left untouched (with a log line) instead of being overwritten as
before.

README updated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Bram-dc
Copy link
Copy Markdown

Bram-dc commented May 9, 2026

I thought this would be nicer. I use env variables in my config file so the entitlements file kept changing in the tracked git commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants