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 find 'UNNotificationInterruptionLevel' in scope #1722

Closed
ziobudda opened this issue Sep 26, 2022 · 4 comments
Closed

cannot find 'UNNotificationInterruptionLevel' in scope #1722

ziobudda opened this issue Sep 26, 2022 · 4 comments

Comments

@ziobudda
Copy link

Describe the bug
The main.dart example on pub.dev does not works with these error:

Command MergeSwiftModule failed with a nonzero exit code
Command CompileSwift failed with a nonzero exit code
/Volumes/LAVORI CRUCIAL/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_local_notifications-11.0.1/macos/Classes/FlutterLocalNotificationsPlugin.swift:512:45: error: cannot find 'UNNotificationInterruptionLevel' in scope
                content.interruptionLevel = UNNotificationInterruptionLevel.init(rawValue: rawInterruptionLevel)!
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
** BUILD FAILED **

To Reproduce

  1. flutter create myproject
  2. copy main.dart from "example page" on pub.dev
  3. replace lib/main.dart with the code gets from example page.
  4. flutter pub add device_info_plus flutter_local_notifications flutter_native_timezone path_provider timezone
  5. exec 'flutter run' and choice macos

My system
Flutter 3.0.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f1875d570e (3 months ago) • 2022-07-13 11:24:16 -0700
Engine • revision e85ea0e79c
Tools • Dart 2.17.6 • DevTools 2.12.2
osx 11.6.1
xcode Version 12.5.1

@MaikuB
Copy link
Owner

MaikuB commented Sep 26, 2022

I believe this is because of the version of Xcode you're using. The API the code is referring to is in OS versions that are newer than the Xcode version you have. See https://developer.apple.com/documentation/usernotifications/unnotificationinterruptionlevel

@ziobudda
Copy link
Author

Hi, but the error is in this code:

if #available(macOS 12.0, *) {
              if let rawInterruptionLevel = platformSpecifics[MethodCallArguments.interruptionLevel] as? UInt {
                content.interruptionLevel = UNNotificationInterruptionLevel.init(rawValue: rawInterruptionLevel)!
              }
            }

Inside an IF that check if there is the availability of macOS12. Is not this strange ?

So, you say me that I can use your plugin only if I have +macOS12 ? And will my app only be usable only on +macos12 ?

@MaikuB
Copy link
Owner

MaikuB commented Sep 26, 2022

I know what you're saying and note I'm don't follow the Apple development ecosystem as closely, however this is the only explanation I can think of given that there's already meant to be a guard in there like you pointed out. Furthermore the example app referencing code compiles on build servers hosted by others

@MaikuB
Copy link
Owner

MaikuB commented Oct 4, 2022

Closing this as there's not much more advice I can give. Should clarify that one I wrote above is more about the version of Xcode used compile the app. It isn't about the version of macOS though XCode will have requirements on the macOS versions it's compatible with. This is to do with requirements enforced by Apple than the plugin The plugin should still work on macOS versions older than 12. I assume the issue is because if you use an older version of XCode then it won't know about APIs added later on given the SDKs bundled with it.

@MaikuB MaikuB closed this as completed Oct 4, 2022
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

2 participants