3

I started using fastLane and match for codesigning on jenkins. match is able to successfully create the certificates and provisioning profile. The build_app step however fails since the pbxproj file is setting the CODE_SIGN_STYLE to Automatic. I want to achieve the build without modifying the pbxproj file since the devs use automatic signing.

FastFile

        lane :upload_debug_test_flight do
          setup_jenkins
          match
          build_app(scheme: "MyWork Dev", clean: true, export_method: "app-store")
          upload_to_testflight(.....)
        end

Match file:

    git_url("git@github.mywork/cert_repo.git")
    storage_mode("git")
    type("appstore")
    api_key_path("./test.json")
    app_identifier(["com.mywork.mywork-test"])
    username("developer@mywork.com")

In our project.pbxproj we have

    CODE_SIGN_IDENTITY = "Apple Development";
    CODE_SIGN_STYLE = Automatic;
    PROVISIONING_PROFILE_SPECIFIER= ''

Also tried the following, but still gym/build_app is not picking the match env variables:

            build_app(
                skip_profile_detection: true,
                export_method: "app-store",
                export_options:{
                    signingStyle: "manual",
                    provisioningProfiles:{
                        "com.mywork.mywork-test": "match AppStore com.mywork.mywork-test"
                    }
                }
            )
Yagna
  • 423
  • 1
  • 5
  • 15

1 Answers1

3

Gym (build_app) uses the provisioning profile mapping defined by Match for archiving (export_options), but not for building the app (these are two different steps).

Thus, you need to either configure your Xcode project to use specific profiles, or update the PROVISIONING_PROFILE_SPECIFIER value before calling build_app.

If developers only use the Debug configuration, you can specify different settings between Debug and Release. This way, you can keep the Automatic option for the Debug configuration and specify the code signing identity and profile manually for the Release configuration.

If you don't want to touch your Xcode project at all and define everything dynamically from fastlane, you can use the update_code_signing_settings action to use the provisioning profile managed by Match:

match(...)
profile_mapping = Actions.lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]
update_code_signing_settings(
    use_automatic_signing: false,
    path: "path/to/your/project.xcodeproj",
    profile_name: profile_mapping['app_identifier'] # app_identifier could be an environment variable: ENV['APP_ID']
)
build_app(...)

Another solution is to pass the PROVISIONING_PROFILE_SPECIFIER variable to the xcargs option. Note that it will update the value in all your targets, so it may not work if you have an app extension with a different profile for example.

build_app(
    ...
    xcargs: "PROVISIONING_PROFILE_SPECIFIER='profile_name'"
)
Nicolas
  • 151
  • 5
  • Thanks a lot, it really helped. This is also discussed here: https://github.com/fastlane/fastlane/issues/20165 – lakim Dec 20 '22 at 10:54
  • If my project has multiple bundle_ids, for example containing widget, do I iterate over the `bundle_id` and execute the `update_code_signing_settings` method with each `bundle_id`? – Rakuyo Dec 26 '22 at 01:21
  • @Rakuyo I haven't tested it myself, but I would indeed execute the action for specific targets based on the Match mapping. – Nicolas Feb 12 '23 at 19:40