Fix Xcode compatibility issues with file system synchronized groups and Swift package references#1031
Open
paul-han-n wants to merge 11 commits intoCocoaPods:masterfrom
Open
Fix Xcode compatibility issues with file system synchronized groups and Swift package references#1031paul-han-n wants to merge 11 commits intoCocoaPods:masterfrom
paul-han-n wants to merge 11 commits intoCocoaPods:masterfrom
Conversation
Remove File.basename() wrapper to preserve the complete display_name path in ascii_plist_annotation output instead of just the base filename.
- Handle https:// and git@ prefixed URLs by extracting last path component - For other formats, split by dot and use last component - Supports both GitHub and custom registry URL formats
…patibility - Add encoding check before unicode_normalize to prevent errors - Only normalize UTF-8 and US-ASCII encoded strings - Ensures compatibility with xcode which uses NFD - Prevents Encoding::CompatibilityError for non-Unicode encodings
…ference Xcode uses only the part before the first dot when generating annotation names for remote Swift package references. e.g., socket.io-client-swift -> socket
fix: extract package name before first dot for XCRemoteSwiftPackageReference
…ode behavior When a PBXFileReference has lastKnownFileType starting with 'folder' and sourceTree is 'SOURCE_ROOT', use the full path for display_name to match Xcode's behavior. For folder references with '<group>' sourceTree, continue using basename as before. This ensures that folder references with SOURCE_ROOT match Xcode's formatting, which uses the full path (e.g., "NaverMap_v5Tests/NaviSearch/Fixtures") rather than just the basename (e.g., "Fixtures") in pbxproj annotations. Fixes issue where re-saving a project would change folder reference annotations from Xcode's format.
fix: use full path for folder references with SOURCE_ROOT to match Xcode behavior
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.
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→repo[email protected]: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