Skip to content

Commit

Permalink
xcodeproj_extensions: fix wrong serialization with local swift packages.
Browse files Browse the repository at this point in the history
In case of a local Swift package, xcodeproj wrongfully uses the
`File.basename` of the path and Xcode fixes that to be the full path.
This commit patches the xcodeproj implementation and fixes it.

Below is an example before and after the change.

before (wrong):
/* Begin XCLocalSwiftPackageReference section */
                BA78EB3B2C889B20000D85B2 /* XCLocalSwiftPackageReference "Package" */ = {
                        isa = XCLocalSwiftPackageReference;
                        relativePath = ../Path/To/Package;
                };

after (correct)
/* Begin XCLocalSwiftPackageReference section */
                BA78EB3B2C889B20000D85B2 /* XCLocalSwiftPackageReference "../Path/To/Package" */ = {
                        isa = XCLocalSwiftPackageReference;
                        relativePath = ../Path/To/Package;
                };
  • Loading branch information
barakwei committed Sep 16, 2024
1 parent b2001c8 commit 90117e1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/kintsugi/xcodeproj_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ def ascii_plist_annotation
" #{display_name.delete_prefix("plugin:")} "
end
end

# The original implementation is `" #{isa} \"#{File.basename(display_name)}\"` so that means that if we have a
# relative path which is Path/To/Package, the item will be serialized as `XCLocalSwiftPackageReference "Package"`.
# And Xcode will automatically fix this to be `XCLocalSwiftPackageReference "Path/To/Package"`.
# So, we need to patch the implementation and make sure the whole path is used.
class XCLocalSwiftPackageReference
def ascii_plist_annotation
" #{isa} \"#{display_name}\" "
end
end
end
end

Expand Down

0 comments on commit 90117e1

Please sign in to comment.