Repository navigation
fix: serialize schemes the way Xcode does - #1189
Open
stefanceriu wants to merge 1 commit into
Open
stefanceriu wants to merge 1 commit into
stefanceriu wants to merge 1 commit into
Conversation
Xcode rewrites schemes generated by XcodeProj as soon as it touches them, which shows up as noise in projects that commit generated schemes. Match Xcode's own output: - Write `TestPlans` as the last child of `TestAction`. - Omit an empty `Testables` element when the scheme uses test plans. - Omit empty `CommandLineArguments` elements. - Only write `runPostActionsOnFailure` when it is enabled. - Write `TestPlanReference` attributes in Xcode's order (`reference`, then `default`). Verified against a scheme re-saved by Xcode 27: regenerating it with these changes produces a byte-identical file.
stefanceriu
marked this pull request as ready for review
September 30, 2026 12:38
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Short description 📝
Schemes written by XcodeProj (and so by XcodeGen) differ slightly from the way Xcode serializes the same scheme. As soon as Xcode touches a generated scheme (running tests, changing the selected test plan, opening the scheme editor) it rewrites the file, which shows up as recurring noise in projects that commit their generated schemes.
For example, for a scheme with a test plan Xcode:
TestPlansto the end ofTestAction,Testableselement,CommandLineArgumentselements,runPostActionsOnFailure = "NO",TestPlanReferenceattributes asreferencethendefault.Solution 📦
Match Xcode's output for each of these cases:
TestPlansas the last child ofTestAction.Testableselement, but only when the scheme uses test plans. Schemes written by Xcode keep an emptyTestableswhen there are no test plans (see the existing Xcode-authored fixtures), so that case is unchanged.CommandLineArgumentsin the test, launch and profile actions when there are no arguments.runPostActionsOnFailurewhen it is enabled.TestPlanReferencetoattributesOrderso its attributes are written asreference,default.To verify, I built XcodeGen 2.46.0 against XcodeProj 9.14.0 with this patch applied and regenerated a real project (element-x-ios). The regenerated scheme is byte-identical to the copy Xcode 27 had saved.
Projects that commit generated schemes will get a one-off diff the first time they regenerate with this change.
Implementation 👩💻👨💻
XCScheme.TestAction.xmlElement().CommandLineArgumentsinLaunchActionandProfileAction.runPostActionsOnFailurewhentrueinBuildAction.TestPlanReferenceattribute order.iOS.xcschemefixture to the newTestPlansposition.Testableswithout test plans, andrunPostActionsOnFailure.