Search code examples
iosflutterxcodecocoapods

unable to spawn process '/bin/sh' (Argument list too long) (in target 'Runner' from project 'Runner')


I have integrated Firebase into my project to utilize Crashlytics. While the application runs smoothly using Visual Studio Code, I encountered issues when using Xcode. ** Flutter Version: 3.13.4 **

PhaseScriptExecution [CP]\ Check\ Pods\ Manifest.lock /Users/meghapradeetha/Library/Developer/Xcode/DerivedData/Runner-eujtueznukosgeaurmvdxxxxvzqf/Build/Intermediates.noindex/Runner.build/Debug-uat-iphonesimulator/Runner.build/Script-CF008D9BDBCCC338375EC5F7.sh (in target 'Runner' from project 'Runner')
    cd /Users/meghapradeetha/GitHub/MobileApp/ios
    /bin/sh -c /Users/meghapradeetha/Library/Developer/Xcode/DerivedData/Runner-eujtueznukosgeaurmvdxxxxvzqf/Build/Intermediates.noindex/Runner.build/Debug-uat-iphonesimulator/Runner.build/Script-CF008D9BDBCCC338375EC5F7.sh

error: unable to spawn process '/bin/sh' (Argument list too long) (in target 'Runner' from project 'Runner')

Issue screenshot

I've followed the guidance provided in unable to spawn process https://github.com/flutter/flutter/issues/4862 and the solution from https://stackoverflow.com/questions/53226087/error-unable-to-spawn-process-argument-list-too-long-in-xcode-build but unfortunately, none of these solutions resolved my issue. but unfortunately, none of these solutions resolved my issue.

Debug.xcconfig :

#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug-dev.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug-qa.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug-uat.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug-prod.xcconfig"
#include "Generated.xcconfig"

Release.xcconfig :

#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release-dev.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release-qa.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release-uat.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release-prod.xcconfig"
#include "Generated.xcconfig"

Podfile

# Uncomment this line to define a global platform for your project
# platform :ios, '14.0'

# Disable CocoaPods analytics to improve build latency
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

# Define the project and configurations
project 'Runner', {
  'Debug' => :debug,
  'Debug-dev' => :debug,
  'Debug-qa' => :debug,
  'Debug-uat' => :debug,
  'Debug-prod' => :release,
  'Profile' => :release,
  'Profile-dev' => :release,
  'Profile-qa' => :debug,
  'Profile-uat' => :debug,
  'Profile-prod' => :release,
  'Release' => :release,
  'Release-dev' => :release,
  'Release-qa' => :release,
  'Release-uat' => :release,
  'Release-prod' => :release,
}

# Define the path to Flutter
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

# Include Flutter pod helper
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

# Set up the target for 'Runner'
target 'Runner' do
  use_frameworks!
  
  # Add the Firebase Crashlytics pod
  pod 'Firebase/Crashlytics'
  
  # Install Flutter pods
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

# Post-installation configurations
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      # Define preprocessor definitions for Dart Permissions
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        '$(inherited)',
        # Dart: PermissionGroup.camera
        'PERMISSION_CAMERA=1',
        'PERMISSION_LOCATION=1',
      ]
      
      # Apply additional Flutter build settings
      flutter_additional_ios_build_settings(target)
    end
  end
end

Pubspec.yaml pubspec.yaml screenshot


Solution

  • Ok: So go to your Xcode then select File at the top and move to Workspace setting. A pop up will appear for you to update your workspace. If you have an updated Xcode go to advanced option and select legacy and press done.

    Happy Coding :)