cordova-plugin-qrscanner
cordova-plugin-qrscanner copied to clipboard
2.6.1 breaks build in Xcode 10.1
We didn't lock the version of this plugin, so now with 2.6.1
the build is failing in Xcode 10.1.
Locking the version to 2.6.0
works, but this might still be something worth looking into.
/path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift:483:16: warning: unnecessary check for 'iOS'; enclosing scope ensures guard will always be true
if #available(iOS 8.0, *) {
^
/path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift:470:9: note: enclosing scope here
if #available(iOS 10.0, *) {
^
/path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift:38:42: error: type 'AVLayerVideoGravity' (aka 'NSString') has no member 'resizeAspectFill'
previewLayer!.videoGravity = AVLayerVideoGravity.resizeAspectFill
^~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
/path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift:124:57: error: incorrect argument label in call (have 'for:', expected 'forMediaType:')
let status = AVCaptureDevice.authorizationStatus(for: AVMediaType.video)
^~~~
forMediaType
/path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift:136:75: error: type 'AVMediaType' (aka 'NSString') has no member 'video'
let availableVideoDevices = AVCaptureDevice.devices(for: AVMediaType.video)
^~~~~~~~~~~ ~~~~~
/path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift:156:52: error: type 'AVMetadataObject.ObjectType' (aka 'NSString') has no member 'qr'
metaOutput!.metadataObjectTypes = [AVMetadataObject.ObjectType.qr]
^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
/path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift:241:26: error: type 'AVMetadataObject.ObjectType' (aka 'NSString') has no member 'qr'
if found.type == AVMetadataObject.ObjectType.qr && found.stringValue != nil {
^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
/path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift:257:57: error: incorrect argument label in call (have 'for:', expected 'forMediaType:')
let status = AVCaptureDevice.authorizationStatus(for: AVMediaType.video)
^~~~
forMediaType
/path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift:260:42: error: incorrect argument label in call (have 'for:completionHandler:', expected 'forMediaType:completionHandler:')
AVCaptureDevice.requestAccess(for: AVMediaType.video, completionHandler: { (granted) -> Void in
^~~~
forMediaType
/path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift:398:70: error: incorrect argument label in call (have 'for:', expected 'forMediaType:')
let authorizationStatus = AVCaptureDevice.authorizationStatus(for: AVMediaType.video);
^~~~
forMediaType
/path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift:471:63: error: 'openSettingsURLString' has been renamed to 'UIApplicationOpenSettingsURLString'
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
^~~~~~~~~~~~~~~~~~~~~
UIApplicationOpenSettingsURLString
UIKit.UIApplication:64:22: note: 'openSettingsURLString' was introduced in Swift 4.2
public class let openSettingsURLString: String
^
/path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift:484:74: error: 'openSettingsURLString' has been renamed to 'UIApplicationOpenSettingsURLString'
UIApplication.shared.openURL(NSURL(string: UIApplication.openSettingsURLString)! as URL)
^~~~~~~~~~~~~~~~~~~~~
UIApplicationOpenSettingsURLString
UIKit.UIApplication:64:22: note: 'openSettingsURLString' was introduced in Swift 4.2
public class let openSettingsURLString: String
^
** BUILD FAILED **
The following build commands failed:
CompileSwift normal x86_64 /path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
CompileSwift normal i386 /path/to/project/platforms/ios/app/Plugins/cordova-plugin-qrscanner/QRScanner.swift
(3 failures)
xcodebuild: Command failed with exit code 65
Thanks for reporting. I think that it 's related to the non-backward compatibility between Swift 5 and 3. I will check.
We have the same problem - i guess this latest release should have been a major one 🙈 Any chance this could be reverted, rereleased as 2.6.2 and a 3.0.0 with swift 5 support published?
Could you maybe also update NPM? https://www.npmjs.com/package/cordova-plugin-qrscanner Still says latest version is 2.6.1.
Plugin has been updated: https://www.npmjs.com/package/cordova-plugin-qrscanner
2.6.2 -> Compatible with XCode 10.1 or below
3.0.1 -> Compatible with Xcode 10.2 or higher
Thanks!
@cmgustavo Awesome. Thanks man!
@cmgustavo Still getting the same error on 3.0.1 :-(
@oschwier Try to add
<preference name="UseSwiftLanguageVersion" value="5" />
To your config.xml
.
2.6.2 with Xcode 10.0 still getting the same error.
@oschwier Try to add
<preference name="UseSwiftLanguageVersion" value="5" />
To your
config.xml
.
@cmgustavo No effect
If you change UseSwiftLanguageVersion preference to value 5, you need to change "UIApplication.openSettingsURLString" to "UIApplicationOpenSettingsURLString" in QRScanner.swift file.
If you change UseSwiftLanguageVersion preference to value 5, you need to change "UIApplication.openSettingsURLString" to "UIApplicationOpenSettingsURLString" in QRScanner.swift file.
That's not correct.
'UIApplicationOpenSettingsURLString' has been renamed to 'UIApplication.openSettingsURLString'
for Swift 5
I had the same problem, tried the <preference name="UseSwiftLanguageVersion" value="5" />
and no change. I changed the "UIApplication.openSettingsURLString" to "UIApplicationOpenSettingsURLString" in QRScanner.swift and it worked.
That's not correct.
'UIApplicationOpenSettingsURLString' has been renamed to 'UIApplication.openSettingsURLString'
for Swift 5
Yes, of course, but then there's something wrong.
@oschwier Try to add
<preference name="UseSwiftLanguageVersion" value="5" />
To your
config.xml
.
Tried, it's working for me, I've put the line inside
<platform name="ios">
- Update plugin for 3.0.1 version.
- "UIApplication.openSettingsURLString" to "UIApplicationOpenSettingsURLString" in QRScanner.swift file.
It's work for me!
I had to do the same as @gesielrosa to get it working.
I submitted pull request #248 to resolve this.
I recognise it should be UIApplication.openSettingsURLString
for Swift 5, but everyone seems to have the same problem and the same solution.
<preference` name="UseSwiftLanguageVersion" value="5" />
Worked for me. I use Xcode 10.2 and qrscanner Version 3.0.1
I had the same problem, tried the
<preference name="UseSwiftLanguageVersion" value="5" />
and no change. I changed the "UIApplication.openSettingsURLString" to "UIApplicationOpenSettingsURLString" in QRScanner.swift and it worked.
That's works for me, but first run cordova platform rm ios
@oschwier Try to add
<preference name="UseSwiftLanguageVersion" value="5" />
To your
config.xml
.
works for me
nothing works me .........
I tried everything but nothing works ...........
Build failed with the following versions: Xcode - 10.3 qrscanner - 3.0.1 Cordova - 9.0.0 ([email protected])
Fixed in config.xml using:
<preference name="SwiftVersion" value="5" />
The Error:
if #available(iOS 8.0, *) {
^
/path/platforms/ios/HelloCordova/Plugins/cordova-plugin-qrscanner/QRScanner.swift:470:9: note: enclosing scope here
if #available(iOS 10.0, *) {
^
/path/platforms/ios/HelloCordova/Plugins/cordova-plugin-qrscanner/QRScanner.swift:136:62: warning: 'devices(for:)' was deprecated in iOS 10.0: Use AVCaptureDeviceDiscoverySession instead.
let availableVideoDevices = AVCaptureDevice.devices(for: AVMediaType.video)
^
/path/platforms/ios/HelloCordova/Plugins/cordova-plugin-qrscanner/QRScanner.swift:471:63: error: 'openSettingsURLString' has been renamed to 'UIApplicationOpenSettingsURLString'
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
^~~~~~~~~~~~~~~~~~~~~
UIApplicationOpenSettingsURLString
UIKit.UIApplication:64:22: note: 'openSettingsURLString' was introduced in Swift 4.2
public class let openSettingsURLString: String
^
/path/platforms/ios/HelloCordova/Plugins/cordova-plugin-qrscanner/QRScanner.swift:484:74: error: 'openSettingsURLString' has been renamed to 'UIApplicationOpenSettingsURLString'
UIApplication.shared.openURL(NSURL(string: UIApplication.openSettingsURLString)! as URL)
^~~~~~~~~~~~~~~~~~~~~
UIApplicationOpenSettingsURLString
UIKit.UIApplication:64:22: note: 'openSettingsURLString' was introduced in Swift 4.2
public class let openSettingsURLString: String
^
** BUILD FAILED **
The following build commands failed:
CompileSwift normal x86_64 /path/platforms/ios/HelloCordova/Plugins/cordova-plugin-qrscanner/QRScanner.swift
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(2 failures)
xcodebuild: Command failed with exit code 65```
It doesn't work with cordova
9 for now. I think it requires a few changes to make it compatible.
fixed for me
Also you can install plugin cordova-plugin-add-swift-support or... maybe is better to add that plugin as dependency
I had the same problem, tried the
<preference name="UseSwiftLanguageVersion" value="5" />
and no change. I changed the "UIApplication.openSettingsURLString" to "UIApplicationOpenSettingsURLString" in QRScanner.swift and it worked.
This worked for me. QRScanner 3.0.1 Cordova 9.0.0 ([email protected])
Just for reference I got it working with:
QRScanner: 3.0.1
Cordova CLI: 8.1.1 ([email protected])
Cordova Platforms: ios 5.1.1
WITH: "UIApplication.openSettingsURLString" to "UIApplicationOpenSettingsURLString" in QRScanner.swift
WITHOUT: <preference name="UseSwiftLanguageVersion" value="5" />
You might need to rm/add ios again to get to a clean slate.
The following build commands failed: CompileSwift normal x86_64 /Users/jiyuan/Desktop/project/cordova/admin/platforms/ios/xgAdmin/Plugins/cordova-plugin-qrscanner/QRScanner.swift CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (2 failures) xcodebuild: Command failed with exit code 65
I had the problem too,has anyone solved the problem?