Skip to content

[increment_version_number] update MARKETING_VERSION build setting#30031

Merged
iBotPeaches merged 3 commits into
fastlane:masterfrom
andredestro:fix/increment-version-marketing-version
May 21, 2026
Merged

[increment_version_number] update MARKETING_VERSION build setting#30031
iBotPeaches merged 3 commits into
fastlane:masterfrom
andredestro:fix/increment-version-marketing-version

Conversation

@andredestro

Copy link
Copy Markdown

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 see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.
  • I've added or updated relevant unit tests.

Motivation and Context

PR #30011 fixed resolving $(MARKETING_VERSION) when reading the current version, but agvtool new-marketing-version can still leave the MARKETING_VERSION build setting unchanged in modern Xcode projects.

Description

This syncs the new version back to the Xcode project's MARKETING_VERSION build setting after running agvtool.

The project is only saved when MARKETING_VERSION already exists.

Testing Steps

bundle exec rspec fastlane/spec/actions_specs/increment_version_number_action_spec.rb
28 examples, 0 failures
RUBOCOP_CACHE_ROOT=/private/tmp/rubocop_cache bundle exec rubocop fastlane/lib/fastlane/actions/increment_version_number.rb fastlane/spec/actions_specs/increment_version_number_action_spec.rb
2 files inspected, no offenses detected

@iBotPeaches

Copy link
Copy Markdown
Member

thanks! I wonder if we have an official existing action to do the replacement in xcodeproj, so we don't have to double up logic in this action that exists elsewhere.

@andredestro

Copy link
Copy Markdown
Author

thanks! I wonder if we have an official existing action to do the replacement in xcodeproj, so we don't have to double up logic in this action that exists elsewhere.

Good question. I checked the existing xcodeproj-related actions, but I couldn’t find a public action/helper that updates arbitrary build settings like MARKETING_VERSION directly. The closest actions are increment_version_number / increment_build_number, but they rely on agvtool/plist behavior, which is what this change is trying to avoid for generated Info.plist projects.
Happy to extract this into a shared helper if preferred.

@iBotPeaches

Copy link
Copy Markdown
Member

Good question. I checked the existing xcodeproj-related actions, but I couldn’t find a public action/helper that updates arbitrary build settings like MARKETING_VERSION directly. The closest actions are increment_version_number / increment_build_number, but they rely on agvtool/plist behavior, which is what this change is trying to avoid for generated Info.plist projects. Happy to extract this into a shared helper if preferred.

Yeah I think this needs a little cleanup and if you are up for it. I don't like how we are reaching into get_version_number solely to get an xcodeproj project via get_project.

That to me probably should have been in xcodeproj_helper in the core so all Actions have an ability to get an XcodeProj class in a standard way.

Then saying that, a method in the root xcodeproj_helper that takes that Project, then a key and value seems like a good standard to start. So we can evolve match, etc in future to make some changes that other actions are presently needed for. I think an official internal function that other actions can call would boost its strength instead of the present fractured setup we have now between these similar actions.

Does that make sense and are you up for it?

@andredestro

Copy link
Copy Markdown
Author

Does that make sense and are you up for it?

Yep, that makes sense. I moved the Xcode project lookup into Fastlane::Helper::XcodeprojHelper and added a shared helper for updating a build setting across the project and targets.

increment_version_number now uses those helpers instead of reaching into GetVersionNumberAction, while GetVersionNumberAction.get_project! delegates to the helper to keep existing behavior intact.

I also added specs for the new helper methods and updated the increment_version_number specs.

Validated locally with the focused specs and RuboCop. I also tested the increment_version_number(version_number: ...) flow against a copy of a real project that stores MARKETING_VERSION in the Xcode project, and it updates the setting correctly.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates increment_version_number to sync version changes back into Xcode project build settings, addressing MARKETING_VERSION-based projects where agvtool does not update the build setting directly.

Changes:

  • Adds shared Xcode project loading and build-setting update helpers.
  • Updates increment_version_number to save MARKETING_VERSION after agvtool.
  • Adds unit coverage for project loading and build-setting synchronization.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
fastlane/lib/fastlane/actions/increment_version_number.rb Syncs version build settings after running agvtool.
fastlane/lib/fastlane/actions/get_version_number.rb Reuses shared Xcode project loading helper.
fastlane/lib/fastlane/helper/xcodeproj_helper.rb Adds project loading and build-setting update helpers.
fastlane/spec/actions_specs/increment_version_number_action_spec.rb Adds tests for MARKETING_VERSION sync behavior.
fastlane/spec/helper/xcodeproj_helper_spec.rb Adds tests for new Xcode project helper methods.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread fastlane/lib/fastlane/helper/xcodeproj_helper.rb Outdated
Comment thread fastlane/lib/fastlane/actions/increment_version_number.rb Outdated
@andredestro

Copy link
Copy Markdown
Author

Addressed the Copilot review comments.

The helper now handles build settings stored in a base .xcconfig when the setting is not present inline in the pbxproj.

The verbose message now preserves the original format returned by agvtool, so ${MARKETING_VERSION} stays as ${...} in the log.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread fastlane/lib/fastlane/helper/xcodeproj_helper.rb Outdated
Comment thread fastlane/lib/fastlane/helper/xcodeproj_helper.rb Outdated
@andredestro andredestro force-pushed the fix/increment-version-marketing-version branch 2 times, most recently from 8639bad to 8ba61cf Compare May 18, 2026 09:42
@andredestro andredestro requested a review from Copilot May 18, 2026 09:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread fastlane/lib/fastlane/actions/increment_version_number.rb Outdated
Comment thread fastlane/lib/fastlane/helper/xcodeproj_helper.rb Outdated
Comment thread fastlane/lib/fastlane/helper/xcodeproj_helper.rb Outdated
@andredestro andredestro force-pushed the fix/increment-version-marketing-version branch from 8ba61cf to 5685309 Compare May 18, 2026 10:30
@andredestro andredestro requested a review from Copilot May 18, 2026 10:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

fastlane/lib/fastlane/helper/xcodeproj_helper.rb:94

  • Writing .xcconfig files here creates a new kind of version-related modification, but the action never records these paths in Actions.add_modified_files. commit_version_bump only expects the pbxproj/Info.plist files plus paths from MODIFIED_FILES, so lanes that run it after this action can now fail with the updated .xcconfig reported as an unexpected change.
        File.write(path, new_content) if updated

Comment thread fastlane/lib/fastlane/actions/increment_version_number.rb
Comment thread fastlane/lib/fastlane/helper/xcodeproj_helper.rb Outdated
@andredestro andredestro force-pushed the fix/increment-version-marketing-version branch from 5685309 to ed82f18 Compare May 18, 2026 10:57
@iBotPeaches

Copy link
Copy Markdown
Member

Ah this is a bit larger now with the xcconfig stuff - let me read up

@iBotPeaches iBotPeaches merged commit 47c965c into fastlane:master May 21, 2026
9 checks passed

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @andredestro 👋

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 month, 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 🚀"

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

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.235.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants