9.9 C
New York
Wednesday, November 13, 2024

ios – Importing to TestFlight utilizing Fastlane concern


In continuation to this query
I hold getting the under error when making an attempt to add to TestFlight: (please naked in thoughts that the bottom line is certainly right)

[08:17:35]: Referred to as from Fastfile at line 30
[08:17:35]: ```
[08:17:35]:     28: 
[08:17:35]:     29:     # Add the construct to TestFlight
[08:17:35]:  => 30:     pilot( api_key_path: "fastlane/api.json" )
[08:17:35]:     31:   finish
[08:17:35]:     32: finish
[08:17:35]: ```
[08:17:35]: Authentication credentials are lacking or invalid. - Present a correctly configured and signed bearer token, and make it possible for it has not expired. Study extra about Producing Tokens for API Requests 

my json format is like so (naked in thoughts the a number of n used for every line within the non-public key):

{
  "key_id": "my_key_id",
  "issuer_id": "my_issuer_id",
  "key": "-----BEGIN PRIVATE KEY-----nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHknlhdlYdLunAgEGCCqGSM49AwEHBHknlhdlYdLunAgEGCCqGSM49AwEHBHknlhdlYdLun-----END PRIVATE KEY-----",
  "length": 1200,
  "in_house": false
}

and I present the above api.json like so in fastfile:

pilot( api_key_path: "fastlane/api.json" )

Workflow yml file:

title: iOS Construct and Add to TestFlight

on:
  workflow_dispatch:

jobs:
  build-ios:
    runs-on: macos-latest

    steps:
      - title: Checkout code
        makes use of: actions/checkout@v4

      - title: Arrange Ruby
        makes use of: ruby/setup-ruby@v1
        with:
          ruby-version: '3.3'

      # Set up Bundler and CocoaPods
      - title: Set up Bundler and CocoaPods
        run: |
          gem set up bundler
          sudo gem set up cocoapods

      - title: Set up Node.js dependencies
        run: npm set up

      - title: Navigate to iOS listing, clear Pods, and take away Podfile.lock
        run: |
          cd ios
          pod deintegrate
          rm -rf Podfile.lock
          npx pod-install

      - title: Set up Fastlane dependencies
        run: |
          cd ios
          bundle set up
         
      - title: Decode and arrange iOS certificates
        run: |
          echo "${{ secrets and techniques.IOS_DISTRIBUTION_CREDENTIALS }}" | base64 --decode > ios_distribution.p12
          echo "${{ secrets and techniques.PROVISIONING_PROFILE }}" | base64 --decode > provisioning.mobileprovision
        shell: bash

      - title: Import certificates to keychain
        run: |
          safety create-keychain -p "" construct.keychain
          safety import ios_distribution.p12 -k construct.keychain -P "${{ secrets and techniques.P12_PASSWORD }}" -T /usr/bin/codesign
          safety set-keychain-settings construct.keychain
          safety unlock-keychain -p "" construct.keychain
          safety set-key-partition-list -S apple-tool:,apple: -s -k "" construct.keychain
          safety list-keychains -d consumer -s construct.keychain $(safety list-keychains -d consumer | tr -d '"')
          safety list-keychains -s construct.keychain
        shell: bash

      - title: Set provisioning profile
        run: |
          mkdir -p ~/Library/MobileDevice/Provisioning Profiles
          cp provisioning.mobileprovision ~/Library/MobileDevice/Provisioning Profiles/
        shell: bash
      
      - title: Construct and add to TestFlight
        run: |
          cd ios
          bundle exec fastlane beta

Fastfile:

default_platform(:ios)

platform :ios do
  desc "Push a brand new beta construct to TestFlight"
  lane :beta do
    # Increment construct quantity mechanically
    increment_build_number(
      xcodeproj: "someapp.xcodeproj"
    )

    # Construct the app utilizing your particular workspace and scheme
    build_app(
      workspace: "someapp.xcworkspace",
      scheme: "someappQA",
      export_method: "app-store",
      export_options: {
        provisioningProfiles: {
          "com.someapp.app.qa" => "com.someapp.app.qa"
        }
      }
    )  

    # Add the construct to TestFlight
    upload_to_testflight( api_key_path: "fastlane/api.json" )
  finish
finish

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles