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

Gym ignores provisioning profile retrieved by Match while building #28803

Open
4 tasks done
peacememories opened this issue Dec 3, 2024 · 4 comments
Open
4 tasks done

Comments

@peacememories
Copy link

peacememories commented Dec 3, 2024

Edit: I renamed the issue and want to provide a bit of context here. While Gym does use the correct provisioning profile while archiving the app, it does not modify the configuration of the target which means it's trying to be built with the "default" profile. This is fine if you only have one build profile, but we have several, which leads to errors in our pipelines where only the profiles actually loaded by Match are present. See this comment for the updatee.

New Issue Checklist

Issue Description

Edit: As stated above, this is not the core of the issue and "fixing" this just leads to new errors.

Gym does not pass the -exportOptionsPlist option to xcodebuild when building.

This can be seen in the difference between build_command_generator.rb and package_command_Generator_xcode7.rb

Why is this a problem?

We are developing a project with multiple app identifiers - one for production and one for development. This also means that we need different provisioning profiles.

Match does the right thing here, finding exactly the right profile. Gym also detects the options set by match, which can be seen in the "Summary for gym" section. The package-step also correctly passes -exportOptionsPlist, so the signing process would succeed if the build succeeded.

Locally this would work because our development machines have all the necessary provisioning profiles installed. So the build would run with a not-quite-correct provisioning profile, but the signing would happen with the correct one. (Side note: we never tested uploading this result to the app store, for all we know it might fail there).

This is not really an option in our pipelines however, since match only downloads the actually needed profiles.

A preferred solution for us would be to add the -exportOptionsPlist argument to the build step.

