Skip to content
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

Remote project support for PBXContainerItemProxy #425

Merged
merged 6 commits into from
May 22, 2019
Merged

Remote project support for PBXContainerItemProxy #425

merged 6 commits into from
May 22, 2019

Conversation

damirdavletov
Copy link
Contributor

@damirdavletov damirdavletov commented May 20, 2019

Short description 📝

PBXContainerItemProxy can reference objects defined either within the same .xcodeproj or within a remote one.

If the object is within the same .xcodeproj as the proxy then containerPortal property contains PBXProject object and remoteGlobalIDString contains the ID of the object which can be accessed through the normal object pool.
On the other hand if the referenced object is in remote .xcodeproj then containerPortal property contains PBXFileReference of remote .xcodeproj (where the object is located) and remoteGlobalIDString contains the ID of the object which cannot be accessed through the normal object pool so has to accessed as a string.

Currently support for remote project is absent so I'm adding it in this pull request.

Solution 📦

I added containerPortalAsFileReference and remoteGlobalIDString properties to be able to access the values.
Also isContainerPortalFileReference is introduced in order to check if containerPortal is a file reference or not.
Additionally I split the init method onto 2 convenience initialisers, one for local proxy and one for remote.

var containerPortalReference: PBXObjectReference

/// Returns the project that contains the remote object.
/// Returns the project that contains the remote object. If container portal is a remote project this getter will fail. Use isContainerPortalFileReference to check if you can use the getter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that we are in the middle of a major release, I'd take the opportunity to make the API nicer. What about something like:

enum ContainerPortal {
  case project(PBXProject)
  case fileReference(PBXFileReference)
}

// PBXContainerItemProxy
class PBXContainerItemProxy {
  public var containerPortal: ContainerPortal
}

What do you think @damirdavletov ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pepibumur I agree regarding making the API nicer. My objective was not introduce breaking changes, but if that's not problem I'll try to make it nicer. Thanks for the feedback!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we avoid introducing breaking changes but this is a special case because we are working on a major release. Feel free to leverage Swift features to make the API nice :)

return remoteGlobalIDReference?.value
}
set {
remoteGlobalIDReference = newValue.map { PBXObjectReference($0) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong because it's been a long time without playing with this project but I'd say the remoteGlobalIDReference is not necessary. We can just have removeGlobalID of type String.

Copy link
Contributor

@pepicrft pepicrft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great idea @damirdavletov. Thanks for bringing this to the project 👏

@codecov
Copy link

codecov bot commented May 21, 2019

Codecov Report

Merging #425 into master will decrease coverage by 0.12%.
The diff coverage is 51.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #425      +/-   ##
==========================================
- Coverage   79.01%   78.88%   -0.13%     
==========================================
  Files         141      141              
  Lines        6842     6862      +20     
==========================================
+ Hits         5406     5413       +7     
- Misses       1436     1449      +13
Impacted Files Coverage Δ
...codeproj/Objects/Files/PBXContainerItemProxy.swift 66.12% <51.85%> (-14.83%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 07f1ebd...36dfe1e. Read the comment docs.

@codecov
Copy link

codecov bot commented May 21, 2019

Codecov Report

Merging #425 into master will increase coverage by 0.06%.
The diff coverage is 82.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #425      +/-   ##
==========================================
+ Coverage   79.01%   79.07%   +0.06%     
==========================================
  Files         141      141              
  Lines        6842     6859      +17     
==========================================
+ Hits         5406     5424      +18     
+ Misses       1436     1435       -1
Impacted Files Coverage Δ
...codeproj/Objects/Sourcery/Equality.generated.swift 93.93% <100%> (ø) ⬆️
...ojTests/Objects/Targets/PBXNativeTargetTests.swift 100% <100%> (ø) ⬆️
...es/xcodeproj/Objects/Targets/PBXNativeTarget.swift 92.1% <100%> (ø) ⬆️
Sources/xcodeproj/Utils/ReferenceGenerator.swift 85.48% <50%> (ø) ⬆️
...codeproj/Objects/Files/PBXContainerItemProxy.swift 88.13% <81.81%> (+7.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 07f1ebd...65f6738. Read the comment docs.

@damirdavletov
Copy link
Contributor Author

@pepibumur Thanks for the improvement suggestions! Please have a look at the amended implementation as per your comments.

@@ -1,5 +1,11 @@
import Foundation

public enum ContainerPortal {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this one into PBXContainerItemProxy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pepibumur this is done

@pepicrft
Copy link
Contributor

Only one more thing @damirdavletov, could you update the CHANGELOG? Make sure that entry that you add states that the change is a breaking change.

@codecov-io
Copy link

Codecov Report

Merging #425 into master will increase coverage by 0.06%.
The diff coverage is 82.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #425      +/-   ##
==========================================
+ Coverage   79.01%   79.07%   +0.06%     
==========================================
  Files         141      141              
  Lines        6842     6859      +17     
==========================================
+ Hits         5406     5424      +18     
+ Misses       1436     1435       -1
Impacted Files Coverage Δ
...codeproj/Objects/Sourcery/Equality.generated.swift 93.93% <100%> (ø) ⬆️
...ojTests/Objects/Targets/PBXNativeTargetTests.swift 100% <100%> (ø) ⬆️
...es/xcodeproj/Objects/Targets/PBXNativeTarget.swift 92.1% <100%> (ø) ⬆️
Sources/xcodeproj/Utils/ReferenceGenerator.swift 85.48% <50%> (ø) ⬆️
...codeproj/Objects/Files/PBXContainerItemProxy.swift 88.13% <81.81%> (+7.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 07f1ebd...cd9db92. Read the comment docs.

1 similar comment
@codecov-io
Copy link

Codecov Report

Merging #425 into master will increase coverage by 0.06%.
The diff coverage is 82.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #425      +/-   ##
==========================================
+ Coverage   79.01%   79.07%   +0.06%     
==========================================
  Files         141      141              
  Lines        6842     6859      +17     
==========================================
+ Hits         5406     5424      +18     
+ Misses       1436     1435       -1
Impacted Files Coverage Δ
...codeproj/Objects/Sourcery/Equality.generated.swift 93.93% <100%> (ø) ⬆️
...ojTests/Objects/Targets/PBXNativeTargetTests.swift 100% <100%> (ø) ⬆️
...es/xcodeproj/Objects/Targets/PBXNativeTarget.swift 92.1% <100%> (ø) ⬆️
Sources/xcodeproj/Utils/ReferenceGenerator.swift 85.48% <50%> (ø) ⬆️
...codeproj/Objects/Files/PBXContainerItemProxy.swift 88.13% <81.81%> (+7.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 07f1ebd...cd9db92. Read the comment docs.

@damirdavletov
Copy link
Contributor Author

Only one more thing @damirdavletov, could you update the CHANGELOG? Make sure that entry that you add states that the change is a breaking change.

This was already there. Let me know if you need anything else done. Thanks!

@pepicrft pepicrft merged commit a47ec78 into tuist:master May 22, 2019
@yonaskolb
Copy link
Collaborator

I think this may have broken things. Code outside this project can't get access to the uuid of an object, so there isn't a way to access a value to pass into remoteGlobalIDString

@yonaskolb
Copy link
Collaborator

yonaskolb commented Jun 7, 2019

In addition as the uuid may be generated after everything is created, it's not possible to access it anyway. This may need to become an enum instead of a string

enum RemoteGlobalID {
	case object(PBXObject)
	case uuid(String)
}

@pepicrft
Copy link
Contributor

pepicrft commented Jun 7, 2019

Would you mind opening an issue with that @yonaskolb?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants