Edgar J.
Edgar J.

Reputation: 172

Flutter Xcode Cloud error There is no XCFramework found

I'm having trouble getting my Flutter app to build using Xcode Cloud. I keep encountering an error and have tried various solutions, but nothing seems to work. Has anyone experienced this issue or know how to resolve it?

Note: I also tried the CI script from flutters website

Error: There is no XCFramework found at '/Volumes/flutter/bin/cache/artifacts/engine/ios/Flutter.xcframework'.

ci_post_clone.sh file

#!/bin/sh

# Fail this script if any subcommand fails.
set -e

# Log function to capture errors
log_error() {
    echo "====> ERROR during: $1"
    echo "====> Exit Code: $2"
    exit $2
}

# Debug: Print the current working directory and PATH
echo "====> Current working directory: $(pwd)"
echo "====> PATH: $PATH"

# Assuming the current directory is the root of your cloned repo.
# Debug: List the contents of the current directory
ls -la

# Install Flutter using git. Adjust this as necessary for Xcode Cloud.
echo "====> Installing Flutter..."
git clone https://github.com/flutter/flutter.git --depth 1 -b stable $HOME/flutter
export PATH="$PATH:$HOME/flutter/bin"

# Check if Flutter was installed successfully
flutter --version || log_error "flutter installation" $?

# Install Flutter artifacts for iOS
echo "====> Precaching Flutter for iOS..."
flutter precache --ios || log_error "flutter precache --ios" $?

# Install Flutter dependencies
echo "====> Installing Flutter dependencies..."
flutter pub get || log_error "flutter pub get" $?

# Install CocoaPods using Homebrew
echo "====> Installing CocoaPods..."
HOMEBREW_NO_AUTO_UPDATE=1 brew install cocoapods || log_error "brew install cocoapods" $?

# Debug: Check if CocoaPods is available
if ! command -v pod &> /dev/null; then
    log_error "command -v pod" 127
    echo "====> Error: CocoaPods could not be found."
    exit 1
else
    echo "====> CocoaPods found."
fi

# Navigate to the Flutter project root directory
cd "$(git rev-parse --show-toplevel)" || log_error "git rev-parse --show-toplevel" $?

# Install CocoaPods dependencies
echo "====> Installing CocoaPods dependencies..."
cd ios && pod install || log_error "pod install" $?

echo "====> CocoaPods dependencies installed successfully."

# Check if Flutter.xcframework exists
echo "====> Checking if Flutter.xcframework exists..."
if [ ! -d "$HOME/flutter/bin/cache/artifacts/engine/ios/Flutter.xcframework" ]; then
    echo "====> Error: Flutter.xcframework not found!"
    log_error "Flutter.xcframework check" 1
else
    echo "====> Flutter.xcframework found."
fi

# Run Xcode build command
echo "====> Starting Xcode build..."

xcodebuild build -workspace ios/Runner.xcworkspace \
                 -scheme Runner \
                 -destination 'generic/platform=iOS' \
                 -derivedDataPath build/ \
                 -resultBundleVersion 3 \
                 -resultBundlePath resultbundle.xcresult \
                 -verbose | tee build_logs.log

if [ $? -ne 0 ]; then
    echo "====> Error: Xcode build failed."
    exit 1
else
    echo "====> Xcode build succeeded."
fi

# Debug: Print success message
echo "====> ci_post_clone.sh script completed successfully."

Upvotes: 1

Views: 269

Answers (1)

Sem Rus
Sem Rus

Reputation: 1

Had the same problem. I just added the missing folder from another version of flutter and it worked.

Upvotes: 0

Related Questions