Command executed
bundle exec fastlane ios build_adhoc_prod
Complete output when running fastlane, including the stack trace and command used
/Users/worker/builds/28PApn6ZK/0/[redacted]/ios/App/vendor/bundle/ruby/3.3.0/gems/httpclient-2.8.3/lib/httpclient.rb:19: warning: mutex_m was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0.
You can add mutex_m to your Gemfile or gemspec to silence this warning.
/Users/worker/builds/28PApn6ZK/0/[redacted]/ios/App/vendor/bundle/ruby/3.3.0/gems/highline-2.0.3/lib/highline/import.rb:10: warning: abbrev was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0.
You can add abbrev to your Gemfile or gemspec to silence this warning.
[12:34:43]: ------------------------------
[12:34:43]: --- Step: default_platform ---
[12:34:43]: ------------------------------
[12:34:43]: Driving the lane 'ios build_adhoc_prod' 🚀
[12:34:43]: ----------------------
[12:34:43]: --- Step: setup_ci ---
[12:34:43]: ----------------------
[12:34:43]: Creating temporary keychain: "fastlane_tmp_keychain".
[12:34:43]: Found keychain '~/Library/Keychains/fastlane_tmp_keychain', creation skipped
[12:34:43]: If creating a new Keychain DB is required please set the `require_create` option true to cause the action to fail
[12:34:43]: $ security list-keychains -d user
[12:34:43]: ▸ "/Users/worker/Library/Keychains/fastlane_tmp_keychain-db"
[12:34:43]: ▸ "/Users/worker/Library/Keychains/login.keychain-db"
[12:34:43]: Found keychain '/Users/worker/Library/Keychains/fastlane_tmp_keychain-db' in list-keychains, adding to search list skipped
[12:34:43]: Enabling match readonly mode.
[12:34:43]: -------------------
[12:34:43]: --- Step: is_ci ---
[12:34:43]: -------------------
[12:34:43]: ---------------------------------------
[12:34:43]: --- Step: app_store_connect_api_key ---
[12:34:43]: ---------------------------------------
[12:34:43]: --------------------------------------------
[12:34:43]: --- Step: Switch to ios build_adhoc lane ---
[12:34:43]: --------------------------------------------
[12:34:43]: Cruising over to lane 'ios build_adhoc' 🚖
[12:34:43]: -------------------
[12:34:43]: --- Step: is_ci ---
[12:34:43]: -------------------
[12:34:44]: -------------------
[12:34:44]: --- Step: match ---
[12:34:44]: -------------------
[12:34:44]: Successfully loaded '[redacted]/fastlane/Matchfile' 📄
+---------------------------------------------------+
|    Detected Values from './fastlane/Matchfile'    |
+----------------+----------------------------------+
| gitlab_project | [redacted]                       |
| gitlab_host    | [redacted]                       |
| storage_mode   | gitlab_secure_files              |
| type           | development                      |
+----------------+----------------------------------+
+---------------------------------------------------------------------------+
|                         Summary for match 2.225.0                         |
+----------------------------------------+----------------------------------+
| type                                   | adhoc                            |
| readonly                               | true                             |
| force_for_new_devices                  | true                             |
| api_key                                | ********                         |
| generate_apple_certs                   | true                             |
| skip_provisioning_profiles             | false                            |
| app_identifier                         | ["[redacted].prod"]              |
| team_id                                | [redacted]                       |
| storage_mode                           | gitlab_secure_files              |
| git_branch                             | master                           |
| shallow_clone                          | false                            |
| clone_branch_directly                  | false                            |
| skip_google_cloud_account_confirmation | false                            |
| s3_skip_encryption                     | false                            |
| gitlab_project                         | [redacted]                       |
| gitlab_host                            | [redacted]                       |
| job_token                              | [MASKED]                         |
| keychain_name                          | fastlane_tmp_keychain            |
| force                                  | false                            |
| include_mac_in_profiles                | false                            |
| include_all_certificates               | false                            |
| force_for_new_certificates             | false                            |
| skip_confirmation                      | false                            |
| safe_remove_certs                      | false                            |
| skip_docs                              | false                            |
| platform                               | ios                              |
| derive_catalyst_app_identifier         | false                            |
| fail_on_name_taken                     | false                            |
| skip_certificate_matching              | false                            |
| skip_set_partition_list                | false                            |
| force_legacy_encryption                | false                            |
| verbose                                | false                            |
+----------------------------------------+----------------------------------+
[12:34:44]: Initializing match for GitLab project [redacted] on [redacted]
[12:34:46]: Installing certificate...
+--------------------------------------------------------------------------+
|                          Installed Certificate                           |
+-------------------+------------------------------------------------------+
| User ID           | [redacted]                                           |
| Common Name       | [redacted]                                           |
| Organisation Unit | [redacted]                                           |
| Organisation      | [redacted]                                           |
| Country           | [redacted]                                           |
| Start Datetime    | 2024-11-12 09:20:29 UTC                              |
| End Datetime      | 2025-11-12 09:20:28 UTC                              |
+-------------------+------------------------------------------------------+
[12:34:46]: Installing provisioning profile...
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                               Installed Provisioning Profile                                                                               |
+---------------------+------------------------------------------------------+---------------------------------------------------------------------------------------------------------------+
| Parameter           | Environment Variable                                 | Value                                                                                                         |
+---------------------+------------------------------------------------------+---------------------------------------------------------------------------------------------------------------+
| App Identifier      |                                                      | [redacted].prod                                                                                               |
| Type                |                                                      | adhoc                                                                                                         |
| Platform            |                                                      | ios                                                                                                           |
| Profile UUID        | sigh_[redacted].prod_adhoc                           | [redacted]                                                                                                    |
| Profile Name        | sigh_[redacted].prod_adhoc_profile-name              | match AdHoc [redacted].prod                                                                                   |
| Profile Path        | sigh_[redacted].prod_adhoc_profile-path              | /Users/worker/Library/MobileDevice/Provisioning Profiles/[redacted].mobileprovision                           |
| Development Team ID | sigh_[redacted].prod_adhoc_team-id                   | [redacted]                                                                                                    |
| Certificate Name    | sigh_[redacted].prod_adhoc_certificate-name          | Apple Distribution: [redacted]                                                                                |
+---------------------+------------------------------------------------------+---------------------------------------------------------------------------------------------------------------+
[12:34:46]: All required keys, certificates and provisioning profiles are installed 🙌
[12:34:46]: Setting Provisioning Profile type to 'ad-hoc'
[12:34:46]: -----------------------
[12:34:46]: --- Step: build_app ---
[12:34:46]: -----------------------
[12:34:46]: Resolving Swift Package Manager dependencies...
[12:34:46]: $ xcodebuild -resolvePackageDependencies -workspace App.xcworkspace -scheme App\ PROD -configuration Debug
[12:34:46]: ▸ Command line invocation:
[12:34:46]: ▸     /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -resolvePackageDependencies -workspace App.xcworkspace -scheme "App PROD" -configuration Debug
[12:34:46]: ▸ User defaults from command line:
[12:34:46]: ▸     IDEPackageSupportUseBuiltinSCM = YES
[12:34:46]: ▸ resolved source packages: 
[12:34:46]: $ xcodebuild -showBuildSettings -workspace App.xcworkspace -scheme App\ PROD -configuration Debug 2>&1
[12:34:47]: Detected provisioning profile mapping: {:"[redacted].prod"=>"match AdHoc [redacted].prod"}
+--------------------------------------------------------------------------------------------------------------------------+
|                                                 Summary for gym 2.225.0                                                  |
+--------------------------------------------------------------+-----------------------------------------------------------+
| workspace                                                    | App.xcworkspace                                           |
| scheme                                                       | App PROD                                                  |
| configuration                                                | Debug                                                     |
| clean                                                        | true                                                      |
| export_method                                                | ad-hoc                                                    |
| output_directory                                             | ./output                                                  |
| output_name                                                  | App_prod                                                  |
| export_options.provisioningProfiles.[redacted].prod          | match AdHoc [redacted].prod                               |
| silent                                                       | false                                                     |
| skip_package_ipa                                             | false                                                     |
| skip_package_pkg                                             | false                                                     |
| build_path                                                   | /Users/worker/Library/Developer/Xcode/Archives/2024-12-03 |
| result_bundle                                                | false                                                     |
| buildlog_path                                                | ~/Library/Logs/gym                                        |
| destination                                                  | generic/platform=iOS                                      |
| xcodebuild_formatter                                         | xcpretty                                                  |
| build_timing_summary                                         | false                                                     |
| skip_profile_detection                                       | false                                                     |
| xcodebuild_command                                           | xcodebuild                                                |
| skip_package_dependencies_resolution                         | false                                                     |
| disable_package_automatic_updates                            | false                                                     |
| use_system_scm                                               | false                                                     |
| xcode_path                                                   | /Applications/Xcode.app                                   |
+--------------------------------------------------------------+-----------------------------------------------------------+
[12:34:47]: $ set -o pipefail && xcodebuild -workspace App.xcworkspace -scheme App\ PROD -configuration Debug -destination 'generic/platform=iOS' -archivePath /Users/worker/Library/Developer/Xcode/Archives/2024-12-03/App_prod\ 2024-12-03\ 12.34.47.xcarchive clean archive | tee /Users/worker/Library/Logs/gym/App\ PROD-App\ PROD.log | xcpretty
[12:34:49]: ▸ Clean Succeeded
[12:34:51]: ▸     Run script build phase '[CP] Embed Pods Frameworks' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'App PROD' from project 'App')
[12:34:51]: ▸ ** ARCHIVE FAILED **
[12:34:51]: ▸ The following build commands failed:
[12:34:51]: ▸ 	Archiving workspace App with scheme App PROD
[12:34:51]: ▸ (1 failure)
▸ Clean Succeeded
    Run script build phase '[CP] Embed Pods Frameworks' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'App PROD' from project 'App')
