cordova-plugin-qrscanner icon indicating copy to clipboard operation
cordova-plugin-qrscanner copied to clipboard

2.6.1 breaks build in Xcode 10.1

Open AndreasGassmann opened this issue 5 years ago • 28 comments

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

AndreasGassmann avatar Mar 28 '19 12:03 AndreasGassmann

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

cmgustavo avatar Mar 28 '19 12:03 cmgustavo

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?

flipace avatar Mar 28 '19 13:03 flipace

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

BasMatthee avatar Mar 29 '19 07:03 BasMatthee

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 avatar Mar 29 '19 16:03 cmgustavo

@cmgustavo Awesome. Thanks man!

BasMatthee avatar Apr 01 '19 07:04 BasMatthee

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

oschwier avatar Apr 01 '19 10:04 oschwier

@oschwier Try to add

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

To your config.xml.

cmgustavo avatar Apr 01 '19 12:04 cmgustavo

2.6.2 with Xcode 10.0 still getting the same error.

marcelobandeira avatar Apr 02 '19 13:04 marcelobandeira

@oschwier Try to add

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

To your config.xml.

@cmgustavo No effect

oschwier avatar Apr 02 '19 13:04 oschwier

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

hamrak avatar Apr 04 '19 05:04 hamrak

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

cmgustavo avatar Apr 05 '19 13:04 cmgustavo

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.

MattRiddell avatar Apr 07 '19 20:04 MattRiddell

That's not correct.

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

for Swift 5

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

hamrak avatar Apr 08 '19 06:04 hamrak

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

maiolica avatar Apr 10 '19 11:04 maiolica

  • Update plugin for 3.0.1 version.
  • "UIApplication.openSettingsURLString" to "UIApplicationOpenSettingsURLString" in QRScanner.swift file.

It's work for me!

gesielrosa avatar Apr 18 '19 12:04 gesielrosa

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

AndreasGassmann avatar Apr 19 '19 09:04 AndreasGassmann

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.

evertdespiegeleer avatar Apr 21 '19 15:04 evertdespiegeleer

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

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

uklawitter avatar May 21 '19 18:05 uklawitter

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

alexlarraga1 avatar Jun 19 '19 20:06 alexlarraga1

@oschwier Try to add

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

To your config.xml.

works for me

stefano-8wave avatar Aug 09 '19 10:08 stefano-8wave

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

sushilsunuwar avatar Aug 21 '19 07:08 sushilsunuwar

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

sushilsunuwar avatar Aug 21 '19 07:08 sushilsunuwar

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```

RoeelCohen avatar Aug 22 '19 07:08 RoeelCohen

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

cmgustavo avatar Aug 22 '19 12:08 cmgustavo

fixed for me

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

phyr0s avatar Dec 27 '19 19:12 phyr0s

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])

dwengs avatar Jan 06 '20 08:01 dwengs

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.

joshstrangetp avatar Feb 10 '20 15:02 joshstrangetp

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?

jyqwq avatar Mar 19 '20 08:03 jyqwq