Flutter iOS构建失败:Framework 'Toast'未找到
iOS端Flutter项目构建失败:框架链接异常问题
Android端可正常构建输出,但iOS端构建失败,初始报错信息如下:
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
本人对Xcode和iOS开发不熟悉,已尝试以下修复方案,且每次修改后均清理重建确保生效:
- 清理并重建项目
- 删除iOS的Pods目录及Podfile.lock文件
- 删除Xcode派生数据
- 解除Pods集成后重新配置
- 确认Framework Search Paths包含
$(inherited)
按照建议手动在Podfile中添加pod 'Toast'后,出现新的报错:
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
所有Flutter插件均已更新至最新版本,目前无法确定问题根源,恳请提供解决建议。
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.com/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 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.com/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.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨https://plugins.jetbrains.com/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!
内容的提问来源于stack exchange,提问作者u2tall
相关产品推荐
相关产品推荐