** ARCHIVE FAILED **
The following build commands failed:
	Archiving workspace App with scheme App PROD
(1 failure)
[12:34:51]: Exit status: 65
+-----------------------------------------+
|            Build environment            |
+---------------+-------------------------+
| xcode_path    | /Applications/Xcode.app |
| gym_version   | 2.225.0                 |
| export_method | ad-hoc                  |
| sdk           | iPhoneOS18.1.sdk        |
+---------------+-------------------------+
[12:34:51]: ▸ Build description signature: [redacted]
[12:34:51]: ▸ Build description path: /Users/worker/Library/Developer/Xcode/DerivedData/App-[redacted]/Build/Intermediates.noindex/ArchiveIntermediates/App PROD/IntermediateBuildFilesPath/XCBuildData/[redacted].xcbuilddata
[12:34:51]: ▸ /Users/worker/builds/28PApn6ZK/0/[redacted]/ios/App/App.xcodeproj: error: No profile for team '[redacted]' matching 'match AppStore [redacted].prod' found: Xcode couldn't find any provisioning profiles matching '[redacted]/match AppStore [redacted].prod'. Install the profile (by dragging and dropping it onto Xcode's dock item) or select a different one in the Signing & Capabilities tab of the target editor. (in target 'App PROD' from project 'App')
[12:34:51]: ▸ /Users/worker/builds/28PApn6ZK/0/[redacted]/ios/App/App.xcodeproj: warning: The Copy Bundle Resources build phase contains this target's Info.plist file '/Users/worker/builds/28PApn6ZK/0/[redacted]/ios/App/App/App PROD-Info.plist'. (in target 'App PROD' from project 'App')
[12:34:51]: ▸ warning: Run script build phase '[CP] Embed Pods Frameworks' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'App PROD' from project 'App')
[12:34:51]: 
[12:34:51]: ⬆️  Check out the few lines of raw `xcodebuild` output above for potential hints on how to solve this error
[12:34:51]: 📋  For the complete and more detailed error log, check the full log at:
[12:34:51]: 📋  /Users/worker/Library/Logs/gym/App PROD-App PROD.log
[12:34:51]: 
[12:34:51]: Looks like fastlane ran into a build/archive error with your project
[12:34:51]: It's hard to tell what's causing the error, so we wrote some guides on how
[12:34:51]: to troubleshoot build and signing issues: https://docs.fastlane.tools/codesigning/getting-started/
[12:34:51]: Before submitting an issue on GitHub, please follow the guide above and make
[12:34:51]: sure your project is set up correctly.
[12:34:51]: fastlane uses `xcodebuild` commands to generate your binary, you can see the
[12:34:51]: the full commands printed out in yellow in the above log.
[12:34:51]: Make sure to inspect the output above, as usually you'll find more error information there
[12:34:51]: 
+-----------------------------------------------------------------------------------------------------------+
|                                               Lane Context                                                |
+------------------------------------+----------------------------------------------------------------------+
| DEFAULT_PLATFORM                   | ios                                                                  |
| PLATFORM_NAME                      | ios                                                                  |
| LANE_NAME                          | ios build_adhoc_prod                                                 |
| KEYCHAIN_PATH                      | ~/Library/Keychains/fastlane_tmp_keychain                            |
| ORIGINAL_DEFAULT_KEYCHAIN          | "/Users/worker/Library/Keychains/fastlane_tmp_keychain-db"           |
| SIGH_PROFILE_TYPE                  | ad-hoc                                                               |
| MATCH_PROVISIONING_PROFILE_MAPPING | {"[redacted].prod"=>"match AdHoc [redacted].prod"}                   |
+------------------------------------+----------------------------------------------------------------------+
[12:34:51]: Called from Fastfile at line 36
[12:34:51]: ```
[12:34:51]:     34:	    # Export method is the same as the match step above
[12:34:51]:     35:	    # https://docs.fastlane.tools/actions/build_app/
[12:34:51]:  => 36:	    build_app(
[12:34:51]:     37:	      workspace: "App.xcworkspace",
[12:34:51]:     38:	      scheme: options[:build_scheme],
[12:34:51]: ```
[12:34:51]: Error building the application - see the log above
+-----------------------------------------------------+
|                  fastlane summary                   |
+------+--------------------------------+-------------+
| Step | Action                         | Time (in s) |
+------+--------------------------------+-------------+
| 1    | default_platform               | 0           |
| 2    | setup_ci                       | 0           |
| 3    | is_ci                          | 0           |
| 4    | app_store_connect_api_key      | 0           |
| 5    | Switch to ios build_adhoc lane | 0           |
| 6    | is_ci                          | 0           |
| 7    | match                          | 2           |
| 💥   | build_app                      | 5           |
+------+--------------------------------+-------------+
[12:34:51]: fastlane finished with errors
[!] Error building the application - see the log above
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1

