we are using Flutter to build our iOS app using Github Actions. Build is done with Melos since we are using monorepo. We have no problem building our app on local machines, but in Github Actions there is a problem with profiles. I tried many ways of configuring it but everything fails. Apple configuration:

  1. We have Apple Distribution Certificate which we import in Github Actions from secrets
  2. We have "App store" type provisioning profile

Using configuration above in xcode everything works fine. This is how we build our app:

melos exec --scope="app" -- flutter build ipa --obfuscate --split-debug-info=app/build/app/outputs/symbols --export-options-plist=$PWD/app/ExportOptions.plist

Our exportoptions look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>destination</key>
    <string>export</string>
    <key>manageAppVersionAndBuildNumber</key>
    <true/>
    <key>method</key>
    <string>app-store</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>REDACTED</key>
        <string>REDACTED</string>
    </dict>
    <key>signingCertificate</key>
    <string>Apple Distribution</string>
    <key>signingStyle</key>
    <string>manual</string>
    <key>stripSwiftSymbols</key>
    <true/>
    <key>teamID</key>
    <string>REDACTED</string>
    <key>uploadSymbols</key>
    <true/>
</dict>
</plist>

And this is a snippet of Github Actions Workflow settings environment variables, profiles etc.:

        env:
          P12_DISTRIBUTION_CERTIFICATE_BASE64: "${{ secrets.P12_BASE64 }}"
          P12_DISTRIBUTION_CERTIFICATE_PASSWORD: "${{ secrets.P12_PASSWORD }}"
          DISTRIBUTION_PROVISIONING_PROFILE_BASE64: "${{ secrets.PROVISIONING_PROFILE_BASE64 }}"
          KEYCHAIN_PASSWORD: "${{ secrets.RUNNER_LOCAL_KEYCHAIN_PASSWORD }}"
          EXPORT_OPTIONS_BASE64: "${{ secrets.EXPORT_OPTIONS_BASE64 }}"
        run: |
          # create variables
          CERTIFICATE_PATH=$RUNNER_TEMP/distribution_certificate.p12
          PROVISIONING_PROFILE_PATH=$RUNNER_TEMP/distribution.mobileprovision
          KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
          EXPORT_OPTIONS_PATH="${{ github.workspace }}/apps/messenger/ExportOptions.plist"

          # import certificate, provisioning profile and export options from secrets
          echo -n "$P12_DISTRIBUTION_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
          echo -n "$DISTRIBUTION_PROVISIONING_PROFILE_BASE64" | base64 --decode -o $PROVISIONING_PROFILE_PATH
          echo -n "$EXPORT_OPTIONS_BASE64" | base64 --decode -o $EXPORT_OPTIONS_PATH

          # create temporary keychain
          security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
          security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
          security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH

          # import certificate to keychain
          security import $CERTIFICATE_PATH -P "$P12_DISTRIBUTION_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
          security list-keychain -d user -s $KEYCHAIN_PATH


          # apply provisioning profile
          mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
          cp $PROVISIONING_PROFILE_PATH ~/Library/MobileDevice/Provisioning\ Profiles

I also tried to create App Development profile and attach it to github actions but doesn't seem to work. On my local machine the Apple Configuration that I've provided is identical as in Github. I'm pretty new to mobile apps so any help will be amazing.

0

There are 0 best solutions below