Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on Building iOS locally and in pipeline #2704

Open
omarammarthefirst opened this issue Dec 18, 2024 · 11 comments
Open

Error on Building iOS locally and in pipeline #2704

omarammarthefirst opened this issue Dec 18, 2024 · 11 comments
Labels
bug Something isn't working

Comments

@omarammarthefirst
Copy link

omarammarthefirst commented Dec 18, 2024

App ID: dcadf652-7fb4-4d26-9cd3-9b4c850ac58c

Screenshot 2024-12-18 at 12 14 42 PM

Description
We have newly integrated shorebird into our system, the release on android works amazing. however on iOS attempting to build locally or in our pipeline breaks with no clear issue. we are using flutter 3.24.5.

attached below is a copy of verbose logs from local machine and from pipeline. as well as the pipeline workflow

Steps To Reproduce
locally:

  1. run fvm flutter pub get
  2. run fvm dart run build_runner build --delete-conflicting-outputs
  3. run fvm dart fvm flutter pub run intl_utils:generate
  4. run shorebird release ios --flutter-version 3.24.5 --verbose

pipeline

name: iOS Release

on:
  push:
    tags:
      - "v[0-9].[0-9]+.[0-9]+" # e.g. v1.0.0

  workflow_dispatch:

env:
  SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }}
jobs: 
 release-ios:
    runs-on: macos-latest

    name: 🍎 Release iOS

    env:

    steps:
      - name: 📚 Git Checkout
        uses: actions/checkout@v4

      - uses: subosito/flutter-action@v2
        with:
          flutter-version: "3.24.5"
          channel: "stable"
          cache: true

      - name: flutter clean
        run: flutter clean

      - name: Get dependencies
        run: flutter pub get

      - name: Build Runner
        run: dart run build_runner build --delete-conflicting-outputs

      - name: intl generation
        run: flutter pub run intl_utils:generate

      - name: 🐦 Setup Shorebird
        uses: shorebirdtech/setup-shorebird@v1
        with:
          cache: true

      - name: ✍️ Setup XCode Signing
        env:
          CERTIFICATE: ${{ secrets.IOS_BUILD_CERTIFICATE_BASE64 }}
          CERTIFICATE_PASSWORD: ${{ secrets.IOS_BUILD_CERTIFICATE_PASSWORD }}
          PROVISIONING_PROFILE: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
          KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
        run: |
          # create variables
          CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
          KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
          PP_PATH=$RUNNER_TEMP/temp.mobileprovision

          # import certificate and provisioning profile from secrets
          echo -n "$CERTIFICATE" | base64 --decode -o $CERTIFICATE_PATH
          echo -n "$PROVISIONING_PROFILE" | base64 --decode -o $PP_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 "$CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
          security list-keychain -d user -s $KEYCHAIN_PATH
          security find-identity -v

          # use uuid for the name of provisioning profile
          UUID=$(/usr/libexec/PlistBuddy -c "Print UUID" /dev/stdin <<< $(/usr/bin/security cms -D -i $PP_PATH))

          # apply provisioning profile
          mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
          cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles/$UUID.mobileprovision

      - name: 🚀 Shorebird Release
        uses: shorebirdtech/shorebird-release@v0
        with:
          platform: ios
          args: "--verbose --flutter-version=3.24.5"

      - name: 🧹 Clean Up
        if: ${{ always() }}
        run: |
          PP_PATH=$RUNNER_TEMP/temp.mobileprovision
          security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
          rm $RUNNER_TEMP/temp.mobileprovision

      - name: 📦 Upload Artifact
        uses: actions/upload-artifact@v4
        with:
          name: ios-release
          path: build/ios/ipa/app-release.ipa

      - name: Clean up keychain and provisioning profile
        if: ${{ always() }}
        run: |
          security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
          rm ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.mobileprovision

Expected Behavior

Build to be done successfully
Screenshots

  1. local build results
IO  : Writing 1002116 characters to text file /Users/omarammar/.pub-cache/log/pub_log.txt.
[   +1 ms] Encountered error while archiving for device.
[        ] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      _BuildIOSSubCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:722:7)
           <asynchronous suspension>
           #2      BuildIOSArchiveCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:427:50)
           <asynchronous suspension>
           #3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1408:27)
           <asynchronous suspension>
           #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #5      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           #6      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:420:9)
           <asynchronous suspension>
           #7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #8      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:364:5)
           <asynchronous suspension>
           #9      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:130:9)
           <asynchronous suspension>
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #11     main (package:flutter_tools/executable.dart:93:3)
           <asynchronous suspension>

  1. pipeline build results
 Writing 1000543 characters to text file /Users/runner/.pub-cache/log/pub_log.txt.
[   +2 ms] Encountered error while archiving for device.
[        ] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      _BuildIOSSubCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:722:7)
           <asynchronous suspension>
           #2      BuildIOSArchiveCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:427:50)
           <asynchronous suspension>
           #3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1408:27)
           <asynchronous suspension>
           #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)

           <asynchronous suspension>
           #5      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           #6      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:420:9)
           <asynchronous suspension>
           #7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #8      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:364:5)
           <asynchronous suspension>
           #9      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:130:9)
           <asynchronous suspension>
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
           <asynchronous suspension>
           #11     main (package:flutter_tools/executable.dart:93:3)
           <asynchronous suspension>

 (822.1s)
[Process.run] git symbolic-ref HEAD (in /Users/runner/.shorebird/bin/cache)
Exited with code 0

stdout:
refs/heads/stable

[Process.run] git rev-parse --verify HEAD (in /Users/runner/.shorebird/bin/cache)
Exited with code 0

apologies for the text files but the output is very long
pipeline_build_logs.txt
local_build_logs.txt

@omarammarthefirst omarammarthefirst added the bug Something isn't working label Dec 18, 2024
@omarammarthefirst
Copy link
Author

i have checked the following issues and following the steps in them didn't resolve the problem
#2591
#2590

@bryanoltman
Copy link
Contributor

I think we're probably not surfacing as much error output as we should be. If you run:

FLUTTER_STORAGE_BASE_URL=https://download.shorebird.dev /Users/omarammar/.shorebird/bin/cache/flutter/3faf56aafaec13a0ba54445574e8e81f3235070c/bin/flutter build ipa --release --verbose

do you see anything more helpful there?

@bryanoltman
Copy link
Contributor

(filed #2705)

@omarammarthefirst
Copy link
Author

Hey @bryanoltman , This is the error thats surfacing now, I'm attaching the logs again for you to see if I missed anything

               Unhandled exception:
               Null check operator used on a null value
               #0      Context.embedFlutterFrameworks (file:///Users/omarammar/.shorebird/bin/cache/flutter/3faf56aafaec13a0ba54445574e8e81f3235070c/packages/flutter_tools/bin/xcode_backend.dart:237:68)
               #1      Context.run (file:///Users/omarammar/.shorebird/bin/cache/flutter/3faf56aafaec13a0ba54445574e8e81f3235070c/packages/flutter_tools/bin/xcode_backend.dart:61:9)
               #2      main (file:///Users/omarammar/.shorebird/bin/cache/flutter/3faf56aafaec13a0ba54445574e8e81f3235070c/packages/flutter_tools/bin/xcode_backend.dart:17:5)
               #3      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:33)
               #4      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
               Command PhaseScriptExecution failed with a nonzero exit code

it looks like the issue is in the shorebird flutter package, for your reference, when archieving from xcode the build is done successfully

logs.txt

@eseidel eseidel added this to 1.1 Dec 20, 2024
@eseidel eseidel moved this to Todo in 1.1 Dec 20, 2024
@eseidel
Copy link
Contributor

eseidel commented Dec 20, 2024

Shorebird will be out for next week (US holidays). So we'd love to help, but are most likely to get back to you in a week or so. Thanks for reporting.

@bryanoltman
Copy link
Contributor

We also improved our iOS error reporting in our 1.5.4 release, so trying the failing command again might give you more insights into what the issue is.

@omarammarthefirst
Copy link
Author

omarammarthefirst commented Jan 2, 2025

Hey Guys, As suggested by you I have updated the shorebird to the newer release, however no new bugs ahve shown up, I have attached the logs below. @eseidel @bryanoltman

logs.txt

@eseidel
Copy link
Contributor

eseidel commented Jan 2, 2025

Hey Guys, As suggested by you I have updated the shorebird to the newer release, however no new bugs ahve shown up, I have attached the logs below. @eseidel @bryanoltman

logs.txt

PhaseScriptExecution Thin\ Binary /Users/omarammar/Library/Developer/Xcode/DerivedData/Runner-cwupfmrpqdhpfleenkbozbodpulm/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-3B06AD1E1E4923F5004D2608.sh (in target 'Runner' from project 'Runner')
                   cd /Users/omarammar/waj/ios
                   export ACTION\=install
...
                   export variant\=normal
                   /bin/sh -c /Users/omarammar/Library/Developer/Xcode/DerivedData/Runner-cwupfmrpqdhpfleenkbozbodpulm/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-3B06AD1E1E4923F5004D2608.sh
               Unhandled exception:
               Null check operator used on a null value
               #0      Context.embedFlutterFrameworks (file:///Users/omarammar/.shorebird/bin/cache/flutter/3faf56aafaec13a0ba54445574e8e81f3235070c/packages/flutter_tools/bin/xcode_backend.dart:237:68)
               #1      Context.run (file:///Users/omarammar/.shorebird/bin/cache/flutter/3faf56aafaec13a0ba54445574e8e81f3235070c/packages/flutter_tools/bin/xcode_backend.dart:61:9)
               #2      main (file:///Users/omarammar/.shorebird/bin/cache/flutter/3faf56aafaec13a0ba54445574e8e81f3235070c/packages/flutter_tools/bin/xcode_backend.dart:17:5)
               #3      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:33)
               #4      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
               Command PhaseScriptExecution failed with a nonzero exit code

Looks like a crash in the Flutter tool. Unclear if it's caused by shorebird or not.

@eseidel
Copy link
Contributor

eseidel commented Jan 2, 2025

@omarammarthefirst
Copy link
Author

omarammarthefirst commented Jan 3, 2025

@eseidel Is there something specific I need to do to have it set? , considering build succeeds when I use flutter build ipa and xcode archieve utility

@eseidel
Copy link
Contributor

eseidel commented Jan 3, 2025

@eseidel Is there something specific I need to do to have it set? , considering build succeeds when I use flutter build ipa and xcode archive utility

No, you shouldn't have to set anything.

Maybe flutter/flutter#140845 or https://stackoverflow.com/questions/77259439/my-xcode-backend-dart-file-has-errors-when-trying-to-run-my-application have an answer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

3 participants