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

[Fastlane.Swift] readPodspec: return map of [String: Any] #19953

Merged
merged 2 commits into from
Feb 11, 2022

Conversation

Hais
Copy link
Contributor

@Hais Hais commented Feb 11, 2022

🔑

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

Fixes a force-cast crash when using readPodspec.
This is because a podspec can't typically be expressed as just a dictionary of [String: String].

Description

Changing the return type uses an overload of parseDictionary which doesn't force-cast the return value to [String: String], which causes a crash.

This is technically a breaking API change to anyone using readPodspec but I struggle to see how any non-trivial Podspec would have successfully parsed as [String: String].

Testing Steps

Using readPodspec shouldn't crash, and return a successful [String: Any].

Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

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

Good catch here! The Swift code is actually auto generated based on Ruby so I added a commit to fix that. I ran the task that generates the Swift and here is the output 👇

  This can be useful when basing your release process on the version string only stored in one place - in the podspec.
  As one of the first steps you'd read the podspec and its version and the rest of the workflow can use that version string (when e.g. creating a new git tag or a GitHub Release).
  */
-@discardableResult public func readPodspec(path: String) -> [String: String] {
+@discardableResult public func readPodspec(path: String) -> [String: Any] {
     let pathArg = RubyCommand.Argument(name: "path", value: path, type: nil)
     let array: [RubyCommand.Argument?] = [pathArg]
     let args: [RubyCommand.Argument] = array
@@ -13430,4 +13430,4 @@ public let snapshotfile: Snapshotfile = .init()

@joshdholtz joshdholtz merged commit 67a2290 into fastlane:master Feb 11, 2022
@Hais
Copy link
Contributor Author

Hais commented Feb 11, 2022

@joshdholtz Thanks for explaining! I had no idea it was automatically generated. I'll keep this in mind on any future Fastlane Swift contributions.

@fastlane-bot
Copy link

Hey @Hais 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀

Copy link

@fastlane-bot fastlane-bot left a comment

Choose a reason for hiding this comment

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

Congratulations! 🎉 This was released as part of fastlane 2.204.3 🚀

@fastlane fastlane locked and limited conversation to collaborators Apr 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants