flutter 启动 ios 项目失败 n 次,求大神帮忙 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
avenhen
V2EX    Flutter

flutter 启动 ios 项目失败 n 次,求大神帮忙

  •  
  •   avenhen 352 天前 2023 次点击
    这是一个创建于 352 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我已经被这个破报错折腾了俩晚上了,google 上各种方法都尝试了,就是绕不过去。求大神解答。

    ## 启动报错内容
    ```txt
    Failed to build iOS app
    Error output from Xcode build:

    --- xcodebuild: WARNING: Using the first of multiple matching destinations:
    { platform:iOS Simulator, id:16524F90-A508-4F0D-9091-F0CF7A5A6686, OS:17.5, name:iPhone 14 Pro }
    { platform:iOS Simulator, id:16524F90-A508-4F0D-9091-F0CF7A5A6686, OS:17.5, name:iPhone 14 Pro }
    ** BUILD FAILED **


    Xcode's output:

    Writing result bundle at path:
    /var/folders/fq/2051nhxx5rs4svtvnsd_hvjr0000gn/T/flutter_tools.mEnGAj/flutter_ios_build_temp_dirENnESM/temporary_xcresult_bundle

    /Users/cloud_prg/.pub-cache/hosted/pub.flutter-io.cn/wakelock-0.5.3+3/ios/Classes/messages.m:4:9: fatal error: 'Flutter/Flutter.h' file not found
    #import <Flutter/Flutter.h>
    ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    In file included from /Users/cloud_prg/.pub-cache/hosted/pub.flutter-io.cn/wakelock-0.5.3+3/ios/Classes/WakelockPlugin.m:1:
    /Users/cloud_prg/.pub-cache/hosted/pub.flutter-io.cn/wakelock-0.5.3+3/ios/Classes/WakelockPlugin.h:1:9: fatal error: 'Flutter/Flutter.h' file not
    found
    #import <Flutter/Flutter.h>
    ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    /Users/cloud_prg/.pub-cache/hosted/pub.flutter-io.cn/video_player-2.1.15/ios/Classes/messages.m:8:9: fatal error: 'Flutter/Flutter.h' file not
    found
    #import <Flutter/Flutter.h>
    ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    Command SwiftEmitModule failed with a nonzero exit code
    /Users/cloud_prg/Documents/project/github/FLUTTER/flutter_bolg_manage/ios/Runner.xcodeproj: warning: The iOS Simulator deployment target
    'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.5.99. (in target 'Runner' from
    project 'Runner')
    warning: Run script build phase 'Thin Binary' will be run during every build because it does not specify any outputs. To address this warning,
    either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the
    script phase. (in target 'Runner' from project 'Runner')
    warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning,
    either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the
    script phase. (in target 'Runner' from project 'Runner')

    Lexical or Preprocessor Issue (Xcode): 'Flutter/Flutter.h' file not found
    /Users/cloud_prg/.pub-cache/hosted/pub.flutter-io.cn/wakelock-0.5.3+3/ios/Classes/messages.m:3:8


    Lexical or Preprocessor Issue (Xcode): 'Flutter/Flutter.h' file not found
    /Users/cloud_prg/.pub-cache/hosted/pub.flutter-io.cn/wakelock-0.5.3+3/ios/Classes/WakelockPlugin.h:0:8


    Lexical or Preprocessor Issue (Xcode): 'Flutter/Flutter.h' file not found
    /Users/cloud_prg/.pub-cache/hosted/pub.flutter-io.cn/video_player-2.1.15/ios/Classes/messages.m:7:8


    Uncategorized (Xcode): Command SwiftEmitModule failed with a nonzero exit code


    Could not build the application for the simulator.
    Error launching application on iPhone 14 Pro.
    ```

    ## podFile 内容
    ```Podfile
    # Uncomment this line to define a global platform for your project
    platform :ios, "14.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__))
    end

    post_install do |installer|
    installer.pods_project.targets.each do |target|
    flutter_additional_macos_build_settings(target)
    target.build_configurations.each do |config|
    config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] = "14.0"
    end
    end
    end

    ```
    3 条回复    2025-01-09 16:43:40 +08:00
    rrubick
        1
    rrubick  
       352 天前 via iPhone
    可能的原因
    1. cache 问题
    2. flutter 和 xcode 版本问题
    3. 第三方库不支持模拟器架构

    解决方案
    1. flutter clean 然后 flutter pub get
    2. 进入 ios 文件夹 删掉 pods
    3. 直接用 xcode 跑真机,没问题了再看其它 ide 和模拟器是否能运行
    hwb
        2
    hwb  
       352 天前
    @magic3584 经典三板斧
    ccw1234
        3
    ccw1234  
       352 天前
    要是上面 3 板斧解决不了问题,可以试一下下面的方案
    1. Remove ios/Flutter/Flutter.podspec: rm ios/Flutter/Flutter.podspec
    2. flutter clean
    3. Run your app again.
    https://www.cnblogs.com/qqcc1388/p/14686339.html
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2608 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 32ms UTC 11:36 PVG 19:36 LAX 03:36 JFK 06:36
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86