Skip to content

Instantly share code, notes, and snippets.

@wndxlori
Last active July 9, 2023 17:02
Show Gist options
  • Save wndxlori/d1a315d5cd3378988db1e83a907e113e to your computer and use it in GitHub Desktop.
Save wndxlori/d1a315d5cd3378988db1e83a907e113e to your computer and use it in GitHub Desktop.

Use match.

Create private git repo to synchronize certs and profiles

Add gem 'fastlane' to the Gemfile in your RubyMotion project directory

Run bundle exec fastlane match init in your RubyMotion project directory

be fastlane match init
[βœ”] πŸš€
[17:56:21]: fastlane match supports multiple storage modes, please select the one you want to use:
1. git
2. google_cloud
3. s3
4. gitlab_secure_files
?  1
[17:56:29]: Please create a new, private git repository to store the certificates and profiles there
[17:56:29]: URL of the Git Repo: git@github.com:wndxlori/match_certificates.git
[17:56:35]: Successfully created './fastlane/Matchfile'. You can open the file using a code editor.
[17:56:35]: You can now run `fastlane match development`, `fastlane match adhoc`, `fastlane match enterprise` and `fastlane match appstore`
[17:56:35]: On the first run for each environment it will create the provisioning profiles and
[17:56:35]: certificates for you. From then on, it will automatically import the existing profiles.
[17:56:35]: For more information visit https://docs.fastlane.tools/actions/match/

Must have bundle identifier already created to produce a development profile, or else you get this error:

be fastlane match development
[βœ”] πŸš€
[17:59:24]: Successfully loaded '/Users/lori/Dropbox/Projects/rubymotion-community/foo/fastlane/Matchfile' πŸ“„

+--------------+------------------------------------------------+
|          Detected Values from './fastlane/Matchfile'          |
+--------------+------------------------------------------------+
| git_url      | git@github.com:wndxlori/match_certificates.gi  |
|              | t                                              |
| storage_mode | git                                            |
| type         | development                                    |
+--------------+------------------------------------------------+


+----------------------------------------+------------------------------------------------+
|                                Summary for match 2.212.1                                |
+----------------------------------------+------------------------------------------------+
| type                                   | development                                    |
| readonly                               | false                                          |
| generate_apple_certs                   | true                                           |
| skip_provisioning_profiles             | false                                          |
| storage_mode                           | git                                            |
| git_url                                | git@github.com:wndxlori/match_certificates.gi  |
|                                        | t                                              |
| git_branch                             | master                                         |
| shallow_clone                          | false                                          |
| clone_branch_directly                  | false                                          |
| skip_google_cloud_account_confirmation | false                                          |
| keychain_name                          | login.keychain                                 |
| force                                  | false                                          |
| force_for_new_devices                  | 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                                          |
| verbose                                | false                                          |
+----------------------------------------+------------------------------------------------+

[17:59:24]: Cloning remote git repo...
[17:59:24]: If cloning the repo takes too long, you can use the `clone_branch_directly` option in match.
[17:59:25]: Checking out branch master...
[17:59:25]: Enter the passphrase that should be used to encrypt/decrypt your certificates
[17:59:25]: This passphrase is specific per repository and will be stored in your local keychain
[17:59:25]: Make sure to remember the password, as you'll need it when you run match on a different machine
[17:59:25]: Passphrase for Match storage: ******************
[18:01:57]: Type passphrase again: ******************
[18:01:59]: πŸ”“  Successfully decrypted certificates repo
[18:01:59]: Verifying that the certificate and profile are still valid on the Dev Portal...
-------------------------------------------------------------------------------------
Please provide your Apple Developer Program account credentials
The login information you enter will be stored in your macOS Keychain
You can also pass the password using the `FASTLANE_PASSWORD` environment variable
See more information about it on GitHub: https://github.com/fastlane/fastlane/tree/master/credentials_manager
-------------------------------------------------------------------------------------
Username: XXXXXX@mac.com
Available session is not valid any more. Continuing with normal login.
[18:03:11]: To not be asked about this value, you can specify it using 'app_identifier'
[18:03:11]: The bundle identifier(s) of your app (comma-separated string or array of strings): org.rubymotioncommunity.foo
[18:03:48]:
[18:03:48]: ==========================================
[18:03:48]: Could not find App ID with bundle identifier 'org.rubymotioncommunity.foo'
[18:03:48]: You can easily generate a new App ID on the Developer Portal using 'produce':
[18:03:48]:
[18:03:48]: fastlane produce -u  -a org.rubymotioncommunity.foo --skip_itc
[18:03:48]:
[18:03:48]: You will be asked for any missing information, like the full name of your app
[18:03:48]: If the app should also be created on App Store Connect, remove the --skip_itc from the command above
[18:03:48]: ==========================================
[18:03:48]:
[18:03:48]: An app with that bundle ID needs to exist in order to create a provisioning profile for it
[18:03:48]: ================================================================
[18:03:48]: Available apps:
- com.wndx.ARDemo (ARDemo)
- * (Xcode: Mac Wildcard AppID)
- com.wndx.SurvivAR (SurvivAR)
- * (Xcode: iOS Wildcard AppID)
- com.wndx.POIapp (POI)
- com.wndx.wimby (WIMBY Application)
[18:03:48]: Make sure to run `fastlane match` with the same user and team every time.

