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

时间:2021-07-11 15:18:44

标签: ios xcode flutter cocoapods flutter-ios

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

pod install 没有错误

在我尝试 flutter run 之后,我收到了这些错误。 我的 pod 文件在下面。

我该如何解决这个问题?

Flutter 运行输出:

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


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

我的 Pod 文件:

# Uncomment this line to define a global platform for your project
platform :ios, '10.0'

pod 'Firebase'
pod 'Firebase/Crashlytics'
pod 'Firebase/Analytics'
pod 'Firebase/Messaging'
pod 'Google-Mobile-Ads-SDK'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
     end
  end

0 个答案:

没有答案