XcodeGen icon indicating copy to clipboard operation
XcodeGen copied to clipboard

Synced folders

Open yonaskolb opened this issue 8 months ago • 3 comments

This adds support for Xcode 16's synchronized folders, which depending where you look have a few different names:

  • synchronized root groups
  • synchronized folders
  • folder references
  • buildable folders

For our purposes I've chosen the name syncedFolder, looking for feedback on this.

This initial push supports the following:

  • [x] a new syncedFolder source type
  • [x] a new defaultSourceDirectoryType project spec option of the same type that can be used to override the default directory type of group

At the moment only top level synced folders are supported. Xcode also includes a PBXFileSystemSynchronizedBuildFileExceptionSet which has not been added yet here either. There is a load of complexity that has been added to XcodeGen over the years to sources around relative paths, custom parent groups, includes and excludes, mixed target phases, and various other options. In this first pass anything beyond the basics is unsupported for these special folders.

Please test this in your own projects and give feedback about what is broken and how this should be expanded

yonaskolb avatar Apr 15 '25 12:04 yonaskolb

thank you so much! i will give this a try this week, hopefully😅, and come back with feedback :)

esnssr avatar Apr 15 '25 18:04 esnssr

for the very basic use case, which is just "make all of my project's groups -> buildable folders" it works as expected, whether by specifying syncedFolder for defaultSourceDirectoryType, or on the source's path type.

i just tried this on a very small project i have and it worked without any issues whatsoever.

i am yet to try to mix and match with other types and see how it goes... but so far, it gets the job done ❤️🚀

esnssr avatar Apr 15 '25 19:04 esnssr

This is looking pretty cool! Thank you! 🚀

You said "At the moment only top level synced folders are supported.", that's why I can't (yet) specify a group as a parent of a syncedFolder, right?

carlosefonseca avatar May 16 '25 13:05 carlosefonseca

Thank you for the PR ❤️ Is the PR scheduled to be merged before the next release? Is there anything I can help with? I tested it, and it seems to be working great! 🚀

noefroidevaux avatar Jun 30 '25 08:06 noefroidevaux

Would love an ETA on this merge :D

mredig avatar Jul 07 '25 14:07 mredig

This makes it convenient because files created via external editors or AI agents can be immediately recognized and read by Xcode.

s2mr avatar Jul 11 '25 05:07 s2mr

I've fixed the cache from checking all children within synced folders, which should add one of the big benefits of this feature, which is cache not getting invalidated when files are added or removed within a synced folder.

On a project I tested this with I'm getting a duplicate Info.plist error (surprised no one else has mentioned it), which I've attempted to fix here, but it needs an upstream fix https://github.com/yonaskolb/XcodeGen/pull/1560

yonaskolb avatar Jul 17 '25 05:07 yonaskolb

Looks like xcassets folders are no longer included in the build targets, thus breaking pretty badly

Edit: And maybe it's less obvious, but when ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS is enabled (or "generate-swift-asset-symbol-extensions" : "enabled" in the xcasset's Contents.json), the asset "folder" needs to be compiled to generate the resources

clausjoergensen avatar Jul 17 '25 12:07 clausjoergensen