Flutter ios“无法为模拟器构建应用程序。”

uka*_*ale 13 xcode ios cocoapods flutter flutter-ios

我有一个用 Flutter 编写的 Android 应用程序。\n现在我正在尝试它的 ios 版本,但出现错误。我尝试运行空的 flutter 项目,并且运行成功。

\n

没有错误 pod install

\n

在尝试 flutter run 后,我收到这些错误。\n我的 pod 文件位于下面。

\n

我怎么解决这个问题?

\n

颤振运行输出:

\n
    Xcode's output:\n\xe2\x86\xb3\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-2.0.9/ios/Classes/FlutterWebView.m:395:23:\n    warning: 'requiresUserActionForMediaPlayback' is deprecated: first deprecated in iOS 10.0 [-Wdeprecated-declarations]\n            configuration.requiresUserActionForMediaPlayback = true;\n                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n                          mediaTypesRequiringUserActionForPlayback\n    In module 'WebKit' imported from\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-2.0.9/ios/Classes/FlutterWebView.h:6:\n    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/System/Library/Framew\n    orks/WebKit.framework/Headers/WKWebViewConfiguration.h:213:28: note: 'requiresUserActionForMediaPlayback' has been explicitly marked\n    deprecated here\n    @property (nonatomic) BOOL requiresUserActionForMediaPlayback API_DEPRECATED_WITH_REPLACEMENT("mediaTypesRequiringUserActionForPlayback",\n    ios(9.0, 10.0));\n                               ^\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-2.0.9/ios/Classes/FlutterWebView.m:407:23:\n    warning: 'requiresUserActionForMediaPlayback' is deprecated: first deprecated in iOS 10.0 [-Wdeprecated-declarations]\n            configuration.requiresUserActionForMediaPlayback = false;\n                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n                          mediaTypesRequiringUserActionForPlayback\n    In module 'WebKit' imported from\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-2.0.9/ios/Classes/FlutterWebView.h:6:\n    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/System/Library/Framew\n    orks/WebKit.framework/Headers/WKWebViewConfiguration.h:213:28: note: 'requiresUserActionForMediaPlayback' has been explicitly marked\n    deprecated here\n    @property (nonatomic) BOOL requiresUserActionForMediaPlayback API_DEPRECATED_WITH_REPLACEMENT("mediaTypesRequiringUserActionForPlayback",\n    ios(9.0, 10.0));\n                               ^\n    2 warnings generated.\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/InAppBrowser/InAppBrow\n    serWebViewController.swift:557:13: warning: setter for 'statusBarStyle' was deprecated in iOS 9.0: Use -[UIViewController\n    preferredStatusBarStyle]\n                UIApplication.shared.statusBarStyle = UIStatusBarStyle(rawValue: previousStatusBarStyle)!\n                ^\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/S\n    afariBrowserOptions.swift:34:16: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true\n                if #available(iOS 10.0, *) {\n                   ^\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/S\n    afariBrowserOptions.swift:12:14: note: enclosing scope here\n    public class SafariBrowserOptions: Options<SafariViewController> {\n                 ^\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/S\n    afariViewController.swift:66:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true\n            if #available(iOS 10.0, *) {\n               ^\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/S\n    afariViewController.swift:12:14: note: enclosing scope here\n    public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate {\n                 ^\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/S\n    afariBrowserOptions.swift:34:16: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true\n                if #available(iOS 10.0, *) {\n                   ^\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/S\n    afariBrowserOptions.swift:12:14: note: enclosing scope here\n    public class SafariBrowserOptions: Options<SafariViewController> {\n                 ^\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/S\n    afariViewController.swift:66:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true\n            if #available(iOS 10.0, *) {\n               ^\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/S\n    afariViewController.swift:12:14: note: enclosing scope here\n    public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate {\n                 ^\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/Types/URLCredential.sw\n    ift:14:25: warning: comparing non-optional value of type '[Any]' to 'nil' always returns true\n            if certificates != nil {\n               ~~~~~~~~~~~~ ^  ~~~\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/Util.swift:86:25:\n    warning: 'spotlightSuggestion' was deprecated in iOS 10.0: renamed to 'WKDataDetectorTypes.lookupSuggestion'\n                    return .spotlightSuggestion\n                            ^\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/Util.swift:86:25:\n    note: use 'WKDataDetectorTypes.lookupSuggestion' instead\n                    return .spotlightSuggestion\n                            ^~~~~~~~~~~~~~~~~~~\n                            WKDataDetectorTypes.lookupSuggestion\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/Util.swift:121:31:\n    warning: 'spotlightSuggestion' was deprecated in iOS 10.0: renamed to 'WKDataDetectorTypes.lookupSuggestion'\n                if type.contains(.spotlightSuggestion) {\n                                  ^\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/Util.swift:121:31:\n    note: use 'WKDataDetectorTypes.lookupSuggestion' instead\n                if type.contains(.spotlightSuggestion) {\n                                  ^~~~~~~~~~~~~~~~~~~\n                                  WKDataDetectorTypes.lookupSuggestion\n    /usr/local/Caskroom/flutter/2.2.3/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/Util.swift:216:21:\n    warning: immutable value 'j' was never used; consider replacing with '_' or removing it\n                    for j in ipv6.count...8 {\n                        ^\n                        _\n    Undefined symbols for architecture x86_64:\n      "_OBJC_CLASS_$_GULAppEnvironmentUtil", referenced from:\n          objc-class-ref in FIRCLSApplication.o\n    ld: symbol(s) not found for architecture x86_64\n    clang: error: linker command failed with exit code 1 (use -v to see invocation)\n    Undefined symbols for architecture i386:\n      "_OBJC_CLASS_$_GULAppEnvironmentUtil", referenced from:\n          objc-class-ref in FIRCLSApplication.o\n    ld: symbol(s) not found for architecture i386\n    clang: error: linker command failed with exit code 1 (use -v to see invocation)\n    Undefined symbols for architecture arm64:\n      "_OBJC_CLASS_$_GULAppEnvironmentUtil", referenced from:\n          objc-class-ref in FIRCLSApplication.o\n    ld: symbol(s) not found for architecture arm64\n    clang: error: linker command failed with exit code 1 (use -v to see invocation)\n    note: Using new build system\n    note: Building targets in parallel\n    note: Planning build\n    note: Analyzing workspace\n    note: Constructing build description\n    note: Build preparation complete\n    warning: Stale file\n    '/Users/emre/Desktop/freegamescodes/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/flutter_local_notifications.framework' is\n    located outside of the allowed root paths.\n\n\nCould not build the application for the simulator.\nError launching application on iPhone 12 Pro Max.\n
Run Code Online (Sandbox Code Playgroud)\n

我的 Pod 文件:

\n
# Uncomment this line to define a global platform for your project\nplatform :ios, '10.0'\n\npod 'Firebase'\npod 'Firebase/Crashlytics'\npod 'Firebase/Analytics'\npod 'Firebase/Messaging'\npod 'Google-Mobile-Ads-SDK'\n\n# CocoaPods analytics sends network stats synchronously affecting flutter build latency.\nENV['COCOAPODS_DISABLE_STATS'] = 'true'\n\nproject 'Runner', {\n  'Debug' => :debug,\n  'Profile' => :release,\n  'Release' => :release,\n}\n\ndef flutter_root\n  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)\n  unless File.exist?(generated_xcode_build_settings_path)\n    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"\n  end\n\n  File.foreach(generated_xcode_build_settings_path) do |line|\n    matches = line.match(/FLUTTER_ROOT\\=(.*)/)\n    return matches[1].strip if matches\n  end\n  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"\nend\n\nrequire File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)\n\nflutter_ios_podfile_setup\n\ntarget 'Runner' do\n  use_frameworks!\n  use_modular_headers!\n\n  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))\nend\n\npost_install do |installer|\n  installer.pods_project.targets.each do |target|\n    flutter_additional_ios_build_settings(target)\n    target.build_configurations.each do |config|\n      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'\n     end\n  end\n
Run Code Online (Sandbox Code Playgroud)\n

Sye*_*lal 0

备份您的项目并尝试以下命令: flutter clean && \ rm ios/Podfile ios/Podfile.lock pubspec.lock && \ rm -rf ios/Pods ios/Runner.xcworkspace && \ flutter run