4

I am using flutter and trying to build an ipa file, I am able to run my app my device or simulator no problem, but can't build an ipa file. I am using the flutter command flutter build ipa and I get this error:

Command PhaseScriptExecution failed with a nonzero exit code

I have tried to do the following:

flutter clean
flutter pub get
cd ios
pod install
pod update

Here is my Podfile:

platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  pod 'DKImagePickerController/PhotoGallery', :git => 'https://github.com/miguelpruivo/DKImagePickerController.git'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

And here is my pubspec.yaml file:

name: myApp
description: An app for parents built by parents

version: 1.0.0+1

environment:
  sdk: ">=2.15.1 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  firebase_core: 1.12.0
  firebase_auth: 3.3.6
  cloud_firestore: 3.1.7
  firebase_messaging: 11.2.6
  firebase_database: 9.0.6
  firebase_storage: 10.2.6

  shared_preferences: 2.0.12
  json_annotation: 4.4.0
  uuid: 3.0.5
  flutter_easyloading: 3.0.3
  flutter_svg: 1.0.3
  adaptive_dialog: 1.3.0
  image_picker: 0.8.4+5
  charts_flutter: 0.12.0
  url_launcher: 6.0.12
  dart_date: 1.1.1
  carousel_slider: 4.0.0
  dots_indicator: 2.1.0
  open_mail_app: 0.4.4
  percent_indicator: 4.0.0
  audioplayers: 0.20.1
  number_picker_dialog: 0.0.1
  share_plus: 3.1.0
  flutter_tabler_icons: 1.1.1
  flutter_local_notifications: 9.4.0
  intl: 0.17.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: 1.0.0
  build_runner: 2.1.7
  json_serializable: 6.1.4

flutter_icons:
  android: "launcher_icon"
  ios: true
  remove_alpha_ios: true
  image_path: "assets/icons/logo.png"

flutter_launcher_name:
  name: "MyApp"

flutter:
  uses-material-design: true

  assets:
    - assets/images/intro/
    - assets/images/questions/
    - assets/images/badges/
    - assets/icons/
    - assets/data/
    - assets/audio/

  fonts:
    - family: Chalkboard
      fonts:
        - asset: assets/fonts/chalkboard/Daneehand Demo.otf
    - family: Poppins-Light
      fonts:
        - asset: assets/fonts/poppins/Poppins-Light.ttf
    - family: Poppins-Regular
      fonts:
        - asset: assets/fonts/poppins/Poppins-Regular.ttf
    - family: Poppins-Medium
      fonts:
        - asset: assets/fonts/poppins/Poppins-Medium.ttf
    - family: Poppins-SemiBold
      fonts:
        - asset: assets/fonts/poppins/Poppins-SemiBold.ttf
    - family: Poppins-Bold
      fonts:
        - asset: assets/fonts/poppins/Poppins-Bold.ttf

Can anyone tell me what I am doing wrong?

user979331
  • 11,039
  • 73
  • 223
  • 418
  • Did you try building iPA using Xcode? and can you please share the full error logs – Ahmed Adel Jun 16 '22 at 07:51
  • @AhmedAdel I did try building ipa using Xcode, I will post my full error – user979331 Jun 16 '22 at 14:50
  • @AhmedAdel I tried to update my question, but the error is too lengthy. but this the first thing I see `PhaseScriptExecution Run\ Script /Users/me/Library/Developer/Xcode/DerivedData/Runner-bumipejvyltkyxgswadeexbpjcwp/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-9740EEB61CF901F6004384FC.sh (in target 'Runner' from project 'Runner')` – user979331 Jun 16 '22 at 14:57
  • And here is the last thing I see `/bin/sh -c /Users/me/Library/Developer/Xcode/DerivedData/Runner-bumipejvyltkyxgswadeexbpjcwp/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-9740EEB61CF901F6004384FC.sh Failed to package /Users/me/Downloads/MyApp.` – user979331 Jun 16 '22 at 14:57
  • @user979331 do you have still the problem, or solved? – Maziar Saadatfar Jul 01 '22 at 12:44
  • Check this https://stackoverflow.com/a/75947102/6667442 – Ketan Ramani Apr 06 '23 at 07:57

7 Answers7

8

Update your SDK version from flutter upgrade version 3.0.2 to 3.0.3.

export PATH="your_path/flutter/bin:$PATH" 
flutter clean
flutter pub get
cd ios
sudo gem pod install
pod install
run the app from Android Studio IDE so that it checks all the necessary installs.
flutter build ipa --release -t lib/main.dart 

Hope it may help you.

Mukund Jogi
  • 1,329
  • 5
  • 18
2

You can check the below steps:

  1. Go to iOs Folder and delete podlock file and pods folder
  2. Go to the pod file and edit the below section that contains like as below code:
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
     end
  end
end
  1. Go to terminal and cd to iOS folder and run "pod cache clean --all" command
  2. run pod install(pod update) command

Try to Archive again with XCode IDE

Sambhav jain
  • 1,467
  • 12
  • 19
Maziar Saadatfar
  • 1,286
  • 1
  • 5
  • 11
1

After various failed attempts with Xcode, I tried flutter build ipa --release with the terminal without the use of Xcode and it build like a charm.

To upload the ipa file to App Store Connect either:

  1. Drag and drop the build/ios/ipa/*.ipa bundle into the Apple Transporter macOS app https://apps.apple.com/us/app/transporter/id1450874784

Or

  1. Run xcrun altool --upload-app --type ios -f build/ios/ipa/*.ipa --apiKey your_api_key --apiIssuer your_issuer_id. See "man altool" for details about how to authenticate with the App Store Connect API key.
alea
  • 980
  • 1
  • 13
  • 18
GeekyPS
  • 11
  • 3
0

First clear Derived data from preference and remove it from bin as well

  1. flutter clean
  2. flutter pub get
  3. cd ios
  4. pod install
  5. pod update

Try this

Hardik Mehta
  • 2,195
  • 1
  • 11
  • 14
0

I was exactly same problem,

Finally I found out after spending two days.

In my case.

Just flutter upgrade version 3.0.2 to 3.0.3

Taz
  • 1,737
  • 1
  • 15
  • 30
0

I usually have this problem when a dependency is not updated. You can try following these steps, this usually works for me:

1- Delete your Podfile.lock (I like to use the command 'rm -rf Podfile.lock' on the terminal for this)

2- Delete your Pods folder (I like to use the command 'rm -rf Pods' in the terminal for this)

3- Delete your .xcworkspace

4- Pod install

5- Clear your project into XCode> Product> Clean Build Folder

Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30
Sadhik
  • 304
  • 1
  • 6
-1

This mainly happens because of less space in your machine. Clean up some space, delete derived data and archieves of older builds

Path to derived data

~/Library/Developer/Xcode/DerivedData

Enter this in finder -> go -> go to folder

Yoy can also restart your machine to clean all temp files

Also try building it from xcode directly

Kaushik Chandru
  • 15,510
  • 2
  • 12
  • 30