Skip to content

Add support for Xcode 27.2's JSON project format - #1653

Open
antigluten wants to merge 1 commit into
yonaskolb:masterfrom
antigluten:feature/json-project-format
Open

antigluten wants to merge 1 commit into
yonaskolb:masterfrom
antigluten:feature/json-project-format

Conversation

@antigluten

Copy link
Copy Markdown

Summary

  • add options.projectFormat: json, which writes project.xcproj instead of project.pbxproj
  • bump XcodeProj to 9.17.1, the release that ships the experimental writer for that format
  • raise the minimum to macOS 14 and Swift 6.1, which that bump brings with it

Xcode 27.2 stores a project as JSON in project.xcproj by default, a format Apple documents and implements in apple/xcode-project-format. XcodeProj shipped an experimental writer for it in 9.17.0. This exposes it as one more projectFormat value rather than a separate option, which is how Xcode 27.2 presents it too: JSON is an entry in the same Project Format pop-up as the object version choices.

The default is unchanged, and nothing differs for anyone who does not opt in.

The requirements bump

XcodeProj 9.17 depends on apple/xcode-project-format, which needs Swift 6.1 and macOS 14, so XcodeGen now needs the same. SwiftPM has no conditional form for this: platforms: is one static declaration per package, and a build with .macOS(.v11) fails with requires minimum platform version 14.0 for the macOS platform. The only alternative was staying on XcodeProj 9.16 and not having the format at all. This is the real cost of the PR and the part most worth pushing back on.

Two things that do not work yet

Against XcodeProj 9.17.1, two spec shapes generate a project Xcode will not open. Both are fixed upstream and unreleased, and both are called out in the docs:

A third upstream bug would have made every regeneration a diff: XcodeProj settles its deterministic object identifiers only while encoding the property list, so the JSON writer emitted a fresh TEMP_<UUID> per run (tuist/XcodeProj#1180). That one is worked around in FileWriter by encoding a property list and discarding it, with a comment saying to drop the workaround once the fix ships.

One unrelated fix

XcodeProj 9.16 added a hostBuildTool product type, which broke the exhaustive switch in Target.defaultLinkage. It is handled alongside the other executable product types.

Test plan

  • swift test, all green
  • scripts/gen-fixtures.sh followed by scripts/diff-fixtures.sh: generated fixtures are unchanged, so the XcodeProj bump alters no existing output
  • four new cases in ProjectGeneratorTests.testProjectFormat: the default still writes project.pbxproj, json writes project.xcproj and reads back as .xcproj, two generations produce byte-identical output, and switching format deletes the file the previous one left behind
  • generated a project with projectFormat: json and confirmed xcodebuild -list reads it, using Xcode 27.0

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.

1 participant