-
-
Notifications
You must be signed in to change notification settings - Fork 319
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 Support for Custom Build Rules #197
Conversation
dc33c09
to
b564743
Compare
Generated by 🚫 Danger |
fb7c56b
to
6167d59
Compare
b564743
to
bb1e2ed
Compare
Sources/xcproj/PBXBuildRule.swift
Outdated
public var fileType: String | ||
|
||
/// Element is editable. | ||
public var isEditable: UInt |
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.
Can this take any other values than 1 or 0? Otherwise we can make it a Bool
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.
I believe it's only ever a 1 or 0. There were some existing seemingly Bool properties were using (U)Int but definitely happy to change it.
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.
Yeah, those other ones could be changed in 2.0 as it's a breaking change
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.
Sources/xcproj/PBXBuildRule.swift
Outdated
public var outputFilesCompilerFlags: [String]? | ||
|
||
/// Element script. | ||
public var script: 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.
Script is also optional right? Is there an advantage to making it non optional?
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.
Nice catch. This should definitely be optional.
bb1e2ed
to
fd9c669
Compare
Thanks for the feedback @yonaskolb. Updated the PR. |
Some Xcode projects have custom build rules to automatically invoke a tool when an input file changes. Add a PBXObject subclass, PBXBuildRule, which describes when and how a custom build tool should be invoked. Update PBXProj to store custom build rules and add decoding/encoding support. In addition to updating the tests, verified xcproj correctly round trips a project with custom build rules (custom pattern/custom tool, custom pattern/built-in tool, built-in pattern/custom tool, built-in pattern/built-in tool).
fd9c669
to
faf90a0
Compare
public init(reference: String, | ||
compilerSpec: String, | ||
filePatterns: String? = nil, | ||
fileType: 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.
One more very minor thing. As fileType
is non optional (I don't know if it should be or not), can we move it before optional filePatterns
?
public var compilerSpec: String | ||
|
||
/// Element file patterns. | ||
public var filePatterns: 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.
Out of curiosity. Did you check the optionality of the attributes with Xcode?
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 for fixing this up and merging. @pepibumur, yes, I tried examining the encoded form of of a number of different permutations. compilerSpec
is required so specify how the file should be processed, but filePatterns
is optional since it's a filter on fileType
.
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.
No problem @briantkelley 😛 it was just curiosity. The changes should be in xcproj 1.8.0 ready to be used :)
Short description 📝
Add support for custom build rules, which Xcode uses to automatically invoke a tool when a matching input file changes.
Solution 📦
Add a PBXObject subclass, PBXBuildRule, which can load and store the custom build rule configuration.
Implementation 👩💻👨💻
PBXBuildRule
, which is a subclass ofPBXObject
and add properties for all possible fields in the Xcode project file. Implement Equatable, Decodable, and encoding support.PBXObject
andPBXProj
to support decodingPBXProj
andPBXProjEncoder
to support encodingThis change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)