Environment

🚫 fastlane environment 🚫

Stack

Key Value
OS 14.5
Ruby 3.3.6
Bundler? false
Git git version 2.39.5 (Apple Git-154)
Installation Source ~/.rvm/gems/ruby-3.3.6/bin/fastlane
Host macOS 14.5 (23F79)
Ruby Lib Dir ~/.rvm/rubies/ruby-3.3.6/lib
OpenSSL Version OpenSSL 3.4.0 22 Oct 2024
Is contained false
Is homebrew false
Is installed via Fabric.app false
Xcode Path /Applications/Xcode.app/Contents/Developer/
Xcode Version 16.1
Swift Version 6.0.2

System Locale

Error
No Locale with UTF8 found 🚫

fastlane files:

`./fastlane/Fastfile`
default_platform(:ios)

before_all do |lane, options|
  # Detect if we are running in CI, and create a temporary keychain
  # and switch match to readonly mode
  # https://docs.fastlane.tools/actions/setup_ci/
  setup_ci

  # Login to App Store Connect in order to perform actions later
  # in this process. Configuration provided by environment variables added
  # by the GitLab Apple Apps Store integration
  # https://docs.gitlab.com/ee/user/project/integrations/apple_app_store.html
  # https://docs.fastlane.tools/actions/app_store_connect_api_key/
  if is_ci then
    app_store_connect_api_key
  end
