最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Flutter iOS build failing due to Framework 'Toast' not found - Stack Overflow

programmeradmin1浏览0评论

I am able to build and Android output, but iOS build is failing with this error:

Error (Xcode): Framework 'Toast' not found
Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)
Encountered error while building for device.
Process finished with exit code 1

I am pretty unfamiliar with xcode and iOS development. I have tried many different changes and suggestions based on what I've found online. This includes cleaning and rebuilding, deleting iOS pods and Podfile.lock, deleting xcode derived data, deintegrating pods, I made sure Framework Search Paths includes: $(inherited), and more. I have cleaned and rebuilt after every change to make sure the changes were applied. As per an AI suggestion I tried adding pod 'Toast' to the podfile manually and I received this error instead:

Error (Xcode): Framework 'sqflite' not found
Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)
Encountered error while building for device.
Process finished with exit code 1

So it seems like the project is having trouble linking Flutter plugins correctly (they are up to date). I'm not sure what to try next. Any suggestions and help would be greatly appreciated.

Podfile

platform :ios, '13.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!

 pod 'FMDB'
  pod 'FirebaseFirestore/WithLeveldb', :git => '.git', :tag => '9.3.0'

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

end

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

pubspec.yaml

name: com.app.app
description: description

publish_to: 'none' 

version: 1.1.1+44

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  intl: ^0.19.0 # added for localization
  shared_preferences: ^2.0.6
  path: ^1.8.0
  path_provider: ^2.0.2
  provider: ^6.0.2
  sqflite: ^2.4.1
  package_info_plus: ^8.0.0 # provides access to version info
  jiffy: ^6.2.1 # added for extra date functions like daysInMonth
  animated_size_and_fade: ^5.1.1
  url_launcher: ^6.0.9
  share_plus: ^10.1.4
  excel: ^4.0.2
  google_mobile_ads: ^5.1.0
  in_app_purchase: ^3.0.2
  in_app_purchase_android: ^0.4.0+1
  in_app_review: ^2.0.10
  flutter_email_sender: ^7.0.0
  pdf: ^3.6.5
  printing: ^5.6.6
  device_info_plus: ^11.3.0
  fluttertoast: ^8.2.12
  crypto: ^3.0.1
  file_picker: ^9.0.2
  flutter_intro: ^3.0.2
  app_tracking_transparency: ^2.0.3
  home_widget: ^0.7.0+1

  # firebase
  firebase_core: ^3.2.0
  firebase_analytics: ^11.2.0
  firebase_crashlytics: ^4.0.3
  firebase_storage: ^12.1.1

  # use flutter launcher icons when updating icons
  flutter_launcher_icons: ^0.14.3
  cupertino_icons: ^1.0.3

  # Sign in
  firebase_auth: ^5.1.2
  google_sign_in: ^6.1.0
  sign_button: ^2.0.2
  sign_in_with_apple: ^6.1.1

  # UI packages
  settings_ui:  ^2.0.2

flutter_icons:
  android: "launcher_icon"
  ios: true
  remove_alpha_ios: true
  image_path: "assets/icon/icon.png"
 
flutter:
  generate: true # added for localization

  uses-material-design: true

this:
  assets:
     - assets/icon/icon.png
     - assets/

flutter_intl:
  main_locale: en_US
  enabled: true

Flutter doctor:
[✓] Flutter (Channel stable, 3.27.3, on macOS 15.3.2 24D81 darwin-arm64, locale en-CA)
• Flutter version 3.27.3 on channel stable at /Users/Desktop/SDKs/flutter
• Upstream repository .git
• Framework revision c519ee916e (7 weeks ago), 2025-01-21 10:32:23 -0800
• Engine revision e672b006cb
• Dart version 3.6.1
• DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
• Android SDK at /Users/Library/Android
• Platform android-35, build-tools 35.0.1
• Java binary at: /opt/homebrew/Cellar/openjdk@17/17.0.14/libexec/openjdk.jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment Homebrew (build 17.0.14+0)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
��
• Dart plugin can be installed from:
��
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
[✓] Connected device (4 available)
• ios • iOS 17.7 21H16
• macOS (desktop) • macos • darwin-arm64 • macOS 15.3.2 24D81 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.3.2 24D81 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 134.0.6998.89
[✓] Network resources
• All expected network resources are available.
• No issues found!

I am able to build and Android output, but iOS build is failing with this error:

Error (Xcode): Framework 'Toast' not found
Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)
Encountered error while building for device.
Process finished with exit code 1

I am pretty unfamiliar with xcode and iOS development. I have tried many different changes and suggestions based on what I've found online. This includes cleaning and rebuilding, deleting iOS pods and Podfile.lock, deleting xcode derived data, deintegrating pods, I made sure Framework Search Paths includes: $(inherited), and more. I have cleaned and rebuilt after every change to make sure the changes were applied. As per an AI suggestion I tried adding pod 'Toast' to the podfile manually and I received this error instead:

Error (Xcode): Framework 'sqflite' not found
Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)
Encountered error while building for device.
Process finished with exit code 1

So it seems like the project is having trouble linking Flutter plugins correctly (they are up to date). I'm not sure what to try next. Any suggestions and help would be greatly appreciated.

Podfile

platform :ios, '13.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!

 pod 'FMDB'
  pod 'FirebaseFirestore/WithLeveldb', :git => 'https://github/invertase/firestore-ios-sdk-frameworks.git', :tag => '9.3.0'

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

end

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

pubspec.yaml

name: com.app.app
description: description

publish_to: 'none' 

version: 1.1.1+44

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  intl: ^0.19.0 # added for localization
  shared_preferences: ^2.0.6
  path: ^1.8.0
  path_provider: ^2.0.2
  provider: ^6.0.2
  sqflite: ^2.4.1
  package_info_plus: ^8.0.0 # provides access to version info
  jiffy: ^6.2.1 # added for extra date functions like daysInMonth
  animated_size_and_fade: ^5.1.1
  url_launcher: ^6.0.9
  share_plus: ^10.1.4
  excel: ^4.0.2
  google_mobile_ads: ^5.1.0
  in_app_purchase: ^3.0.2
  in_app_purchase_android: ^0.4.0+1
  in_app_review: ^2.0.10
  flutter_email_sender: ^7.0.0
  pdf: ^3.6.5
  printing: ^5.6.6
  device_info_plus: ^11.3.0
  fluttertoast: ^8.2.12
  crypto: ^3.0.1
  file_picker: ^9.0.2
  flutter_intro: ^3.0.2
  app_tracking_transparency: ^2.0.3
  home_widget: ^0.7.0+1

  # firebase
  firebase_core: ^3.2.0
  firebase_analytics: ^11.2.0
  firebase_crashlytics: ^4.0.3
  firebase_storage: ^12.1.1

  # use flutter launcher icons when updating icons
  flutter_launcher_icons: ^0.14.3
  cupertino_icons: ^1.0.3

  # Sign in
  firebase_auth: ^5.1.2
  google_sign_in: ^6.1.0
  sign_button: ^2.0.2
  sign_in_with_apple: ^6.1.1

  # UI packages
  settings_ui:  ^2.0.2

flutter_icons:
  android: "launcher_icon"
  ios: true
  remove_alpha_ios: true
  image_path: "assets/icon/icon.png"
 
flutter:
  generate: true # added for localization

  uses-material-design: true

this:
  assets:
     - assets/icon/icon.png
     - assets/

flutter_intl:
  main_locale: en_US
  enabled: true

Flutter doctor:
[✓] Flutter (Channel stable, 3.27.3, on macOS 15.3.2 24D81 darwin-arm64, locale en-CA)
• Flutter version 3.27.3 on channel stable at /Users/Desktop/SDKs/flutter
• Upstream repository https://github/flutter/flutter.git
• Framework revision c519ee916e (7 weeks ago), 2025-01-21 10:32:23 -0800
• Engine revision e672b006cb
• Dart version 3.6.1
• DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
• Android SDK at /Users/Library/Android
• Platform android-35, build-tools 35.0.1
• Java binary at: /opt/homebrew/Cellar/openjdk@17/17.0.14/libexec/openjdk.jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment Homebrew (build 17.0.14+0)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
��https://plugins.jetbrains/plugin/9212-flutter
• Dart plugin can be installed from:
��https://plugins.jetbrains/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
[✓] Connected device (4 available)
• ios • iOS 17.7 21H16
• macOS (desktop) • macos • darwin-arm64 • macOS 15.3.2 24D81 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.3.2 24D81 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 134.0.6998.89
[✓] Network resources
• All expected network resources are available.
• No issues found!
Share Improve this question edited Mar 18 at 14:16 u2tall asked Mar 13 at 20:57 u2tallu2tall 4002 gold badges7 silver badges17 bronze badges 4
  • can you share your pubspec.yaml and podfile folder content? – Munsif Ali Commented Mar 18 at 4:40
  • You got it, just added them – u2tall Commented Mar 18 at 14:17
  • First thing to start, did you try flutter clean and then flutter pub get followed with pod install from within the ios directory? – Albert221 Commented Mar 20 at 14:21
  • Yes, I started with that, and unfortunately have done that at least a hundred times since the issue started since I wanted to make sure that whatever changes I am trying are implemented cleanly in the code – u2tall Commented Mar 20 at 17:08
Add a comment  | 

5 Answers 5

Reset to default 1

In my case, after updating XCode and the Simulator, I started encountering the error:

“Framework ‘Toast’ not found”

For me, the issue was resolved by downgrading the fluttertoast version from:

fluttertoast: ^8.2.12 → fluttertoast: 8.2.8

After changing the fluttertoast version to 8.2.8, the error disappeared, and the build was successful.

I’m not sure about sqflite, but you might want to give it a try.

plus, For me, the issue started occurring from fluttertoast version 8.2.11.

Add "pod 'Toast', '~> 4.1.1'" on Podfile

target 'Runner' do
  use_frameworks!
  use_modular_headers!
  pod 'AppsFlyerFramework'
  pod 'Toast', '~> 4.1.1'
  
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

end

then

  • flutter clean

  • flutter pub get

  • cd ios

  • pod update

  • If you get an issue, close Xcode and reopen

can you try this pod file content

# Uncomment this line to define a global platform for your project
platform :ios, '13.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!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  target 'RunnerTests' do
    inherit! :search_paths
  end
end

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

if it didn't worked delete the IOS folder and then run command flutter create -i swift --platforms ios . which will create a new Podfile and KEEP IN MIND that if you have make any changes in the ios specific folder(like native code etc) that will be gone so be careful.

you can also try this:

cd ios
pod repo update
pod install --verbose
brew upgrade cocoapods

If error persists despite downgrading fluttertoast or manually adding pods try below steps

Run

flutter clean
flutter pub get,

then in the ios folder, reset CocoaPods with

rm -rf Pods Podfile.lock
pod deintegrate
pod install

If that fails, delete the ios folder and regenerate it with

flutter create -i swift --platforms ios

then rebuild.

I finally got it working, although I can't be completely sure what the original source of the issue was.

At some point I had backed up my runner.xcworkspace by making a copy: runnercopy.xcworkspace.

After changing it's extension to runnercopy.xcworkspace.bak, it started working.

My best guess is that the duplicate workspaces were still active and causing conflicts. I made many changes throughout all of my testing, so there may have been something else I fixed in the meantime but I didn't realize was a fix because of the duplicate workspace issue. Removing the .bak extension does not seem to cause the issue again, but I'm not willing to go through many hoops to re-create it, so I'm leaving it at at that. This is my working podfile:

# Uncomment this line to define a global platform for your project
# platform :ios, '12.0' trying 13.0 to see if that fixes issue with build
platform :ios, '13.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!

 flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

end

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
发布评论

评论列表(0)

  1. 暂无评论