[!] Couldn't find bundle identifier 'org.rubymotioncommunity.foo' for the user ''

Error accessing... ?

be fastlane produce -u  -a org.rubymotioncommunity.foo --skip_itc
[βœ”] πŸš€

+----------------+------------+
| Summary for produce 2.212.1 |
+----------------+------------+
| username       | -a         |
| skip_itc       | true       |
| sku            | 1681344625 |
| platform       | ios        |
| language       | English    |
| skip_devcenter | false      |
+----------------+------------+

-------------------------------------------------------------------------------------
Please provide your Apple Developer Program account credentials
The login information you enter will be stored in your macOS Keychain
You can also pass the password using the `FASTLANE_PASSWORD` environment variable
See more information about it on GitHub: https://github.com/fastlane/fastlane/tree/master/credentials_manager
-------------------------------------------------------------------------------------
Password (for -a): *********

Looking for related GitHub issues on fastlane/fastlane...

➑️  Match receives `Access Forbidden` response
    https://github.com/fastlane/fastlane/issues/20530 [open] 12 πŸ’¬
    7 weeks ago

➑️  `Spaceship::Client.handle_two_factor` can loop indefinitely in CI environments, causing Apple Account lockouts
    https://github.com/fastlane/fastlane/issues/20707 [open] 7 πŸ’¬
    7 weeks ago

➑️  Don't ask verification code and access forbiden and apple account block
    https://github.com/fastlane/fastlane/issues/21071 [closed] 202 πŸ’¬
    6 weeks ago

and 14 more at: https://github.com/fastlane/fastlane/search?q=The%20request%20could%20not%20be%20completed%20because%3A%0A%09Access%20forbidden&type=Issues&utf8=βœ“

πŸ”—  You can ⌘ + double-click on links to open them directly in your browser.

[!] The request could not be completed because:
	Access forbidden

Add credentials manually?

be fastlane fastlane-credentials add --username XXXXXX@mac.com
[βœ”] πŸš€
Password: *********
Credential XXXXXX@mac.com:********* added to keychain.

Still no. Read all the Github issues.

Ah! is the problem that I have a Team ID, and I'm not specifying?

Nope. I just went and edited my Matchfile, specified one of my existing app identifiers, and my username:

app_identifier(["com.wndx.SurvivAR"])
username("XXXXXX@mac.com") # Your Apple Developer Portal username

and poof!


be fastlane match development
[βœ”] πŸš€
[19:54:03]: Successfully loaded '/Users/lori/Dropbox/Projects/rubymotion-community/foo/fastlane/Matchfile' πŸ“„

+----------------+-------------------------------------------+
|        Detected Values from './fastlane/Matchfile'         |
+----------------+-------------------------------------------+
| git_url        | git@github.com:wndxlori/match_certificat  |
|                | es.git                                    |
| storage_mode   | git                                       |
| type           | development                               |
| app_identifier | ["com.wndx.SurvivAR"]                     |
| username       | XXXXXX@mac.com                         |
+----------------+-------------------------------------------+


+----------------------------------------+-------------------------------------------+
|                             Summary for match 2.212.1                              |
+----------------------------------------+-------------------------------------------+
| type                                   | development                               |
| readonly                               | false                                     |
| generate_apple_certs                   | true                                      |
| skip_provisioning_profiles             | false                                     |
| app_identifier                         | ["com.wndx.SurvivAR"]                     |
| username                               | XXXXXX@mac.com                         |
| storage_mode                           | git                                       |
| git_url                                | git@github.com:wndxlori/match_certificat  |
|                                        | es.git                                    |
| git_branch                             | master                                    |
| shallow_clone                          | false                                     |
| clone_branch_directly                  | false                                     |
| skip_google_cloud_account_confirmation | false                                     |
| keychain_name                          | login.keychain                            |
| force                                  | false                                     |
| force_for_new_devices                  | 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                                     |
| verbose                                | false                                     |
+----------------------------------------+-------------------------------------------+

[19:54:03]: Cloning remote git repo...
[19:54:03]: If cloning the repo takes too long, you can use the `clone_branch_directly` option in match.
[19:54:04]: Checking out branch master...
[19:54:04]: πŸ”“  Successfully decrypted certificates repo
[19:54:04]: Verifying that the certificate and profile are still valid on the Dev Portal...
Available session is not valid any more. Continuing with normal login.
[19:54:08]: Couldn't find a valid code signing identity for development... creating one for you now

+-------------------------+-------------------------------------------+
|                      Summary for cert 2.212.1                       |
+-------------------------+-------------------------------------------+
| platform                | ios                                       |
| development             | true                                      |
| generate_apple_certs    | true                                      |
| force                   | true                                      |
| username                | XXXXXX@mac.com                         |
| keychain_path           | /Users/lori/Library/Keychains/login.keyc  |
|                         | hain-db                                   |
| skip_set_partition_list | false                                     |
+-------------------------+-------------------------------------------+

[19:54:08]: Starting login with user 'XXXXXX@mac.com'
Available session is not valid any more. Continuing with normal login.
[19:54:11]: Successfully logged in
[19:54:48]: Enter the password for /Users/lori/Library/Keychains/login.keychain-db
[19:54:48]: This passphrase will be stored in your local keychain with the name fastlane_keychain_login and used in future runs
[19:54:48]: This prompt can be avoided by specifying the 'keychain_password' option or 'MATCH_KEYCHAIN_PASSWORD' environment variable
[19:54:48]: Password for login keychain: *******
[19:54:56]: Type password for login keychain again: *******
[β ‹] Setting key partition list... (this can take a minute if there are a lot of keys instal[β ™] Setting key partition list... (this can take a minute if there are a lot of keys instal[β Ή] Setting key partition list... (this can take a minute if there are a lot of keys instal[β Έ] Setting key partition list... (this can take a minute if there are a lot of keys instal[βœ”] Setting key partition list... (this can take a minute if there are a lot of keys installed)
[19:55:00]: Successfully generated #LLLLL#LL# which was imported to the local machine.
[19:55:00]: $ security find-certificate -a -c 'Apple Worldwide Developer Relations' -p /Users/lori/Library/Keychains/login.keychain-db
[19:55:00]: β–Έ -----BEGIN CERTIFICATE-----
[19:55:00]: β–Έ -----END CERTIFICATE-----
[19:55:00]: β–Έ -----BEGIN CERTIFICATE-----
[19:55:00]: β–Έ -----END CERTIFICATE-----
[19:55:01]: Verifying the certificate is properly installed locally...
[19:55:01]: Successfully installed certificate #LLLLL#LL#

+-------------------------------------+-------------------------------------+
|                         Summary for sigh 2.212.1                          |
+-------------------------------------+-------------------------------------+
| app_identifier                      | com.wndx.SurvivAR                   |
| username                            | XXXXXX@mac.com                   |
| force                               | false                               |
| cert_id                             | #LLLLL#LL#                          |
| provisioning_name                   | match Development com.wndx.SurvivAR |
| ignore_profiles_with_different_name | true                                |
| fail_on_name_taken                  | false                               |
| include_all_certificates            | false                               |
| include_mac_in_profiles             | false                               |
| platform                            | ios                                 |
| development                         | true                                |
| adhoc                               | false                               |
| developer_id                        | false                               |
| skip_install                        | false                               |
| skip_fetch_profiles                 | false                               |
| skip_certificate_verification       | false                               |
| readonly                            | false                               |
+-------------------------------------+-------------------------------------+

[19:55:01]: Starting login with user 'XXXXXX@mac.com'
Available session is not valid any more. Continuing with normal login.
[19:55:04]: Successfully logged in
[19:55:04]: Fetching profiles...
[19:55:04]: Provisioning Profile '(MotionProvisioning) com.wndx.SurvivAR ios development' is not valid, skipping this one...
[19:55:04]: Verifying certificates...
[19:55:04]: No existing profiles found, that match the certificates you have installed locally! Creating a new provisioning profile for you
[19:55:05]: Creating new provisioning profile for 'com.wndx.SurvivAR' with name 'match Development com.wndx.SurvivAR' for 'ios' platform
[19:55:05]: $ security find-certificate -a -c 'Apple Worldwide Developer Relations' -p /Users/lori/Library/Keychains/login.keychain-db
[19:55:05]: β–Έ -----BEGIN CERTIFICATE-----
[19:55:05]: β–Έ -----END CERTIFICATE-----
[19:55:05]: β–Έ -----BEGIN CERTIFICATE-----
[19:55:05]: β–Έ -----END CERTIFICATE-----
[19:55:05]: β–Έ -----BEGIN CERTIFICATE-----
[19:55:05]: β–Έ -----END CERTIFICATE-----
[19:55:05]: β–Έ -----BEGIN CERTIFICATE-----
[19:55:05]: β–Έ -----END CERTIFICATE-----
[19:55:05]: β–Έ -----BEGIN CERTIFICATE-----
[19:55:05]: β–Έ -----END CERTIFICATE-----
[19:55:05]: β–Έ -----BEGIN CERTIFICATE-----
[19:55:05]: β–Έ -----END CERTIFICATE-----
[19:55:06]: Downloading provisioning profile...
[19:55:06]: Successfully downloaded provisioning profile...
[19:55:07]: Installing provisioning profile...
/var/folders/2n/8z_s2hs93z10ywf759n68z840000gn/T/d20230413-37028-1k3obbo/profiles/development/Development_com.wndx.SurvivAR.mobileprovision
[19:55:07]: Installing provisioning profile...
[19:55:07]: πŸ”’  Successfully encrypted certificates repo
[19:55:07]: Pushing changes to remote git repo...
[19:55:08]: Finished uploading files to Git Repo [git@github.com:wndxlori/match_certificates.git]

+---------------------+----------------------------+----------------------------+
|                        Installed Provisioning Profile                         |
+---------------------+----------------------------+----------------------------+
| Parameter           | Environment Variable       | Value                      |
+---------------------+----------------------------+----------------------------+
| App Identifier      |                            | com.wndx.SurvivAR          |
| Type                |                            | development                |
| Platform            |                            | ios                        |
| Profile UUID        | sigh_com.wndx.SurvivAR_de  | XXXXXXXX-XXXX-XXXX-XXXX-X  |
|                     | velopment                  | XXXXXXXXXXX                |
| Profile Name        | sigh_com.wndx.SurvivAR_de  | match Development          |
|                     | velopment_profile-name     | com.wndx.SurvivAR          |
| Profile Path        | sigh_com.wndx.SurvivAR_de  | /Users/lori/Library/Mobil  |
|                     | velopment_profile-path     | eDevice/Provisioning       |
|                     |                            | Profiles/XXXXXXXX-XXXX-XX  |
|                     |                            | XX-XXXX-XXXXXXXXXXXX.mobi  |
|                     |                            | leprovision                |
| Development Team ID | sigh_com.wndx.SurvivAR_de  | XXXXXXXXXX                 |
|                     | velopment_team-id          |                            |
| Certificate Name    | sigh_com.wndx.SurvivAR_de  | Apple Development: Lori    |
|                     | velopment_certificate-nam  | Olson (XXXXXXXXXX)         |
|                     | e                          |                            |
+---------------------+----------------------------+----------------------------+

[19:55:08]: All required keys, certificates and provisioning profiles are installed πŸ™Œ

Register my device with fastlane


be fastlane run register_device name:"Viserion" udid:"XXXXXXXX-XXXXXXXXXXXXXXXX"
[βœ”] πŸš€
[17:14:04]: fastlane detected a Gemfile in the current directory
[17:14:04]: However, it seems like you didn't use `bundle exec`
[17:14:04]: To launch fastlane faster, please use
[17:14:04]:
[17:14:04]: $ bundle exec fastlane run register_device name:Viserion udid:XXXXXXXX-XXXXXXXXXXXXXXXX
[17:14:04]:
[17:14:04]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
[17:14:07]: -----------------------------
[17:14:07]: --- Step: register_device ---
[17:14:07]: -----------------------------
[17:14:07]: Login to App Store Connect ()
-------------------------------------------------------------------------------------
Please provide your Apple Developer Program account credentials
The login information you enter will be stored in your macOS Keychain
You can also pass the password using the `FASTLANE_PASSWORD` environment variable
See more information about it on GitHub: https://github.com/fastlane/fastlane/tree/master/credentials_manager
-------------------------------------------------------------------------------------
Username: XXXXXX@mac.com
Available session is not valid any more. Continuing with normal login.
[17:14:23]: Login successful
[17:14:24]: Successfully registered new device
[17:14:24]: Result: XXXXXXXX-XXXXXXXXXXXXXXXX

Update my Rakefile, using the installed certificate name, and the mobile provisioning file

    app.codesign_certificate = "Apple Development: Lori Olson (XXXXXXXXXX)"
    app.provisioning_profile = "/Users/lori/Library/MobileDevice/Provisioning Profiles/9f5fbea4-be8c-4aae-9b52-ee7ae56b54c7.mobileprovision"

Run rake device and BAM! you have a development provision completed

Cackles with glee!

@wndxlori
Copy link
Author

  1. These are working notes
  2. The free account can only create ONE app identifier
  3. Some of my problems were created by the existence of expired certificates in the KeyChain.

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