Search code examples
iosflutterxcodeworkflow

Xcode workflow returning error when using Flutter command


I have created a workflow with Xcode Cloud to compile (archive) and release my app to TestFlight when a new commit is pushed on master branch. I created the workflow on Xcode, I gave permissions to the repo on Xcode, I added ci_post_clone.sh script as Flutter documentation suggests, and everything was working fine until today. When I pushed a new feature on origin/master the workflow started as expected but then it was stopped by an error on the ci_post_clone.sh script:

fatal: Not a valid object name origin/master Command exited with non-zero exit-code: 128

This is what I have on the script that was working fine until today:

#!/bin/sh

set -e

cd $CI_PRIMARY_REPOSITORY_PATH # change working directory to the root of your cloned repo.

echo "Installing Flutter using git"
git clone https://github.com/flutter/flutter.git --depth 1 -b stable $HOME/flutter
export PATH="$PATH:$HOME/flutter/bin"

echo "Flutter artifacts"
flutter precache --ios

... more commands here.....

It fails when trying to execute the first flutter command. I tried to change the command using flutter clean, commenting this command and trying the next one, but same result.

I tried to clean my project on local and execute it again, everything seems fine.

I'm using last Xcode release version 16.2, last macOS release version Sequoia 15.3 on the workflow and last stable Flutter version 3.29.


Solution

  • I had this exact issue today. I solved it with curl and unzip.

    Replace these lines

    echo "Installing Flutter using git"
    git clone https://github.com/flutter/flutter.git --depth 1 -b stable $HOME/flutter
    

    with these:

    # Install Flutter using curl.
    curl -sLO "https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_3.29.0-stable.zip"
    unzip -qq flutter_macos_3.29.0-stable.zip -d $HOME