-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reuse ReferenceProxy references when possible #1354
Reuse ReferenceProxy references when possible #1354
Conversation
64c0399
to
6a85466
Compare
6a85466
to
49dba0c
Compare
@yonaskolb Is there anything I can do to help you to review this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @OdNairy, looks good
Thanks for this fix @OdNairy 👏. I'm facing a problem using @yonaskolb are you waiting for more PRs to add on next release or there is a release date? |
I was currently investigating something similar to #1339 in my project file and I wanted to test with the latest Prior to this change, I had one unused object reference for a PBXGroup that I was investigating, but now there are a lot of unused PBXContainerItemProxy references in the generated project file: (R.swift has a linting tool that is picking this up for me) The references seem to be related to targets from a different Xcode project of mine:
Perhaps the missing piece here is that we're still creating new |
Ah yes, further up in the file, we're always adding the container item when we create it: XcodeGen/Sources/XcodeGenKit/PBXProjGenerator.swift Lines 410 to 417 in af1adfe
But really I think that we need to do something like this: diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift
index 6e77c3f..9ad0c91 100644
--- a/Sources/XcodeGenKit/PBXProjGenerator.swift
+++ b/Sources/XcodeGenKit/PBXProjGenerator.swift
@@ -407,13 +407,11 @@ public class PBXProjGenerator {
)
)
- let productProxy = addObject(
- PBXContainerItemProxy(
- containerPortal: .fileReference(projectFileReference),
- remoteGlobalID: targetObject.product.flatMap(PBXContainerItemProxy.RemoteGlobalID.object),
- proxyType: .reference,
- remoteInfo: target
- )
+ let productProxy = PBXContainerItemProxy(
+ containerPortal: .fileReference(projectFileReference),
+ remoteGlobalID: targetObject.product.flatMap(PBXContainerItemProxy.RemoteGlobalID.object),
+ proxyType: .reference,
+ remoteInfo: target
)
var path = targetObject.productNameWithExtension()
@@ -437,6 +435,7 @@ public class PBXProjGenerator {
if let existingValue = existingValue {
productReferenceProxy = existingValue
} else {
+ addObject(productProxy)
productReferenceProxy = addObject(
PBXReferenceProxy(
fileType: productReferenceProxyFileType, It fixed the issue in my project file, but I need to run through and see if there is more to it than that or not. |
@liamnichols would you mind opening a PR for this? |
XcodeGen should reuse
PBXReferenceProxy
for external targets when possible. In the current state, Xcode will remove all duplicated dependencies as soon as any change in pbxproj happens.Screen.Recording.2023-05-01.at.10.49.16.mov