end

platform :ios do

  desc "Build and sign the application for development"
  lane :build_adhoc do |options|
    # Download and install the correct signing certificates for the
    # given build environment, in this case development
    # https://docs.fastlane.tools/actions/match/
    match(
      type: 'adhoc',
      readonly: is_ci,
      force_for_new_devices: true,
      api_key: lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
    )

    # Build the app with the supplied configuration settings
    # Export method is the same as the match step above
    # https://docs.fastlane.tools/actions/build_app/
    build_app(
      workspace: "App.xcworkspace",
      scheme: options[:build_scheme],
      configuration: "Debug",
      clean: true,
      export_method: "ad-hoc",
      output_directory: "./output",
      output_name: options[:ipa_output_name]
    )
  end

  desc "Build and sign the application for development, Firebase ENTW configuration"
  lane :build_adhoc_entw do |options|
    build_adhoc(build_scheme: "App ENTW", ipa_output_name: "App_entw.ipa")
  end

  desc "Build and sign the application for development, Firebase PROD configuration"
  lane :build_adhoc_prod do |options|
    build_adhoc(build_scheme: "App PROD", ipa_output_name: "App_prod.ipa")
  end

  desc "Build and sign the application for distribution, upload to TestFlight"
  lane :release_testflight do |options|
    # Download and install the correct signing certificates for the
    # given build environment, in this case appstore
    # https://docs.fastlane.tools/actions/match/
    match(
      type: 'appstore',
      readonly: is_ci,
      force_for_new_devices: true,
      api_key: lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
    )

    current_testflight_build_number = latest_testflight_build_number(
      initial_build_number: 1,
      api_key: lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
    )

    # Auto increment the build number for Test Flight
    # https://docs.fastlane.tools/actions/increment_build_number/
    # https://docs.fastlane.tools/actions/latest_testflight_build_number/
    increment_build_number(
      build_number: current_testflight_build_number + 1,
      xcodeproj: "App.xcodeproj",
    )

    # Build the app with the supplied configuration settings
    # Export method is the same as the match step above
    # Note: the difference between `appstore` and `app-store` is intentional
    # https://docs.fastlane.tools/actions/build_app/
    build_app(
      workspace: "App.xcworkspace",
      scheme: options[:build_scheme],
      configuration: "Release",
      clean: true,
      export_method: "app-store",
      output_directory: "./"
    )

    # Upload the newly created build to Test Flight using the App Store Connect
    # API key above, and the app configuration in the Appfile
    # https://docs.fastlane.tools/actions/upload_to_testflight/
    upload_to_testflight(
      verbose: true,
      api_key: lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
    )
  end

  desc "Build with Firebase ENTW configuration and sign the application for distribution, upload to TestFlight"
  lane :release_testflight_entw do
    release_testflight(build_scheme: "App ENTW")
  end

  desc "Build with Firebase PROD configuration and sign the application for distribution, upload to TestFlight"
  lane :release_testflight_prod do
    release_testflight(build_scheme: "App PROD")
  end
