Support destinationFilters for synced folders - #1647
Open
anandghegde wants to merge 2 commits into
Open
anandghegde wants to merge 2 commits into
anandghegde wants to merge 2 commits into
Conversation
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.
Description
destinationFiltersandinferDestinationFiltersByPathwere ignored fortype: syncedFoldersources. Regular sources get the filters on eachPBXBuildFile, but synced folders have no build files, so every file in the folder was compiled for every supported destination.Xcode stores per-file platform filters for synced folders in
platformFiltersByRelativePathon thePBXFileSystemSynchronizedBuildFileExceptionSet, which XcodeProj already supports. This PR fills it in:SourceGenerator.syncedFolderPlatformFilterswalks the synced folder (same traversal assyncedFolderExceptions: recurse into plain directories, treat file wrappers like.xcassetsas files, skip hidden files) and uses the existingmakeDestinationFiltersfor each file. Xcode only honors file paths here, not folder paths, so folders are expanded into files.configureMembershipExceptionsadds those filters to the exception set, leaving out files that are already membership exceptions. An exception set is now also created when there are only platform filters.Note: the example in the issue lists the same synced folder path twice in one target. That already doesn't work on master, separately from filters: only the first source's settings are used, and the group is added to
fileSystemSynchronizedGroupstwice. I left that out to keep this PR small. Using separate folders, or one folder withinferDestinationFiltersByPath, works with this change.Testing
SourceGeneratorTests(destinationFilterswith excludes and a nested folder, andinferDestinationFiltersByPath). Both failed before the change.inferDestinationFiltersByPathtoApp_supportedDestinationsin the TestProject fixture and regenerated it. It hasSyncedFile_iOS.swiftandSyncedFile_tvOS.swift, which declare the same symbol, so the target only builds if the filters are applied.swift testpasses, andscripts/gen-fixtures.sh+scripts/diff-fixtures.shshow no changes after the commit.App_supportedDestinationswith Xcode 26.6 for the iOS Simulator and the tvOS Simulator SDK. Each build compiled only its ownSyncedFile_*.swift. WithplatformFiltersByRelativePathremoved from the generated project by hand, the iOS build fails withinvalid redeclaration of 'syncedPlatformName'.destinationFilterson synced folders (like the example above) and built it foriphonesimulator,xrosandxrsimulator. Each build compiled only the files for its platform plus the unfiltered shared folder.Addresses #1646