Skip to content

Generate secrets into each target's DERIVED_FILE_DIR#25768

Draft
mokagio wants to merge 4 commits into
trunkfrom
mokagio/secrets-derived-file-dir
Draft

Generate secrets into each target's DERIVED_FILE_DIR#25768
mokagio wants to merge 4 commits into
trunkfrom
mokagio/secrets-derived-file-dir

Conversation

@mokagio

@mokagio mokagio commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@mokagio mokagio self-assigned this Jul 10, 2026
@dangermattic

Copy link
Copy Markdown
Collaborator
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@mokagio mokagio added this to the 27.1 milestone Jul 10, 2026
@wpmobilebot

wpmobilebot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number33096
VersionPR #25768
Bundle IDcom.jetpack.alpha
Commit45b10e2
Installation URL2ca2r5ofp80n0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number33096
VersionPR #25768
Bundle IDorg.wordpress.alpha
Commit45b10e2
Installation URL2nne78lajmj6o
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

mokagio and others added 4 commits July 10, 2026 12:59
A `sourceTree` the script does not know makes the whole project file
undecodable, failing the `[Lint] Check AppLocalizedString usage` phase after the
Swift compile has already succeeded.
Failing there is right — an unresolvable reference means a file silently goes
unlinted — but the report was
`The data couldn't be read because it isn't in the correct format`, naming
neither the setting nor the value.

`localizedDescription` was throwing that detail away.
Interpolating the error itself yields
`Cannot initialize SourceTree from invalid String value SOME_FUTURE_DIR`,
with the offending object's UUID and key path.

---

Generated with the help of Claude Code, https://claude.com/claude-code

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`WordPress`, `Jetpack` and `Reader` each wrote a different secrets file to the
same `$(BUILD_DIR)/Secrets/Secrets.swift`.
Building one of them left its secrets at a path the next build of another would
see as newer than its inputs, skip regenerating, and compile as its own.

`DERIVED_FILE_DIR` is per-target and per-configuration, so each target now owns
its copy, and the hand-maintained `Secrets-<Target>.swift` names the extensions
needed to dodge the same collision are no longer necessary.

This is the arrangement `doapple` and `wcios` already use.

---

Generated with the help of Claude Code, https://claude.com/claude-code

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The declared input was `ApplyConfiguration.sh`, which no longer exists.
Xcode cannot stat a missing input, so the phase re-ran on every build and
editing `GenerateCredentials.sh` never invalidated it — the opposite of what the
comment above the line promises.

Safe to fix only now that each target writes to its own `DERIVED_FILE_DIR`.
While the three app targets shared one output path, the perpetual re-run was
what kept them from compiling each other's secrets.

---

Generated with the help of Claude Code, https://claude.com/claude-code

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The reference points into `$(DERIVED_FILE_DIR)`, so Xcode draws it red and
`Open Quickly` cannot find it — it reads as a dead reference someone should
clean up, and deleting it stops the apps compiling.

The `Derived Sources` group is repointed from `Classes` to a new `Generated`
directory to give the README somewhere to live.
Its `path` was vestigial: the only child overrides it with `sourceTree =
DERIVED_FILE_DIR`, so nothing resolved through it, and a README added under the
old path would have landed loose in the app's main source directory.

---

Generated with the help of Claude Code, https://claude.com/claude-code

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mokagio mokagio force-pushed the mokagio/secrets-derived-file-dir branch from c915a78 to 45b10e2 Compare July 10, 2026 03:02
# Add the script that uses this file as a source, so that, if the script
# changes, Xcode will run it again on the next build.
${SRCROOT}/../Scripts/BuildPhases/ApplyConfiguration.sh
${SRCROOT}/../Scripts/BuildPhases/GenerateCredentials.sh

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a leftover update that we never noticed. Thanks Claude!

);
outputPaths = (
"$(BUILD_DIR)/Secrets/Secrets.swift",
"$(DERIVED_FILE_DIR)/DerivedSecrets.swift",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered switching to an xcfilelist here but given there's only one output path (so moving to it would have required updating these lines and adding the file, net negative) and that using the file list would have required updating the generation script, I decided against it.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants