Skip to content

[gym] Add app_name parameter to skip xcodebuild -showBuildSettings#29953

Merged
iBotPeaches merged 4 commits into
fastlane:masterfrom
Goeun1001:feature/gym-app-name-parameter
Mar 31, 2026
Merged

[gym] Add app_name parameter to skip xcodebuild -showBuildSettings#29953
iBotPeaches merged 4 commits into
fastlane:masterfrom
Goeun1001:feature/gym-app-name-parameter

Conversation

@Goeun1001

@Goeun1001 Goeun1001 commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

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

scan already supports an app_name parameter that allows skipping xcodebuild -showBuildSettings (#20898, #20897), but gym does not.

In gym, build_command_generator.rb calls Gym.project.app_name to generate the xcodebuild log file name. This triggers xcodebuild -showBuildSettings, which can take 7+ minutes on large workspaces (1200+ targets) and frequently causes timeouts in CI environments.

When users already know their app name, there is no need to invoke this expensive command just to derive a log file name.

Description

  1. gym/lib/gym/options.rb: Added app_name optional parameter (same pattern as scan's app_name)
  2. gym/lib/gym/generators/build_command_generator.rb: Use Gym.config[:app_name] when available, fall back to Gym.project.app_name
  3. gym/spec/build_command_generator_spec.rb: Added unit test for app_name in xcodebuild_log_path

This is a minimal, backward-compatible change — the parameter is optional and falls back to the existing behavior when not provided.

Testing Steps

Specify app_name in gym config:

build_app(
  workspace: "App.xcworkspace",
  scheme: "App",
  app_name: "App"
)

Expected Result: gym does not call xcodebuild -showBuildSettings

Without app_name, behavior is unchanged.

`scan` already supports `app_name` to avoid calling
`xcodebuild -showBuildSettings`, but `gym` does not.

In `gym`, `build_command_generator.rb` calls `Gym.project.app_name`
to generate the xcodebuild log file name. This triggers
`xcodebuild -showBuildSettings`, which can take 7+ minutes on large
workspaces with 1200+ targets.

Adding an `app_name` parameter allows users to skip the expensive
`showBuildSettings` call by providing the value directly, following
the same pattern as `scan`.

Resolves the gym-side of the problem described in fastlane#20897.

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

Adds an optional app_name configuration to gym so users can control the generated xcodebuild logfile name and avoid deriving the app name via Gym.project.app_name (which can trigger an expensive xcodebuild -showBuildSettings call).

Changes:

  • Add app_name as a new optional gym config option (GYM_APP_NAME).
  • Update Gym::BuildCommandGenerator.xcodebuild_log_path to prefer Gym.config[:app_name] over Gym.project.app_name.
  • Add a spec covering xcodebuild_log_path when app_name is provided.

Reviewed changes

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

File Description
gym/lib/gym/options.rb Introduces the new app_name config item for gym.
gym/lib/gym/generators/build_command_generator.rb Uses app_name to construct the xcodebuild logfile name.
gym/spec/build_command_generator_spec.rb Adds test coverage for logfile naming with app_name.

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

Comment thread gym/lib/gym/options.rb Outdated
Comment thread gym/lib/gym/generators/build_command_generator.rb
Comment thread gym/spec/build_command_generator_spec.rb
Comment thread gym/spec/build_command_generator_spec.rb

@iBotPeaches iBotPeaches left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks! I dispatched Copilot - could you help me understand the flow path that xcodebuild -showBuildSettings was called prior to this change? I look at your diff and not seeing how it skips that expensive call.

Apologies if its obvious - I'm just not seeing it.

You'll want to check this test as its failing across the fleet - 1) Gym Gym::BuildCommandGenerator Derived Data Example uses the correct build command with the example project

@Goeun1001 Goeun1001 force-pushed the feature/gym-app-name-parameter branch from f23925f to bfab287 Compare March 31, 2026 11:06
@Goeun1001

Goeun1001 commented Mar 31, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the quick review and for dispatching Copilot, @iBotPeaches! Happy to explain the flow.

How showBuildSettings was triggered before this change:

  1. BuildCommandGenerator#xcodebuild_log_path calls Gym.project.app_name
  2. Project#app_name calls build_settings(key: "WRAPPER_NAME")
  3. Project#build_settings checks @build_settings — if nil, executes xcodebuild -showBuildSettings

So whenever xcodebuild_log_path is called without app_name in the config, it ends up triggering the expensive showBuildSettings command.

With this change, when Gym.config[:app_name] is provided, it uses that value directly and skips Gym.project.app_name entirely, so build_settings is never called from this path.

As a note, build_settings does have other call sites in gym (detect_values.rb, code_signing_mapping.rb), but those are already skippable by setting output_name, configuration, etc. For users who already pass those options (which is common in CI setups), app_name is the last remaining path that triggers showBuildSettings.

Regarding the failing test — I also fixed the Derived Data Example test in this commit. The before(:each) block was missing a Gym.config assignment.

I have addressed the Copilot suggestions as well — updated the description wording, removed requires_xcodebuild, and strengthened the test assertion. Please let me know if there is anything else I should adjust!

- Remove requires_xcodebuild tag since test only checks path construction
- Add expect(Gym.project).not_to receive(:app_name) to verify build
  settings lookup is skipped when app_name is provided
@Goeun1001

Goeun1001 commented Mar 31, 2026

Copy link
Copy Markdown
Contributor Author

Addressing Copilot feedback:

#1 (description wording): Updated to "App name to use in logfile name".

#3 (test assertion): Added expect(Gym.project).not_to receive(:app_name) to verify build settings lookup is actually skipped.

#4 (requires_xcodebuild): Kept requires_xcodebuild: trueGym.config= internally triggers detect_platformbuild_settings which requires Xcode, so the test cannot run on Ubuntu CI without it.

Gym.config= triggers detect_platform which requires Xcode.
Mark test as requires_xcodebuild to skip on Ubuntu CI.
@iBotPeaches

Copy link
Copy Markdown
Member

thanks! That makes sense. I missed that Gym.project.app_name would end up doing a lot more.

@Goeun1001 Goeun1001 requested a review from iBotPeaches March 31, 2026 12:23
Comment thread gym/lib/gym/generators/build_command_generator.rb Outdated
Use || operator instead of if/else as suggested in review.
@Goeun1001 Goeun1001 requested a review from iBotPeaches March 31, 2026 12:53
@iBotPeaches

Copy link
Copy Markdown
Member

CI looks good as well. Just will peek issues to see if we can close any issue with this PR and merge later today.

@iBotPeaches iBotPeaches merged commit e35c12d into fastlane:master Mar 31, 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 @Goeun1001 👋

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

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.

3 participants