Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build iOS app - 'openSettingsURLString' has been renamed to 'UIApplicationOpenSettingsURLString' #301

Closed
adamayoung opened this issue Jan 30, 2020 · 12 comments

Comments

@adamayoung
Copy link

adamayoung commented Jan 30, 2020

I cannot build an iOS app with this plugin. I get the following errors:

                                                   ^
/Users/xxx/MyProject/platforms/ios/MyProject/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:70:22: note: 'openSettingsURLString' was introduced in Swift 4.2
    public class let openSettingsURLString: String
                     ^
/Users/xxx/MyProject/platforms/ios/MyProject/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:70: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 /Users/xxx/MyProject/platforms/ios/MyProject/Plugins/cordova-plugin-qrscanner/QRScanner.swift
        CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(2 failures)
Command finished with error code 65: xcodebuild -workspace,MyProject.xcworkspace,-scheme, MyProject,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,name=iPhone 11 Pro Max,build,CONFIGURATION_BUILD_DIR=/Users/xxx/MyProject/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/xxx/MyProject/platforms/ios/build/sharedpch,EMBEDDED_CONTENT_CONTAINS_SWIFT = YES,ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO,LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"
xcodebuild: Command failed with exit code 65
Error: xcodebuild: Command failed with exit code 65
    at ChildProcess.whenDone (/Users/xxx/MyProject/node_modules/cordova-common/src/superspawn.js:135:23)
    at ChildProcess.emit (events.js:321:20)
    at maybeClose (internal/child_process.js:1026:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
[ERROR] An error occurred while running subprocess cordova.
@florian-diatelic
Copy link

florian-diatelic commented Jan 30, 2020

Yes, it's an known issue. Change UIApplication.openSettingsURLString to UIApplicationOpenSettingsURLString

@adamayoung
Copy link
Author

Are you planning on fixing this in a new release anytime soon? Making the above change isn't going to help when I do a CI build of the app.

@jamesopppp
Copy link

Same question

@hanov-paycasso
Copy link

hanov-paycasso commented Feb 3, 2020

Yes, it's an known issue. Change UIApplication.openSettingsURLString to UIApplicationOpenSettingsURLString

You can workaround this issue by typing next command in the root of the project:
find . -type f -name "*.swift" -print0 | xargs -0 sed -i '' -e 's/UIApplication.openSettingsURLString/UIApplicationOpenSettingsURLString/g'

@florian-diatelic
Copy link

florian-diatelic commented Feb 3, 2020

Are you planning on fixing this in a new release anytime soon? Making the above change isn't going to help when I do a CI build of the app.

Yes, there is several pull requests to fix it like 106abbd . We only wait that it is approved, merged and released by creator. You can fork and doing it

@danielzen
Copy link

danielzen commented Mar 28, 2020

I have given up on waiting for this to be fixed. I have created a substitute for the npm package using @markterrill code (Refer #271). If you want to try it run:

npm uninstall cordova-plugin-qrscanner
npm install git+https://git@github.com/danielzen/cordova-plugin-qrscanner

Hope it works for you...

@markterrill
Copy link

markterrill commented Mar 30, 2020

Cheers @danielzen !

Thanks for the reminder re npm install from git, that'll be very helpful to a lot of folk reading this thread.

Mark

@danielzen
Copy link

Now that I have updated to Swift 5, I understand why @markterrill's code was not accepted. Perhaps it is better to set swift5 in Cordova or Capacitor (as I did)?

In cordova use: https://www.npmjs.com/package/cordova-plugin-add-swift-support

In capacitor set cordovaSwiftVersion: https://capacitor.ionicframework.com/docs/basics/configuring-your-app/

I'm leaving my Swift 3 version at https://github.com/danielzen/cordova-plugin-qrscanner in the meantime, but I no longer recommend it. Hope this helps.

@ChiKaLiO
Copy link

ChiKaLiO commented Dec 5, 2020

srsly it has been almost a year now !

@terryjiang2020
Copy link

Is this closed because it is fixed?

@danielzen
Copy link

I recommend looking at:

based on

It has updates that are working for me....

@mdledoux
Copy link

mdledoux commented Jun 6, 2023

Is this closed because it is fixed?

@terryjiang2020 - closed because there is nothing to fix - it is not a bug - your Cordova iOS settings need to use Swift 5 (at least 4.2, but definitely not 3) and the plugin will work fine.
See @danielzen's comment above on May 18, 2020 - also, see my comment from July 2021 on this similar issue for more help/details <-- I believe this holds the answer you are looking for.

I'm assuming you have an older project, so you probably need an older fix - this was the solution nearly 2 years ago.
But @danielzen's recent comment on April 14 may offer more something more current (but I suspect he's using Swift 5 now, so hence how it works for him - just guessing). I still maintain that a "fix" to the plugin was never needed - just update your project's Swift version (under Cordova settings for iOS), and the newer qrscanner plugin should just work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants