【问题标题】:Xcode Simulator won't work from Flutter when adding assets in pubspec.yaml在 pubspec.yaml 中添加资产时,Xcode Simulator 无法在 Flutter 中运行
【发布时间】:2020-03-30 17:12:14
【问题描述】:

我刚刚下载了 Xcode 11.4,当我将我的图像(它是一个 gif)添加到 pubspec.yaml 中的“资产:”时,模拟器将无法工作 这是我的回归:

Launching lib/main.dart on iPhone 11 Pro in debug mode...
Running Xcode build...
Xcode build done.                                           35.3s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    /Users/scrabbleknight/Downloads/swift-master/build/ios/Debug-iphonesimulator/Runner.app: resource fork, Finder information, or similar detritus not allowed
    Command CodeSign failed with a nonzero exit code
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description

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

【问题讨论】:

  • 这种情况只发生在 Xcode 上吗?安卓呢?
  • 它来自Flutter,但这是一个Xcode问题,因为我的Android模拟器都运行流畅。我发现它只发生在 gif 图像上,而我没有添加到我的资产文件中。我假设 Flutter 在将 gif 作为文件上传到 pubspec 时存在问题。
  • 看看其中一个是否可以修复它stackoverflow.com/questions/39652867/…

标签: xcode flutter


【解决方案1】:

解决方案

嘿,我遇到这个问题的时间最长,并且经过了几种调试方法。 当我清理构建并使用 XCode 11.4.1 运行时,一个为我工作。

我的设置; Xcode:11.4.1 MacOS:卡特琳娜 10.15.4

第 1 步:Pubspec.yaml -- 我将图像的路径指定为 assests/images/"image_name"."image_format"。

第 2 步:Pubspec.yaml -- 我曾经使用“assets: -images”来声明所有图像,但我将它们单独列出。

第 3 步:在我的代码中,我使用“Image(image: AssetImage())”来拉取图像,而不是 images.asset()

第 4 步:我相信这是最重要的部分。当我使用大型 PNG 文件(702KB)时,您使用的图像可能是导致错误的原因,但当我使用 JPG(141KB)时,我的应用程序在我的设备上运行时没有任何错误。 PS:我的 pupspec 中有其他较小的 PNG 文件(75KB 和 15KB),它们没有任何问题。

【讨论】:

    猜你喜欢
    • 2021-08-10
    • 2022-11-04
    • 2021-05-29
    • 2020-04-26
    • 1970-01-01
    • 2014-11-07
    • 2014-12-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多