要开发适用于iOS的Flutter应用,您需要一台装有Xcode的Mac。Xcode 11.4更改了框架的链接和嵌入方式,在iOS设备和模拟器之间切换时,您可能会看到以下错误:
    content_copy

    1. Building for iOS, but the linked and embedded framework 'App.framework' was built for iOS Simulator.

    要么
    content_copy

    1. Building for iOS Simulator, but the linked and embedded framework 'App.framework' was built for iOS.

    Flutter v1.15.3及更高版本会自动迁移Xcode项目。
    如果需要手动升级项目,请使用以下步骤:

    1. 在Flutter应用程序目录中,ios/Runner.xcworkspace以Xcode 打开。
    2. 在“ 导航器”窗格中,找到 Flutter组,然后删除App.frameworkFlutter.framework
      image.png
    3. 在Runner目标构建设置中,选择“ 构建阶段”>“使用库链接二进制文件”进行 确认App.frameworkFlutter.framework 并且不再存在。还要在“ 构建阶段”>“嵌入框架”中进行确认。
      Flutter项目报错 - Building for iOS, but the linked and embedded framework 'App.framework'的处理 - 图2
    4. 如下更改Runner目标构建设置 Build Phases> Thin Binary脚本:
      content_copy

      1. /bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed
      2. /bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" thin
    5. Flutter项目报错 - Building for iOS, but the linked and embedded framework 'App.framework'的处理 - 图3

    6. 在Runner目标的Build Settings> Other Linker FlagsOTHER_LDFLAGS)中添加$(inherited) -framework Flutter
      Flutter项目报错 - Building for iOS, but the linked and embedded framework 'App.framework'的处理 - 图4

    https://flutter.dev/docs/development/ios-project-migration