ionic-frameworkfastlanexcodebuildfastlane-match

Build Ionic app with fastlane: export archive failed


I try to build my Ionic 8 app (Cordova) with fastlane. I created a Fastfile which calls match first and then uses the ionic plugin to build the app.

Fastfile:

platform :ios do
  desc "Build Release"
  lane :build_release do
    match(type: "appstore", app_identifier: "de.myapp", 
          username: "me@myapp.de", team_id: "<my team ID>", 
          api_key_path: "<path>/AppStoreKey.json", platform: "ios",
          git_url: "git@bitbucket.org:myapp/fastlane_match.git", 
          git_private_key: "~ralf/.ssh/id_rsa", git_branch: "myapp",  
          generate_apple_certs: false, output_path: "/Users/ralf/CertsProfiles/myapp")

    update_code_signing_settings(use_automatic_signing: false, profile_name: "match AppStore de.myapp", 
                                 team_id: "<my team ID>", code_sign_identity: "iPhone Distribution", 
                                 path: "/Users/ralf/myAppBuild/platforms/ios/myapp.xcodeproj")

    ionic(platform: 'ios', prod: true, release: true, team_id: "<my team ID>")
  end
end

Match creates the certificates and pushes them to the git repo, to the developer portal and to the /Library/MobileDevice/Provisioning Profiles directory.

The build works fine if there are no existing certs and profiles at any of the above places. But when I call the the build lane for a second time, the build step fails with the error:

exportArchive "myapp.app" requires a provisioning profile with the Push Notifications feature.

** EXPORT FAILED **

As a workaround I call match_nuke before the build_release lane to remove every certificate and profile. Then the build succeeds again, but if I understood the docs correctly thats not the purpose of match.

I found some older posts suggesting to specify the provisioning profile in exportOptions.plist, but there is no parameter for the ionic plugin for that (as it is for build_app).

Any ideas what's wrong with my build lane? My understanding is that I should be able to call that build lane again and again without errors. And if match detects an expired profile it will generate a new one and everything will continue working.

Thanks


Solution

  • I found a solution, according to this post.

    I created a build config file (build.json):

    {
      "ios": {
        "debug": {
          "codeSignIdentity": "iPhone Development",
          "provisioningProfile": "DEV_PROFILE_UUID",
          "developmentTeam": "TEAM_ID",
          "packageType": "development"
        },
        "release": {
          "codeSignIdentity": "iPhone Distribution",
          "provisioningProfile": "DIST_PROFILE_UUID",
          "developmentTeam": "TEAM_ID",
          "packageType": "app-store"
        }
      }
    }
    

    And in my Fastfile I specify this file to the build parameter cordova_build_config_file:

    ionic(platform: 'ios', prod: true, release: true, team_id: "TEAM_ID", 
          cordova_build_config_file: 'build-ios.json')
    

    With this solution I am able to build the app multiple times successfully without calling match_nuke.