Fix Xcode compatibility issues with file system synchronized groups and Swift package references #1031
+84
−5
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.
Summary
This pull request addresses several Xcode compatibility issues related to file system synchronized groups, Swift package references, and build phase serialization. These fixes ensure that generated project files match Xcode's expected format and maintain proper compatibility with Xcode 15+.
Changes
1. Unicode NFD Normalization for Xcode Compatibility
File:
lib/xcodeproj/project/object.rbAdded Unicode NFD (Normalization Form Decomposed) normalization to the
ascii_plist_annotationmethod. This ensures that special characters in display names are properly normalized to match Xcode's internal representation.Why: Xcode internally uses NFD normalization for strings. Without this normalization, projects with non-ASCII characters (e.g., accented characters, Korean, Japanese) may experience compatibility issues or display inconsistencies when opened in Xcode.
2. Improved Swift Package URL Parsing
File:
lib/xcodeproj/project/object/swift_package_remote_reference.rbEnhanced the
extract_package_namemethod to correctly handle various Git repository URL formats:https://github.com/owner/repo.git→repogit@github.com:owner/repo.git→repodomain.xyz→xyzWhy: Previous implementation didn't correctly parse all URL formats, leading to inconsistent package naming in project files. The improved parser ensures consistent and correct package names across different repository URL schemes.
3. Fixed displayName for File System Synchronized Exception Sets
File:
lib/xcodeproj/project/object/file_system_synchronized_exception_set.rbChanged the
displayNamefor exception sets from descriptive strings to Xcode's internal class names:PBXFileSystemSynchronizedBuildFileExceptionSetfor build file exceptionsPBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSetfor build phase membership exceptionsWhy: Xcode uses the class name as the display name for these objects, not descriptive strings. Using descriptive names caused project file format mismatches.
Added: Support for
attributes_by_relative_pathattribute inPBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSetto match Xcode's data model.4. Remove Empty Exception Arrays from File System Synchronized Root Groups
File:
lib/xcodeproj/project/object/file_system_synchronized_root_group.rbAdded
to_hash_asmethod that excludes emptyexceptionsarrays from serialization.Why: Xcode doesn't serialize empty exception arrays in
PBXFileSystemSynchronizedRootGroupobjects. Including them creates unnecessary diff noise and doesn't match Xcode's output format. Related to #1012.5. Use Full Path in XCLocalSwiftPackageReference Annotations
File:
lib/xcodeproj/project/object/swift_package_local_reference.rbChanged annotation from using
File.basename(display_name)to using the fulldisplay_namepath.Why: Xcode uses the full relative path in annotations for local Swift package references, not just the basename. This ensures the annotation matches Xcode's format exactly.
6. Ensure inputPaths and outputPaths Always Present in Shell Script Build Phases
File:
lib/xcodeproj/project/object/build_phase.rbModified
PBXShellScriptBuildPhaseserialization to always includeinputPathsandoutputPathsarrays, even when empty.Why: Xcode always serializes these fields as empty arrays when not set, rather than omitting them. This prevents unnecessary project file changes when the project is opened and saved in Xcode.
Testing
These changes have been tested to ensure:
Compatibility
Related Issues
()from PBXFileSystemSynchronizedRootGroup exceptions output #1012