【问题标题】:Xcode Build Error on Flutter Any Object Error and openURL errorFlutter 上的 Xcode 构建错误任何对象错误和 openURL 错误
【发布时间】:2021-09-17 19:52:43
【问题描述】:

我的项目有问题。我在 Xcode 上构建(在 Visual Studio 代码上开发)时遇到了一堆错误。

Launching lib/main.dart on iPhone 11 Pro in debug mode...
Xcode build done.                                           1456.2s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    /Users/usuario/development/projects/stb/property1/ios/Pods/BSImagePicker/Sources/Scene/Albums/AlbumsViewController.swift:26:40: warning: using 'class' keyword for protocol inheritance is deprecated; use 'AnyObject' instead
    protocol AlbumsViewControllerDelegate: class {
                                           ^~~~~
                                           AnyObject
    /Users/usuario/development/projects/stb/property1/ios/Pods/BSImagePicker/Sources/Scene/Assets/AssetsViewController.swift:26:40: warning: using 'class' keyword for protocol inheritance is deprecated; use 'AnyObject' instead
    protocol AssetsViewControllerDelegate: class {
                                           ^~~~~
                                           AnyObject
    /Users/usuario/development/projects/stb/property1/ios/Pods/BSImagePicker/Sources/Controller/ImagePickerControllerDelegate.swift:27:48: warning: using 'class' keyword for protocol inheritance is deprecated; use 'AnyObject' instead
    public protocol ImagePickerControllerDelegate: class {
                                                   ^~~~~
                                                   AnyObject
    /Users/usuario/development/projects/stb/property1/ios/Pods/BSImagePicker/Sources/Scene/Albums/AlbumsViewController.swift:26:40: warning: using 'class' keyword for protocol inheritance is deprecated; use 'AnyObject' instead
    protocol AlbumsViewControllerDelegate: class {
                                           ^~~~~
                                           AnyObject
    /Users/usuario/development/projects/stb/property1/ios/Pods/BSImagePicker/Sources/Scene/Assets/AssetsViewController.swift:26:40: warning: using 'class' keyword for protocol inheritance is deprecated; use 'AnyObject' instead
    protocol AssetsViewControllerDelegate: class {
                                           ^~~~~
                                           AnyObject
    /Users/usuario/development/projects/stb/property1/ios/Pods/BSImagePicker/Sources/Controller/ImagePickerControllerDelegate.swift:27:48: warning: using 'class' keyword for protocol inheritance is deprecated; use 'AnyObject' instead
    public protocol ImagePickerControllerDelegate: class {
                                                   ^~~~~
                                                   AnyObject
    /Users/usuario/development/projects/stb/property1/ios/Pods/BSImagePicker/Sources/Scene/Albums/AlbumsViewController.swift:26:40: warning: using 'class' keyword for protocol inheritance is deprecated; use 'AnyObject' instead
    protocol AlbumsViewControllerDelegate: class {
                                           ^~~~~
                                           AnyObject
    /Users/usuario/development/projects/stb/property1/ios/Pods/BSImagePicker/Sources/Scene/Assets/AssetsViewController.swift:26:40: warning: using 'class' keyword for protocol inheritance is deprecated; use 'AnyObject' instead
    protocol AssetsViewControllerDelegate: class {
                                           ^~~~~
                                           AnyObject
    /Users/usuario/development/projects/stb/property1/ios/Pods/BSImagePicker/Sources/Controller/ImagePickerControllerDelegate.swift:27:48: warning: using 'class' keyword for protocol inheritance is deprecated; use 'AnyObject' instead
    public protocol ImagePickerControllerDelegate: class {
                                                   ^~~~~
                                                   AnyObject
    /Users/usuario/development/projects/stb/property1/ios/Pods/AppAuth/Source/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m:148:42: warning: 'openURL:' is deprecated: first deprecated in iOS 10.0 [-Wdeprecated-declarations]
          [[UIApplication sharedApplication] openURL:_appStoreURL];
                                             ^~~~~~~
                                             openURL:options:completionHandler:
    In module 'UIKit' imported from /Users/usuario/development/projects/stb/property1/ios/Pods/Target Support Files/AppAuth/AppAuth-prefix.pch:2:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.5.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:123:1: note: 'openURL:' has been explicitly marked deprecated here
    - (BOOL)openURL:(NSURL*)url API_DEPRECATED_WITH_REPLACEMENT("openURL:options:completionHandler:", ios(2.0, 10.0)) NS_EXTENSION_UNAVAILABLE_IOS("");
    ^
    /Users/usuario/development/projects/stb/property1/ios/Pods/AppAuth/Source/AppAuth/iOS/OIDExternalUserAgentIOSCustomBrowser.m:156:61: warning: 'openURL:' is deprecated: first deprecated in iOS 10.0 [-Wdeprecated-declarations]
      BOOL openedInBrowser = [[UIApplication sharedApplication] openURL:requestURL];
                                                                ^~~~~~~
                                                                openURL:options:completionHandler:
    In module 'UIKit' imported from /Users/usuario/development/projects/stb/property1/ios/Pods/Target Support Files/AppAuth/AppAuth-prefix.pch:2:
    1 warning generated.
    In file included from /Users/usuario/development/projects/stb/property1/ios/Pods/gRPC-Core/src/core/lib/security/transport/client_auth_filter.cc:32:
    In file included from /Users/usuario/development/projects/stb/property1/ios/Pods/gRPC-Core/src/core/lib/security/context/security_context.h:28:
    /Users/usuario/development/projects/stb/property1/ios/Pods/gRPC-Core/src/core/lib/security/credentials/credentials.h:205:15: warning: anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here [-Wnon-c-typedef-for-linkage]
    typedef struct {
                  ^
                   grpc_credentials_mdelem_array
    /Users/usuario/development/projects/stb/property1/ios/Pods/gRPC-Core/src/core/lib/security/credentials/credentials.h:206:21: note: type is not C-compatible due to this default member initializer
      grpc_mdelem* md = nullptr;
                        ^~~~~~~
    /Users/usuario/development/projects/stb/property1/ios/Pods/gRPC-Core/src/core/lib/security/credentials/credentials.h:208:3: note: type is given name 'grpc_credentials_mdelem_array' for linkage purposes by this typedef declaration
    } grpc_credentials_mdelem_array;
      ^
    1 warning generated.
    In file included from /Users/usuario/development/projects/stb/property1/ios/Pods/gRPC-Core/src/core/ext/transport/chttp2/transport/chttp2_transport.cc:36:
    In file included from /Users/usuario/development/projects/stb/property1/ios/Pods/gRPC-Core/src/core/ext/transport/chttp2/transport/context_list.h:26:
    /Users/usuario/development/projects/stb/property1/ios/Pods/gRPC-Core/src/core/ext/transport/chttp2/transport/internal.h:109:15: warning: anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here [-Wnon-c-typedef-for-linkage]
    typedef struct {
                  ^
                   grpc_chttp2_ping_queue
    /Users/usuario/development/projects/stb/property1/ios/Pods/gRPC-Core/src/core/ext/transport/chttp2/transport/internal.h:110:52: note: type is not C-compatible due to this default member initializer
      grpc_closure_list lists[GRPC_CHTTP2_PCL_COUNT] = {};
                                ^
    Failed to package /Users/usuario/development/projects/stb/property1.
    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
Could not build the application for the simulator.
Error launching application on iPhone 11 Pro.
Exited (sigterm)

直到今天早上,这一切都出乎意料地发生了。我之前遇到过问题:

warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99

我认为它已经解决了:

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['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
    end
  end
end

在 PodFile 中。

然后我仍然收到这个错误,我正在咨询这个错误,所以我尝试将我的 Flutter 从 2.2.0 更新到 2.5.0,并从以下位置更新了我的依赖项:

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  provider: ^5.0.0
  intl: ^0.17.0
  carousel_pro: ^1.0.0
  url_launcher: ^6.0.3
  photo_view: ^0.11.1
  cloud_firestore: ^2.2.1
  firebase_core: ^1.1.1
  firebase_auth: ^1.1.4
  image_picker: ^0.7.5
  firebase_storage: ^8.0.6
  random_string: ^2.1.0
  algolia: ^1.0.1
  custom_switch: ^0.0.1
  material_design_icons_flutter: ^4.0.5955
  google_sign_in: ^5.0.4
  firebase_dynamic_links: ^2.0.4
  share: ^2.0.2
  flutter_facebook_login: ^3.0.0
  http: ^0.13.3
  sign_in_with_apple: ^3.0.0
  csc_picker: ^0.2.5
  us_states: ^1.1.0
  multi_image_picker2: ^5.0.2
  percent_indicator: ^3.0.1
  flutter_material_pickers: ^3.1.0 #used on Selling Bathrooms and Bedrooms
  numberpicker: ^2.1.1 #used on Selling Bedrooms only.
  eva_icons_flutter: ^3.0.0
  badges: ^2.0.1
  flutter_xlider: ^3.4.0
  expandable_text: 2.2.0
  google_maps_flutter: ^2.0.6
  line_icons: ^2.0.1
  intl_phone_field: ^2.0.1 #used to get the phone in the Profile Page.
  flutter_masked_text: ^0.8.0 #used to do the mask of the Filters TextFormField to Dollar Value, not use currently
  flutter_absolute_path: ^1.0.6 #used to get the file path for multi Image 
  rxdart: ^0.27.2 #used for Geolocation queries with Firebase
  geoflutterfire: ^3.0.1

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  firebase_messaging: ^10.0.6

收件人:

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  provider: ^6.0.0
  intl: ^0.17.0
  carousel_pro: ^1.0.0
  url_launcher: ^6.0.10
  photo_view: ^0.12.0
  cloud_firestore: ^2.5.3
  firebase_core: ^1.6.0
  firebase_auth: ^3.1.1
  image_picker: ^0.8.4+1
  firebase_storage: ^10.0.3
  random_string: ^2.3.1
  algolia: ^1.0.1
  custom_switch: ^0.0.1
  material_design_icons_flutter: ^4.0.5955
  google_sign_in: ^5.1.0
  firebase_dynamic_links: ^2.0.9
  share: ^2.0.4
  #flutter_facebook_login: ^3.0.0
  http: ^0.13.3
  sign_in_with_apple: ^3.0.0
  csc_picker: ^0.2.5
  us_states: ^1.1.5
  multi_image_picker2: ^5.0.2
  percent_indicator: ^3.0.1
  flutter_material_pickers: ^3.1.0 #used on Selling Bathrooms and Bedrooms
  numberpicker: ^2.1.1 #used on Selling Bedrooms only.
  eva_icons_flutter: ^3.0.2
  badges: ^2.0.1
  flutter_xlider: ^3.4.0
  expandable_text: ^2.2.0
  google_maps_flutter: ^2.0.9
  line_icons: ^2.0.1
  intl_phone_field: ^2.1.0 #used to get the phone in the Profile Page.
  flutter_masked_text: ^0.8.0 #used to do the mask of the Filters TextFormField to Dollar Value, not use currently
  #flutter_absolute_path: ^1.0.6 #used to get the file path for multi Image 
  rxdart: ^0.27.2 #used for Geolocation queries with Firebase
  geoflutterfire: ^3.0.1

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  firebase_messaging: ^10.0.7

显然,更新我的代码以反映更改,关于如何将其恢复到 iOS 模拟器并恢复正常工作的任何想法?

【问题讨论】:

    标签: ios xcode flutter


    【解决方案1】:

    如果有人遇到此问题,我会进行修复,首先我遇到了 2 个问题:

    1. 由于 Xcode 12 中对 iOS 8 的支持下降,我的项目的 Pod 不再工作(Link 中的更多信息)。

    2. 为了让它工作,我从 Flutter 2.2.0 更新到 2.5.0,这基本上做了很多改变,并从依赖项所依赖的一些方法中移除了支持。

    为了解决这个问题,我做了两件事:

    从问题 2 开始,我刚刚使用命令 flutter downgrade 2.2.0 对我的 Flutter 进行了降级,这有助于我回到原来的问题而无需面对去掉那些依赖的方法。

    至于第 1 期的事情:

    首先将其添加到 PodFile 中:

    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
    end
    

    其次,为了修复 Pod,我做了以下步骤:

    1. 删除 pubspec.lock 文件。
    • 在主项目的终端中
    1. Flutter 清洁了吗。
    • 在终端中转到 iOS 文件夹:
    1. 删除 Podfile.lock
    2. 删除 Pods 文件夹。
    3. 至关重要:复制(无论何时作为备份)PodFile 的内容,包括最后添加的部分。
    4. 删除 Podfile。
    5. 在 iOS 文件夹的终端中执行 pod init。 (这将生成包含基本信息的 Podfile)。
    6. 在 iOS 文件夹的终端中进行 pod 安装。 (这将生成包含基本信息的 Podfile.lock 和 Pods 文件夹)。
    • 导航到终端中的主项目文件夹 (cd ..) 或使用 pubspec.yaml 文件中的 Pub get 图标。
    1. 做一个颤抖的酒吧得到
    • 在终端中转到 iOS 文件夹:
    1. 复制第5步备份的存储信息,粘贴到PodFile中。

    2. 进行 pod 安装。

    • 导航到终端中的主项目文件夹 (cd ..)

    最后,做一个颤动的运行。

    这就是我设法解决它的方法。

    亲切的问候

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-21
      • 2018-10-04
      • 1970-01-01
      • 1970-01-01
      • 2018-03-24
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      相关资源
      最近更新 更多