rhymelph / r_scan

📷🖨Flutter二维码&条形码扫描插件,支持相机、文件、链接、Uint8List类型扫描
https://juejin.im/post/5dd8efb1e51d452314438515
BSD 3-Clause "New" or "Revised" License
119 stars 79 forks source link

Flutter2.0 error on iOS #47

Closed anchao-lu closed 3 years ago

anchao-lu commented 3 years ago

flutter_app/ios/Runner/GeneratedPluginRegistrant.m:128:9: fatal error: could not build module 'r_scan'

anchao-lu commented 3 years ago

完整的 log Launching lib/main.dart on iPhone 12 Pro Max in debug mode... Running Xcode build... Xcode build done. 11.7s Failed to build iOS app Error output from Xcode build: ↳ BUILD FAILED

Xcode's output: ↳ While building module 'r_scan' imported from /Users/monkey/Desktop/flutter_app/ios/Runner/GeneratedPluginRegistrant.m:128: In file included from :1: In file included from /Users/monkey/Desktop/flutter_app/build/ios/Debug-iphonesimulator/r_scan/r_scan.framework/Headers/r_scan-umbrella.h:16: /Users/monkey/Desktop/flutter_app/build/ios/Debug-iphonesimulator/r_scan/r_scan.framework/Headers/RScanResult.h:10:9: error: include of non-modular header inside framework module 'r_scan.RScanResult': '/Users/monkey/Desktop/flutter_app/build/ios/Debug-iphonesimulator/ZXingObjC/ZXingObjC.framework/Headers/ZXingObjC.h' [-Werror,-Wnon-modular-include-in-framework-module]

import "ZXingObjC.h"

        ^
/Users/monkey/Desktop/flutter_app/build/ios/Debug-iphonesimulator/r_scan/r_scan.framework/Headers/RScanResult.h:11:9: error: include of non-modular header inside framework module 'r_scan.RScanResult': '/Users/monkey/Desktop/flutter_app/build/ios/Debug-iphonesimulator/ZBarSDK/ZBarSDK.framework/Headers/ZBarSDK.h' [-Werror,-Wnon-modular-include-in-framework-module]
#import "ZBarSDK.h"
        ^
While building module 'r_scan' imported from /Users/monkey/Desktop/flutter_app/ios/Runner/GeneratedPluginRegistrant.m:128:
In file included from <module-includes>:1:
In file included from /Users/monkey/Desktop/flutter_app/build/ios/Debug-iphonesimulator/r_scan/r_scan.framework/Headers/r_scan-umbrella.h:16:
In file included from /Users/monkey/Desktop/flutter_app/build/ios/Debug-iphonesimulator/r_scan/r_scan.framework/Headers/RScanResult.h:11:
In file included from /Users/monkey/Desktop/flutter_app/build/ios/Debug-iphonesimulator/ZBarSDK/ZBarSDK.framework/Headers/ZBarSDK.h:34:
/Users/monkey/Desktop/flutter_app/build/ios/Debug-iphonesimulator/ZBarSDK/ZBarSDK.framework/Headers/ZBarCameraSimulator.h:37:5: warning: 'UIPopoverController' is deprecated: first deprecated in iOS 9.0 - UIPopoverController is deprecated. Popovers are now implemented as UIViewController presentations. Use a modal presentation style of UIModalPresentationPopover and UIPopoverPresentationController. [-Wdeprecated-declarations]
    UIPopoverController *pickerPopover;
    ^
In module 'UIKit' imported from /Users/monkey/Desktop/flutter_app/build/ios/Debug-iphonesimulator/r_scan/r_scan.framework/Headers/r_scan-umbrella.h:2:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIPopoverController.h:26:12: note: 'UIPopoverController' has been explicitly marked deprecated here
@interface UIPopoverController : NSObject <UIAppearanceContainer> {}
           ^
1 warning and 2 errors generated.
/Users/monkey/Desktop/flutter_app/ios/Runner/GeneratedPluginRegistrant.m:128:9: fatal error: could not build module 'r_scan'
#import <r_scan/RScanPlugin.h>
 ~~~~~~~^
1 warning and 3 errors generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description

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

NateWilliams2 commented 3 years ago

I'm getting this exact same error, but using Flutter 1.22.5. It worked fine a week or two ago when I last built for iOS.

tpc707494 commented 3 years ago

这个是一样的报错信息 Error output from Xcode build: ↳ BUILD FAILED

Xcode's output: ↳ While building module 'r_scan' imported from /Users/tpc/Desktop/t/ttt/ios/Runner/GeneratedPluginRegistrant.m:56: In file included from :1: In file included from /Users/tpc/Desktop/t/ttt/build/ios/Debug-iphonesimulator/r_scan/r_scan.framework/Headers/r_scan-umbrella.h:16: /Users/tpc/Desktop/t/ttt/build/ios/Debug-iphonesimulator/r_scan/r_scan.framework/Headers/RScanResult.h:10:9: error: include of non-modular header inside framework module 'r_scan.RScanResult': '/Users/tpc/Desktop/t/ttt/build/ios/Debug-iphonesimulator/ZXingObjC/ZXingObjC.framework/Headers/ZXingObjC.h' [-Werror,-Wnon-modular-include-in-framework-module]