end
`./fastlane/Appfile`
for_lane :build_adhoc_entw do
    app_identifier("<redacted>.entw")
end

for_lane :release_testflight_entw do
    app_identifier("<redacted>.entw")
end

for_lane :build_adhoc_prod do
    app_identifier("<redacted>.prod")
end

for_lane :release_testflight_prod do
    app_identifier("<redacted>.prod")
end

if ENV["APPLE_ID"] then
  apple_id(ENV["APPLE_ID"])
end

itc_team_id("<redacted>") # App Store Connect Team ID
team_id("<redacted>") # Developer Portal Team ID

# For more information about the Appfile, see:
#     https://docs.fastlane.tools/advanced/#appfile

fastlane gems

Gem Version Update-Status
fastlane 2.225.0 ✅ Up-To-Date

Loaded fastlane plugins:

No plugins Loaded

Loaded gems
Gem Version
error_highlight 0.6.0
did_you_mean 1.6.3
syntax_suggest 2.0.1
artifactory 3.0.17
babosa 1.0.4
base64 0.2.0
CFPropertyList 3.0.7
colored 1.2
highline 2.0.3
commander 4.6.0
dotenv 2.8.1
emoji_regex 3.2.3
faraday-cookie_jar 0.0.7
fastimage 2.3.1
sysrandom 1.0.5
fastlane-sirp 1.0.0
gh_inspector 1.1.3
uber 0.1.0
declarative 0.0.20
trailblazer-option 0.1.2
representable 3.2.0
retriable 3.1.2
mini_mime 1.1.5
multi_json 1.15.0
os 1.1.4
googleauth 1.8.1
httpclient 2.8.3
google-apis-core 0.11.3
google-apis-androidpublisher_v3 0.54.0
google-apis-playcustomapp_v1 0.13.0
google-cloud-env 1.6.0
multipart-post 2.4.1
naturally 2.2.1
plist 3.7.1
rubyzip 2.3.2
security 0.1.5
simctl 1.6.10
terminal-notifier 2.0.0
terminal-table 3.0.2
tty-screen 0.8.2
tty-cursor 0.7.1
tty-spinner 0.9.3
word_wrap 1.0.0
rouge 2.0.7
xcpretty 0.3.0
xcpretty-travis-formatter 1.0.1
set 1.1.0
public_suffix 6.0.1
addressable 2.8.7
aws-eventstream 1.3.0
aws-sigv4 1.10.1
aws-partitions 1.1001.0
jmespath 1.6.2
aws-sdk-core 3.212.0
aws-sdk-kms 1.95.0
aws-sdk-s3 1.170.0
bundler 2.5.22
rexml 3.3.9
nkf 0.2.0
excon 0.112.0
ruby2_keywords 0.0.5
faraday-retry 1.0.3
faraday-rack 1.0.0
faraday-patron 1.0.0
faraday-net_http_persistent 1.2.0
faraday-net_http 1.0.2
faraday-multipart 1.0.4
faraday-httpclient 1.0.1
faraday-excon 1.1.0
faraday-em_synchrony 1.0.0
faraday-em_http 1.0.0
faraday 1.10.4
faraday_middleware 1.2.1
domain_name 0.6.20240107
http-cookie 1.0.7
jwt 2.9.3
signet 0.19.0
rake 13.2.1
digest-crc 0.6.5
google-apis-storage_v1 0.31.0
google-apis-iamcredentials_v1 0.17.0
google-cloud-errors 1.4.0
google-cloud-core 1.7.1
google-cloud-storage 1.47.0
json 2.8.1
mini_magick 4.13.2
optparse 0.5.0
unicode-display_width 2.6.0
nanaimo 0.4.0
colored2 3.1.2
claide 1.1.0
atomos 0.1.3
xcodeproj 1.27.0
forwardable 1.3.3
logger 1.6.1
pathname 0.3.0
shellwords 0.2.0
cgi 0.4.1
date 3.3.4
timeout 0.4.1
stringio 3.1.1
securerandom 0.3.2
uri 0.13.1
ipaddr 1.2.6
openssl 3.2.0
digest 3.1.1
io-nonblock 0.3.0
zlib 3.1.1
resolv 0.3.0
io-wait 0.3.1
time 0.3.0
open-uri 0.4.1
mutex_m 0.2.0
net-http 0.4.1
net-protocol 0.2.2
english 0.8.0
erb 4.0.3
strscan 3.1.0
abbrev 0.1.2
io-console 0.7.1
tempfile 0.2.1
delegate 0.3.1
fileutils 1.7.2
tmpdir 0.2.0
singleton 0.2.0
open3 0.2.1
prettyprint 0.2.0
pp 0.5.0
find 0.2.0
ostruct 0.6.0
yaml 0.3.0
psych 5.1.2
@allan735
Copy link

