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

PBXProject decoding issue #108

Closed
enmiller opened this issue Oct 11, 2017 · 4 comments
Closed

PBXProject decoding issue #108

enmiller opened this issue Oct 11, 2017 · 4 comments
Assignees
Milestone

Comments

@enmiller
Copy link

Context 🕵️‍♀️

While looking to update XcodeGen to use xcproj's latest 0.4.0 release, I ran into an issue while running XcodeGen's unit tests. The failing test was due to PBXProject's Decodable initialization method.

What 🌱

While decoding a PBXProject object, on line 127, there is the following

self.projectRoot = try container.decode(.projectRoot)

However, the projectRoot entry in the project file is projectRoot = "";. My assumption is that the decode() is interpreting the empty string as nil and is throwing an error.

Proposal 🎉

My proposal would be to use decodeIfPresent() instead

self.projectRoot = try container.decodeIfPresent(.projectRoot) ?? ""

Since projectRoot is an optional property of PBXProject, it seems okay if the decoder returns nil here (or an empty string).

@welcome
Copy link

welcome bot commented Oct 11, 2017

Thanks for opening your first issue here! Be sure to follow the issue template!

@enmiller
Copy link
Author

Here is a snippet of the console output when running the XcodeGen unit tests after updating to xcproj 0.4.0 (minor formatting applied)

-> Test Project
  -> generates

 Test Project generates
  .build/checkouts/Spectre.git--7655155069707042687/Sources/Case.swift:31 
Unhandled error: keyNotFound(xcproj.PBXProject.(CodingKeys in _358E3F1E80A5A574E57C81A423F44836).projectRoot, 
Swift.DecodingError.Context(codingPath: [], 
debugDescription: "No value associated with key projectRoot (\"projectRoot\").", underlyingError: nil))

@yonaskolb
Copy link
Collaborator

@pepibumur, it seems some optional properties in #99 weren't made to use decodeIfPresent, such as this projectRoot

@pepicrft
Copy link
Contributor

Good catch, it should be fixed here @enmiller. We'll release a new version on Saturday including the fix. Thanks for the report!

@pepicrft pepicrft added this to the 0.5.0 milestone Oct 11, 2017
@pepicrft pepicrft self-assigned this Oct 11, 2017
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

No branches or pull requests

3 participants