Flutter 无法仅在物理 iOs 设备中构建和运行 iOS 应用程序

Posted

技术标签:

【中文标题】Flutter 无法仅在物理 iOs 设备中构建和运行 iOS 应用程序【英文标题】:Flutter Failed to build and run iOS app only in physical iOs device 【发布时间】:2021-07-01 03:29:26 【问题描述】:

我正在尝试构建和运行“计数器应用程序”(创建颤振项目时的默认应用程序),我可以在 androidios 模拟器中运行该项目,在物理设备上完美地在 android 中运行但是当我运行在 vscode 中的项目我得到了一个错误。

我运行项目时的输出是:

Downloading libimobiledevice...
Launching lib/main.dart on iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: FSB8SU7R5X
Xcode build done.                                           16.0s
Failed to build iOS app
Error output from Xcode build:
↳
    2021-06-30 22:16:22.665 xcodebuild[43211:324927]  DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTiOSFrameworks/DVTiOSFrameworks-18108/DTDeviceKitBase/DTDKRemoteDeviceData.m:371
    Details:  (null) deviceType from 281a05c1d363c04aed318582d30866afde2dd04c was NULL when -platform called.
    Object:   <DTDKMobileDeviceToken: 0x7faac3b77c10>
    Method:   -platform
    Thread:   <NSThread: 0x7faac0c416c0>number = 2, name = (null)
    Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
    2021-06-30 22:16:22.867 xcodebuild[43211:324928]  DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTiOSFrameworks/DVTiOSFrameworks-18108/DTDeviceKitBase/DTDKRemoteDeviceData.m:371
    Details:  (null) deviceType from 281a05c1d363c04aed318582d30866afde2dd04c was NULL when -platform called.
    Object:   <DTDKMobileDeviceToken: 0x7faac3b77c10>
    Method:   -platform
    Thread:   <NSThread: 0x7faac3b69fe0>number = 6, name = (null)
    Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
    2021-06-30 22:16:22.991 xcodebuild[43211:324928]  DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTiOSFrameworks/DVTiOSFrameworks-18108/DTDeviceKitBase/DTDKRemoteDeviceData.m:371
    Details:  (null) deviceType from 281a05c1d363c04aed318582d30866afde2dd04c was NULL when -platform called.
    Object:   <DTDKMobileDeviceToken: 0x7faac3b77c10>
    Method:   -platform
    Thread:   <NSThread: 0x7faac3b69fe0>number = 6, name = (null)
    Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
    ** BUILD FAILED **
Xcode's output:
↳
    Command PhaseScriptExecution failed with a nonzero exit code
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete
    note: Removed stale file '/Users/jromero/Library/Developer/Xcode/DerivedData/Runner-flkwoylypfarbpbtarvmoxfypnce/Build/Products/Debug-iphoneos/Runner.app'
Could not build the precompiled application for the device.

Error launching application on iPhone.
Exited (sigterm)

我尝试清理项目(flutter clean,获取包并再次运行)但没有工作:c。

颤振医生输出:

[✓] Flutter (Channel stable, 2.2.2, on macOS 11.4 20F71 darwin-x64, locale en)
    • Flutter version 2.2.2 at /Users/jromero/development/flutter
    • Framework revision d79295af24 (3 weeks ago), 2021-06-11 08:56:01 -0700
    • Engine revision 91c9fc8fe0
    • Dart version 2.13.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/jromero/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/jromero/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.1

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

[✓] Android Studio (version 4.1)
    • 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 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Community Edition (version 2021.1.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 57.0.5
    • Dart plugin version 211.7665

[✓] VS Code (version 1.57.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.23.0

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.114

• No issues found!

欢迎任何帮助 c:

【问题讨论】:

【参考方案1】:

很抱歉,如果这是一个迟到的答案,但在这些情况下对我有帮助的是

    在终端中运行“flutter clean” 在某些情况下,清除项目的文件缓存会有所帮助...可以通过在 vscode 上打开命令快捷方式(shift+command+p 或 shift+control+p)然后搜索“清除编辑器历史记录”来完成" 假设你已经安装了 Mac 和 Pod,并且你已经更新了任何 pubsec 包,一个可选的附加步骤大部分工作是删除你的 Flutter Project iOS 文件夹下的“Podfile.lock”文件,假设它有已经在以前的构建中生成,然后关闭您的 IDE。然后在您的终端中,导航到您的 cd &lt;pathToProject&gt;/&lt;ios&gt; 重要的是您导航到您的 iOS 子文件夹并运行 pod install --repo-update

-一切顺利

【讨论】:

以上是关于Flutter 无法仅在物理 iOs 设备中构建和运行 iOS 应用程序的主要内容,如果未能解决你的问题,请参考以下文章

Flutter 物理 iOS 设备无法向我的本地 asp.net 服务器发出 api 请求

在 macOS 中构建 Flutter 项目

无法在物理 Apple 设备上运行颤振应用程序

Flutter 无法在物理设备上加载图像资产(但在模拟器上加载它就好了)

在发布模式下构建后 Flutter Secure Storage 无法正常工作

Flutter 无法在 VS Code 上构建示例 iOS 应用程序