我最近在 iOS 上遇到了 Flutter 应用程序的问题。当我尝试运行该应用程序时,收到以下错误消息:
Could not build the precompiled application for the device.
Swift Compiler Error (Xcode): No such module 'Flutter'
/Users/victorpelle/.pub-cache/hosted/pub.dev/url_launcher_ios-6.3.1/ios/url_launcher_ios/Sources/url_launcher_ios/messages.g.swift:9:9
Swift Compiler Error (Xcode): No such module 'Flutter'
/Users/victorpelle/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.0/darwin/path_provider_foundation/Sources/path_provider_foundation/messages.g.swift:9:9
Uncategorized (Xcode): Command SwiftEmitModule failed with a nonzero exit code
Error launching application on eziopelle’s iPhone.
我已经尝试过几件事:
flutter clean
flutter pub get
pod install
pod update
我也关闭了 Xcode,尝试删除我的
Podfile.lock
,但似乎没有任何效果。
这是我的启动器:
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import UIKit
/// Protocol for UIApplication methods relating to launching URLs.
///
/// This protocol exists to allow injecting an alternate implementation for testing.
protocol Launcher {
/// Returns a Boolean value that indicates whether an app is available to handle a URL scheme.
func canOpenURL(_ url: URL) -> Bool
/// Attempts to asynchronously open the resource at the specified URL.
func open(
_ url: URL,
options: [UIApplication.OpenExternalURLOptionsKey: Any],
completionHandler completion: ((Bool) -> Void)?)
}
/// Launcher is intentionally a direct passthroguh to UIApplication.
extension UIApplication: Launcher {}
你能帮我解决这个错误吗?
flutter doctor -v [🐍 system]
[✓] Flutter (Channel stable, 3.24.3, on macOS 14.5 23F79 darwin-x64, locale fr-FR)
• Flutter version 3.24.3 on channel stable at /Users/victorpelle/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 2663184aa7 (4 weeks ago), 2024-09-11 16:27:48 -0500
• Engine revision 36335019a8
• Dart version 3.5.3
• DevTools version 2.37.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/victorpelle/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/victorpelle/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16A242d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.3)
• 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 17.0.6+0-17.0.6b829.9-10027231)
[✓] VS Code (version 1.94.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.98.0
[✓] Connected device (3 available)
• eziopelle’s iPhone (mobile) • 00008110-001078243A61801E • ios • iOS 18.0.1 22A3370
• macOS (desktop) • macos
• darwin-x64 • macOS 14.5 23F79 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 129.0.6668.90
[✓] 网络资源 • 所有预期的网络资源均可用。
• 未发现问题!