-
-
Notifications
You must be signed in to change notification settings - Fork 327
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
Add Properties PBXFileElement #244
Conversation
Sources/xcproj/PBXFileElement.swift
Outdated
// MARK: - Init | ||
|
||
/// Initializes the file element with its properties. | ||
/// | ||
/// - Parameters: | ||
/// - sourceTree: file source tree. | ||
/// - name: file name. | ||
/// - usesTabs: group uses tabs. |
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.
The documentation comments doesn't seem to match the parameters the constructor takes.
Sources/xcproj/PBXGroup.swift
Outdated
@@ -25,19 +16,26 @@ final public class PBXGroup: PBXFileElement { | |||
/// - sourceTree: group source tree. | |||
/// - name: group name. | |||
/// - path: group path. | |||
/// - wrapsLines: should the IDE wrap lines for files in the group? | |||
/// - usesTabs: group uses tabs. | |||
public init(children: [String], |
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.
Same here. Would you mind adding them? 😬
I'll go through all the files on the project and make sure they are properly documented.
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.
Some minor comments. Good idea to abstract those properties into the PBXFileElement
class. There's something that I keep noticing and is the need of automating the equatable conformance and the constructors using something like Sourcery. As the models grow, it's very easy to introduce a bug in there (and you already found some in the code base).
Are these new properties in |
Good point @yonaskolb. I forgot to consider other subclasses. It seems Xcode implements the following properties in PBXReference:
Those are the four classes in xcproj that directly or indirectly inherit from |
b9adf41
to
58c5a8d
Compare
It seems |
Though I’m not sure what it gets for that. A comment property? Where is that set? |
58c5a8d
to
cffad76
Compare
We didn't have any instances of comments for these family of elements in our codebase, and I'm sure the UI for it has been removed if it ever existed. I can rebase this on top of #243 to set |
Both PBXGroup and PBXFileReference support a wrapsLines property. Add support for unarchiving and archiving it from Xcode projects to prevent data loss.
Both PBXFileReference and PBXGroup may have the includeInIndex property, so move it from PBXFileReference to PBXFileElement so it can be shared by both classes.
Both PBXFileReference and PBXGroup implemented the usesTabs property. Extract it to the base class so both can share the same implementation.
PBXGroup implemented the indentWidth property. Extract it to the base class so it can be shared with PBXFileReference, which also supports the property.
PBXGroup implemented the tabWidth property. Extract it to the base class so it can be shared with PBXFileReference, which also supports the property.
Remove equality checks from the isEqual(to:) implementation that’s performed by the superclass. Now PBXFileReference and PBXGroup only check their unique properties.
Add some additional properties discovered while round tripping some Xcode projects through xcproj. There’s languageSpecificationIdentifier, which is different than xcLanguageSpecificationIdentifier, and plistStructureDefinitionIdentifier.
Refactor PBXVariantGroup so it’s a subclass of PBXGroup instead of PBXFileElement, better modeling the way Xcode handles this type.
Refactor XCVersionGroup so it’s a subclass of PBXGroup instead of PBXFileElement, better modeling the way Xcode handles this type.
Update PBXFileElement to be a subclass of PBXContainerItem to better reflect Xcode’s model, which also adds support for the comments property.
# Conflicts: # CHANGELOG.md
cffad76
to
c9f2a12
Compare
Thanks everyone! |
Short description 📝
PBXFileReference
andPBXGroup
share many properties. Consolidate them inPBXFileElement
and add additional unique properties toPBXFileReference
.Solution 📦
Refactor the
PBXFileReference.includeInIndex
,PBXGroup.usesTabs
,PBXGroup.indentWidth
,PBXGroup.tabWidth
properties so they're implemented inPBXFileReference
so they can be shared by both subclasses. AddPBXFileElement.wrapsLines
,PBXFileReference.languageSpecificationIdentifier
, andPBXFileReference.plistStructureDefinitionIdentifier
.Implementation 👩💻👨💻
PBXFileElement.wrapsLines
property and parameters to thePBXFileElement
,PBXFileReference
, andPBXGroup
initializers.includeInIndex
fromPBXFileReference
toPBXFileElement
and add parameters to thePBXFileElement
andPBXGroup
initializers.usesTabs
fromPBXGroup
toPBXFileElement
and add parameters to thePBXFileElement
andPBXFileReference
initializers.indentWidth
fromPBXGroup
toPBXFileElement
and add parameters to thePBXFileElement
andPBXFileReference
initializers.tabWidth
fromPBXGroup
toPBXFileElement
and add parameters to thePBXFileElement
andPBXFileReference
initializers.languageSpecificationIdentifier
andplistStructureDefinitionIdentifier
toPBXFileReference
and parameters to its initializer.PBXFileReference.isEqual(to:)
andPBXGroup.isEqual(to:)
only compare properties the class implements.This change does not remove any properties or initializer parameters on
PBXGroup
orPBXFileElement
, so source compatibility should be maintained.This change is