尝试从 android studio 打开时,Xcode 中的 Flutter 打开模块会出错?
Posted
技术标签:
【中文标题】尝试从 android studio 打开时,Xcode 中的 Flutter 打开模块会出错?【英文标题】:Flutter open module in Xcode gives error when trying to open from android studio? 【发布时间】:2021-07-21 10:31:21 【问题描述】:在我的颤振项目中,我正在尝试运行 ios 版本进行调试。但是,当我尝试从 android Studio 中打开 Xcode 中的 iOS 模块时,出现以下错误。
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
/Users/jasondwaku/Documents/FlutterProjects/ClubRoom/clubroom/ios/Pods/libwebp/src/enc/backward_references_enc.c:694:12: warning: variable 'best_offset' may be uninitialized when used here [-Wconditional-uninitialized]
(best_offset << MAX_LENGTH_BITS) | (uint32_t)best_length;
^~~~~~~~~~~
/Users/jasondwaku/Documents/FlutterProjects/ClubRoom/clubroom/ios/Pods/libwebp/src/enc/backward_references_enc.c:626:20: note: initialize the variable 'best_offset' to silence this warning
int best_offset;
^
= 0
1 warning generated.
1 warning generated.
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/image_picker-0.7.4/ios/Classes/FLTImagePickerPhotoAssetUtil.m:17:44: warning: 'UIImagePickerControllerReferenceURL' is deprecated: first deprecated in iOS 11.0 - Will be removed in a future release, use phpicker. [-Wdeprecated-declarations]
NSURL *referenceURL = [info objectForKey:UIImagePickerControllerReferenceURL];
^
In module 'UIKit' imported from /Users/jasondwaku/Documents/FlutterProjects/ClubRoom/clubroom/ios/Pods/Target Support Files/image_picker/image_picker-prefix.pch:2:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIImagePickerController.h:62:51: note: 'UIImagePickerControllerReferenceURL' has been explicitly marked deprecated here
UIKIT_EXTERN UIImagePickerControllerInfoKey const UIImagePickerControllerReferenceURL API_DEPRECATED("Will be removed in a future release, use PHPicker.", ios(4.1, 11.0)) API_UNAVAILABLE(tvos); // an NSURL that references an asset in the AssetsLibrary framework
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/image_picker-0.7.4/ios/Classes/FLTImagePickerPhotoAssetUtil.m:21:47: warning: 'fetchAssetsWithALAssetURLs:options:' is deprecated: first deprecated in iOS 11 - Will be removed in a future release [-Wdeprecated-declarations]
PHFetchResult<PHAsset *> *result = [PHAsset fetchAssetsWithALAssetURLs:@[ referenceURL ]
^
In module 'Photos' imported from /Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/image_picker-0.7.4/ios/Classes/FLTImagePickerPhotoAssetUtil.h:6:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/Photos.framework/Headers/PHAsset.h:74:1: note: 'fetchAssetsWithALAssetURLs:options:' has been explicitly marked deprecated here
+ (PHFetchResult<PHAsset *> *)fetchAssetsWithALAssetURLs:(NSArray<NSURL *> *)assetURLs options:(nullable PHFetchOptions *)options API_DEPRECATED("Will be removed in a future release", ios(8, 11), tvos(8, 11)) API_UNAVAILABLE(macos);
^
2 warnings generated.
/Users/jasondwaku/Documents/FlutterProjects/ClubRoom/clubroom/ios/Pods/SDWebImageWebPCoder/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m:608:33: warning: 'CGColorSpaceCreateWithICCProfile' is deprecated: first deprecated in iOS 11.0 - No longer supported [-Wdeprecated-declarations]
colorSpaceRef = CGColorSpaceCreateWithICCProfile((__bridge CFDataRef)profileData);
^
In module 'UIKit' imported from /Users/jasondwaku/Documents/FlutterProjects/ClubRoom/clubroom/ios/Pods/Target Support Files/SDWebImageWebPCoder/SDWebImageWebPCoder-prefix.pch:2:
In module 'CoreGraphics' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIBezierPath.h:10:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGColorSpace.h:449:38: note: 'CGColorSpaceCreateWithICCProfile' has been explicitly marked deprecated here
CG_EXTERN CGColorSpaceRef __nullable CGColorSpaceCreateWithICCProfile(CFDataRef cg_nullable data)
^
1 warning generated.
2 warnings generated.
12 warnings generated.
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_image_compress-1.0.0/ios/Classes/CompressFileHandler.m:39:18: warning: direct comparison of a string literal has undefined behavior [-Wobjc-string-compare]
if(imageType == @"image/webp")
^ ~~~~~~~~~~~~~
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_image_compress-1.0.0/ios/Classes/CompressFileHandler.m:39:18: note: use 'isEqual:' instead
if(imageType == @"image/webp")
^~
[ isEqual: ]
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_image_compress-1.0.0/ios/Classes/CompressFileHandler.m:82:18: warning: direct comparison of a string literal has undefined behavior [-Wobjc-string-compare]
if(imageType == @"image/webp")
^ ~~~~~~~~~~~~~
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_image_compress-1.0.0/ios/Classes/CompressFileHandler.m:82:18: note: use 'isEqual:' instead
if(imageType == @"image/webp")
^~
[ isEqual: ]
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_image_compress-1.0.0/ios/Classes/CompressFileHandler.m:109:16: warning: unused variable 'swf' [-Wunused-variable]
const char swf[3] = 'F', 'W', 'S';
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_image_compress-1.0.0/ios/Classes/CompressFileHandler.m:110:16: warning: unused variable 'swc' [-Wunused-variable]
const char swc[3] = 'C', 'W', 'S';
^
4 warnings generated.
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariBrowserOptions.swift:29:16: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
if #available(iOS 11.0, *)
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariBrowserOptions.swift:12:14: note: enclosing scope here
public class SafariBrowserOptions: Options<SafariViewController>
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariBrowserOptions.swift:34:16: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
if #available(iOS 10.0, *)
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariBrowserOptions.swift:12:14: note: enclosing scope here
public class SafariBrowserOptions: Options<SafariViewController>
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:62:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
if #available(iOS 11.0, *)
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:12:14: note: enclosing scope here
public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:66:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
if #available(iOS 10.0, *)
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:12:14: note: enclosing scope here
public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:62:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
if #available(iOS 11.0, *)
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:12:14: note: enclosing scope here
public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:66:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
if #available(iOS 10.0, *)
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:12:14: note: enclosing scope here
public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariBrowserOptions.swift:29:16: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
if #available(iOS 11.0, *)
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariBrowserOptions.swift:12:14: note: enclosing scope here
public class SafariBrowserOptions: Options<SafariViewController>
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariBrowserOptions.swift:34:16: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
if #available(iOS 10.0, *)
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariBrowserOptions.swift:12:14: note: enclosing scope here
public class SafariBrowserOptions: Options<SafariViewController>
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:62:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
if #available(iOS 11.0, *)
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:12:14: note: enclosing scope here
public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:66:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
if #available(iOS 10.0, *)
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:12:14: note: enclosing scope here
public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:62:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
if #available(iOS 11.0, *)
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:12:14: note: enclosing scope here
public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:66:12: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
if #available(iOS 10.0, *)
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/SafariViewController/SafariViewController.swift:12:14: note: enclosing scope here
public class SafariViewController: SFSafariViewController, FlutterPlugin, SFSafariViewControllerDelegate
^
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.3.2/ios/Classes/Types/URLCredential.swift:14:25: warning: comparing non-optional value of type '[Any]' to 'nil' always returns true
if certificates != nil
~~~~~~~~~~~~ ^ ~~~
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
While building module 'firebase_core' imported from /Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-8.0.0-dev.15/ios/Classes/FLTFirebaseMessagingPlugin.m:6:
In file included from <module-includes>:1:
In file included from /Users/jasondwaku/Documents/FlutterProjects/ClubRoom/clubroom/ios/Pods/Target Support Files/firebase_core/firebase_core-umbrella.h:13:
In file included from /Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.7.0/ios/Classes/FLTFirebaseCorePlugin.h:11:
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.7.0/ios/Classes/FLTFirebasePlugin.h:9:9: error: include of non-modular header inside framework module 'firebase_core.FLTFirebasePlugin': '/Users/jasondwaku/Documents/FlutterProjects/ClubRoom/clubroom/ios/Pods/Headers/Public/FirebaseCore/FirebaseCore.h' [-Werror,-Wnon-modular-include-in-framework-module]
#import <FirebaseCore/FirebaseCore.h>
^
1 error generated.
/Users/jasondwaku/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-8.0.0-dev.15/ios/Classes/FLTFirebaseMessagingPlugin.m:6:9: fatal error: could not build module 'firebase_core'
#import <firebase_core/FLTFirebasePluginRegistry.h>
~~~~~~~^
2 errors generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Encountered error while building for simulator.
Process finished with exit code 1
我的 pub 规范如下所示
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
firebase_core: ^0.7.0
firebase_messaging: ^8.0.0-dev.15
cupertino_icons: ^1.0.0
shared_preferences: ^2.0.5
connectivity: ^3.0.3
modal_progress_hud: ^0.1.3
toggle_switch: ^0.1.8
font_awesome_flutter: ^9.0.0
implicitly_animated_reorderable_list: ^0.4.0
country_pickers: ^2.0.0
flutter_datetime_picker: ^1.5.1
intl: ^0.17.0
url_launcher: ^6.0.3
flappy_search_bar: ^1.7.2
package_info: ^2.0.0
image_picker: ^0.7.4
flutter_image_compress: ^1.0.0
mime: ^1.0.0
http_parser: ^4.0.0 #^3.1.4
http: ^0.13.0 #^0.12.2
provider: ^5.0.0
flutter_inappwebview: ^5.3.2
multi_select_flutter: ^4.0.0
device_info: ^2.0.0
overlay_support: ^1.2.1
rename: ^1.3.1
dev_dependencies:
flutter_driver:
sdk: flutter
flutter_test:
sdk: flutter
【问题讨论】:
【参考方案1】:最好新建一个 iOS 项目。删除或重命名 iOS 文件夹并运行以下命令。
扑干净 flutter create -i swift .【讨论】:
以上是关于尝试从 android studio 打开时,Xcode 中的 Flutter 打开模块会出错?的主要内容,如果未能解决你的问题,请参考以下文章
知道为啥我发布的 Android 应用在打开时会立即关闭吗?