bitpay / cordova-plugin-qrscanner

A fast, energy efficient, highly-configurable QR code scanner for Cordova apps and the browser.
MIT License
568 stars 772 forks source link

2.6.1 breaks build in Xcode 10.1 #238

Open AndreasGassmann opened 5 years ago

AndreasGassmann commented 5 years ago

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
cmgustavo commented 5 years ago

Thanks for reporting. I think that it 's related to the non-backward compatibility between Swift 5 and 3. I will check.

flipace commented 5 years ago

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?

BasMatthee commented 5 years ago

Could you maybe also update NPM? https://www.npmjs.com/package/cordova-plugin-qrscanner Still says latest version is 2.6.1.

cmgustavo commented 5 years ago

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!

BasMatthee commented 5 years ago

@cmgustavo Awesome. Thanks man!

oschwier commented 5 years ago

@cmgustavo Still getting the same error on 3.0.1 :-(

cmgustavo commented 5 years ago

@oschwier Try to add

<preference name="UseSwiftLanguageVersion" value="5" />

To your config.xml.

marcelobandeira commented 5 years ago

2.6.2 with Xcode 10.0 still getting the same error.

oschwier commented 5 years ago

@oschwier Try to add

<preference name="UseSwiftLanguageVersion" value="5" />

To your config.xml.

@cmgustavo No effect

hamrak commented 5 years ago

If you change UseSwiftLanguageVersion preference to value 5, you need to change "UIApplication.openSettingsURLString" to "UIApplicationOpenSettingsURLString" in QRScanner.swift file.

cmgustavo commented 5 years ago

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

MattRiddell commented 5 years ago

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.

hamrak commented 5 years ago

That's not correct.

'UIApplicationOpenSettingsURLString' has been renamed to 'UIApplication.openSettingsURLString'

for Swift 5

Yes, of course, but then there's something wrong.

maiolica commented 5 years ago

@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">

gesielrosa commented 5 years ago

It's work for me!

AndreasGassmann commented 5 years ago

I had to do the same as @gesielrosa to get it working.

evertdespiegeleer commented 5 years ago

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.

uklawitter commented 4 years ago

<preference` name="UseSwiftLanguageVersion" value="5" />

Worked for me. I use Xcode 10.2 and qrscanner Version 3.0.1

alexlarraga1 commented 4 years ago

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

stefano-8wave commented 4 years ago

@oschwier Try to add

<preference name="UseSwiftLanguageVersion" value="5" />

To your config.xml.

works for me

sushilsunuwar commented 4 years ago

nothing works me .........

sushilsunuwar commented 4 years ago

I tried everything but nothing works ...........

RoeelCohen commented 4 years ago

Build failed with the following versions: Xcode - 10.3 qrscanner - 3.0.1 Cordova - 9.0.0 (cordova-lib@9.0.1)

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```
cmgustavo commented 4 years ago

It doesn't work with cordova 9 for now. I think it requires a few changes to make it compatible.

phyr0s commented 4 years ago

fixed for me

Also you can install plugin cordova-plugin-add-swift-support or... maybe is better to add that plugin as dependency

dwengs commented 4 years ago

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 (cordova-lib@9.0.1)

joshstrangetp commented 4 years ago

Just for reference I got it working with:

QRScanner: 3.0.1 Cordova CLI: 8.1.1 (cordova-lib@8.1.0) 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.

jyqwq commented 4 years ago

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?