Facing same issue here. Help is appreciated. Virginia VA DMV

@peacememories
Copy link
Author

It seems like passing -exportOptionsPlist during the build step is not the solution I was looking for:

xcodebuild: error: The flag -exportArchive is required when specifying -exportOptionsPlist

The problem remains that the Gym build ignores the provisioning profile retrieved by Match. I will update the Issue name and try to find further workarounds.

I tried using update_project_provisioning, but it does not find provisioning profiles retrieved by Match by itself.

I am now trying to use sigh and manually setting its adhoc option to retrieve (or generate? I'm not quite sure what sigh really does) the correct provisioning profile. This seems to be working well locally, though I have yet to test it in our Gitlab pipelines.

The code currently looks something like

# ... match etc
sigh(adhoc: true)
update_project_provisioning
#... gym etc

If this does not work I might try extracting the right profile path from the environment variables Match sets (namely sigh_<appid>_appstore_profile-path.

I would much prefer to just have Match and Gym working together properly here, though. update_project_provisioning itself cautions against using it:

You’re updating provisioning profiles directly in your project, but have you considered easier ways to do code signing?
https://docs.fastlane.tools/codesigning/GettingStarted/

But the advice it gives seems to plain not work when you want to switch provisioning profiles for one target definition.

The last workaround would be to create additional targets with the correct provisioning profile set. But I'd rather not have 8 targets to manage. 4 is already absurd for just two app ids with basically the same app otherwise.

I will report back as I try these workarounds

@peacememories peacememories changed the title Gym does not pass -exportOptionsPlist during build Gym ignores provisioning profile retrieved by Match while building Dec 20, 2024
@peacememories
Copy link
Author

If it's deemed that Gym shouldn't update the target definitions (fair, that is pretty intrusive) it would still be a big benefit to have Match and update_project_provisioning work directly together instead of having to detour via Sigh or gluing them together manually

@peacememories
Copy link
Author

Reporting back:

Using Sigh did not work for us:

'api_key' value must be a Hash! Found String instead.

I assume this is an incompatibility with how Match expects the api key, but I did not investigate further.

I did however get all of this working with some manual plumbing from Match to update_project_provisioning:

app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
env_key = "sigh_#{app_identifier}_appstore_profile-path" # Replace appstore with adhoc for an adhoc build

# Needed because Match does not set the provisioning profile for Gym
update_project_provisioning(
  profile: ENV[env_key]
)

I also had to fix some values in the XCode project to get this working:

disable_automatic_code_signing(
  team_id: CredentialsManager::AppfileConfig.try_fetch_value(:team_id),
  code_sign_identity: "iPhone Distribution"
)

I hope this helps as a workaround

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

2 participants