import "ZXingObjC.h"

        ^
/Users/tpc/Desktop/t/ttt/build/ios/Debug-iphonesimulator/r_scan/r_scan.framework/Headers/RScanResult.h:11:9: error: include of non-modular header inside framework
module 'r_scan.RScanResult': '/Users/tpc/Desktop/t/ttt/build/ios/Debug-iphonesimulator/ZBarSDK/ZBarSDK.framework/Headers/ZBarSDK.h'
[-Werror,-Wnon-modular-include-in-framework-module]
#import "ZBarSDK.h"
        ^
While building module 'r_scan' imported from /Users/tpc/Desktop/t/ttt/ios/Runner/GeneratedPluginRegistrant.m:56:
In file included from <module-includes>:1:
In file included from /Users/tpc/Desktop/t/ttt/build/ios/Debug-iphonesimulator/r_scan/r_scan.framework/Headers/r_scan-umbrella.h:16:
In file included from /Users/tpc/Desktop/t/ttt/build/ios/Debug-iphonesimulator/r_scan/r_scan.framework/Headers/RScanResult.h:11:
In file included from /Users/tpc/Desktop/t/ttt/build/ios/Debug-iphonesimulator/ZBarSDK/ZBarSDK.framework/Headers/ZBarSDK.h:34:
/Users/tpc/Desktop/t/ttt/build/ios/Debug-iphonesimulator/ZBarSDK/ZBarSDK.framework/Headers/ZBarCameraSimulator.h:37:5: warning: 'UIPopoverController' is
deprecated: first deprecated in iOS 9.0 - UIPopoverController is deprecated. Popovers are now implemented as UIViewController presentations. Use a modal
presentation style of UIModalPresentationPopover and UIPopoverPresentationController. [-Wdeprecated-declarations]
    UIPopoverController *pickerPopover;
    ^
In module 'UIKit' imported from /Users/tpc/Desktop/t/ttt/build/ios/Debug-iphonesimulator/r_scan/r_scan.framework/Headers/r_scan-umbrella.h:2:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.3.sdk/System/Library/Frameworks/UIKit.framework/Head
ers/UIPopoverController.h:26:12: note: 'UIPopoverController' has been explicitly marked deprecated here
@interface UIPopoverController : NSObject <UIAppearanceContainer> {}
           ^
1 warning and 2 errors generated.
/Users/tpc/Desktop/t/ttt/ios/Runner/GeneratedPluginRegistrant.m:56:9: fatal error: could not build module 'r_scan'
#import <r_scan/RScanPlugin.h>
 ~~~~~~~^
1 warning and 3 errors generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a
development team in the Runner editor. (in target 'Runner' from project 'Runner')

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

tpc707494 commented 3 years ago

这个是版本信息,不不是flutter2,也报这个 Flutter 1.26.0-2.0.pre.401 • channel unknown • unknown source Framework • revision da5a454d5c (8 weeks ago) • 2021-01-17 01:24:03 -0500 Engine • revision 609036f2bf Tools • Dart 2.12.0 (build 2.12.0-236.0.dev)

navyzhou926 commented 3 years ago

已解决fatal error: could not build module 'r_scan'

找到r_scan的pubspec.yaml文件 1、注释掉flutter: ">=1.12.0 <2.0.0" 2、platforms修改为 androidPackage: com.rhyme.r_scan pluginClass: RScanPlugin 3、clean工程,再次编译即可 4、再不会就随便找一个可以用的其它plugin,对比修改一下即可

navyzhou926 commented 3 years ago

再补充几条: 1、r_scan/ios/r_scan.podspec文件ZXingObjC引用修改为:s.dependency 'ZXingObjC' 2、源码中所有的头文件引用修改为:

import <ZBarSDK/ZBarSDK.h>

import <ZXingObjC/ZXingObjC.h>

3、去用吧,good luck

navyzhou926 commented 3 years ago

android我直接引用没有什么问题,ios需要按照上述修改后,用本地插件的方式引用到工程中,明显作者对于ios引用此插件的兼容性没有做过多的测试,大部分使用者,ios估计是直接报错,大家要给作者加油打气,维护好此插件

anchao-lu commented 3 years ago

已经换了其他插件,作者 null safety 好像都不打算维护了

navyzhou926 commented 3 years ago

已经换了其他插件,作者 null safety 好像都不打算维护了

你用的哪个插件,我测试的目前较多star的插件,要么只支持android,要么扫描效果不是很好。这个插件虽然作者可能不维护了,我底层修改一些代码后,还是比较稳定的

rhymelph commented 3 years ago

v0.1.6