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

MacOS Permission problem in VSCode #114352

Open
berkobob opened this issue Oct 31, 2022 · 15 comments
Open

MacOS Permission problem in VSCode #114352

berkobob opened this issue Oct 31, 2022 · 15 comments
Labels
e: device-specific Only manifests on certain devices engine flutter/engine repository. See also e: labels. found in release: 3.3 Found to occur in 3.3 found in release: 3.4 Found to occur in 3.4 P2 Important issues not at the top of the work list platform-mac Building on or for macOS specifically team-engine Owned by Engine team triaged-engine Triaged by Engine team

Comments

@berkobob
Copy link

I am writing a simple plugin to read, write, edit & delete Apple Reminders. The first thing I do is request access to reminders:

eventStore.requestAccess(to: EKEntityType.reminder, completion: {(granted, error) in 
            if let error = error { print(error) }
            self.hasAccess = granted ? true : false
            })

When I run my app from the terminal (iTerm) using flutter run -d macOS a window popped up to allow me to grant access to my Reminders. If I build the app and run the executable it also works. When I run my app from within VSCode, either using Debug or the VSCode terminal, the permission window does not appear and my app fails to get permission. I'm thinking this is a VSCode issue as it works everywhere else.

I have the same problem on my M1 MacStudio and my Intel MacBook Pro.

How do I grant access to my Reminders to VSCode?

flutter doctor -v [✓] Flutter (Channel stable, 3.3.6, on macOS 13.0 22A380 darwin-arm, locale en-GB) • Flutter version 3.3.6 on channel stable at /Users/antoine/library/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 6928314 (6 days ago), 2022-10-25 16:34:41 -0400 • Engine revision 3ad69d7be3 • Dart version 2.18.2 • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/antoine/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14A400
• CocoaPods version 1.11.3

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.72.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.50.0

[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.0 22A380 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.87

[✓] HTTP Host Availability
• All required HTTP hosts are available

• No issues found!

VSCode Version

@exaby73 exaby73 added the in triage Presently being triaged by the triage team label Nov 1, 2022
@exaby73
Copy link
Member

exaby73 commented Nov 1, 2022

Hello @berkobob. Thank you for filing this issue. Can you please provide the following information?

Please provide the information in the form of text. See how to make collapsible sections with Markdown here.

@exaby73 exaby73 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 1, 2022
@berkobob
Copy link
Author

berkobob commented Nov 2, 2022

Here is a public repo. I've included the absolute minimum necessary to reproduce the error but as this is a plugin, there is more than main.dart. main.dart is in the example/lib folder: https://github.com/berkobob/example

The output from flutter run -v is over 2.5K lines long so I'm attaching a text file instead of collapsible text. I hope that's OK. Let me know if you still need me to cut and paste:

run-v.txt

Screenshot when run from VSCode:
Screenshot when run from VSCode

And this is the exact same code being run from the terminal (iTerm2):
Screenshot when run from terminal

I don't know if you need this but here it the output from 'flutter run -v' when run from the terminal:
run-v-from-terminal.txt

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 2, 2022
@exaby73
Copy link
Member

exaby73 commented Nov 2, 2022

I cannot reproduce this issue. I can see true when running the app from VSCode

@exaby73 exaby73 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 2, 2022
@berkobob
Copy link
Author

berkobob commented Nov 2, 2022

Can I ask you some questions then:

  1. How are you running the app within VSCode? I've used the builtin configurations including Flutter (macos), Flutter (profile mode), Flutter (release mode), Example, Example (profile mode), Example (release mode) and I've tried the terminal within VS Code and nothing works.

  2. Did you get a popup asking you for permission to access your calendar?

  3. If you look in the Reminders section of Privacy & Security, do you have VS Code as an option.

Screenshot 2022-11-02 at 11 49 25

As you can see, I have iTerm switched on and the app works well from iTerm but not from VS Code?

  1. Do you know if there's a way to reset VSCode's permissions or even give it permission to access Reminders?

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 2, 2022
@exaby73
Copy link
Member

exaby73 commented Nov 2, 2022

Yes Visual Studio Code is showing up in this list, with it switched on. Looks like this issue is with VSCode not with Flutter directly.

Please see https://flutter.dev/community for resources and asking questions like this,
you may also get some help if you post it on Stack Overflow and if you need help with your code, please see https://www.reddit.com/r/flutterhelp/. Alternatively, you can raise an issue in the vscode repo
Closing, as this isn't an issue with Flutter itself. If you disagree, please write in the comments and I will reopen it.
Thank you

@exaby73 exaby73 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2022
@exaby73 exaby73 added r: invalid Issue is closed as not valid and removed in triage Presently being triaged by the triage team labels Nov 2, 2022
@berkobob
Copy link
Author

berkobob commented Nov 3, 2022

Just before you close this issue, I think this repo is the right place to log issues with the Flutter extension for VSCode team. Is it possible for them to take a quick look please. Thanks.

@exaby73
Copy link
Member

exaby73 commented Nov 3, 2022

@DanTup Do you have any insights about this that I may have missed?

@exaby73 exaby73 reopened this Nov 3, 2022
@exaby73 exaby73 added in triage Presently being triaged by the triage team and removed r: invalid Issue is closed as not valid labels Nov 3, 2022
@DanTup
Copy link
Contributor

DanTup commented Nov 3, 2022

I was able to reproduce this on my M1 MacBook. I was able to force the permission prompt by pasting this into the built-in VS Code terminal:

osascript - title <<END
on run a
tell app "Reminders"
tell list "Reminders" of default account
make new reminder with properties {name:item 1 of a}
end
end
end
END

(I got this from https://apple.stackexchange.com/questions/66981/how-can-i-add-reminders-via-the-command-line).

That triggered the prompt and after accepting, running the app now shows it has permission. I'm not sure why the code in the app isn't triggering the prompt with the call to EKEventStore().requestAccess() though.

@berkobob
Copy link
Author

berkobob commented Nov 3, 2022

Thanks so much Dan. Much appreciated! Kudos.

@berkobob berkobob closed this as completed Nov 3, 2022
@exaby73
Copy link
Member

exaby73 commented Nov 4, 2022

@DanTup Just to confirm, is this a Vscode issue or a Flutter issue?

@exaby73 exaby73 reopened this Nov 4, 2022
@DanTup
Copy link
Contributor

DanTup commented Nov 4, 2022

@exaby73 I don't know a lot about it, but it feels to me like the issue is on macOS or in the SDK used by the swift code in the app. The code was clearly asking for access to Reminders but macOS was never showing a prompt, nor adding the app to the Reminders section in the Security&Privacy section. For some reason, running a script that tries to access reminders from the terminal does trigger the prompt, allowing permission to be granted.

I don't think it's a VS Code (or Dart-Code) issue. I suspect it's not a Flutter issue, but I couldn't be sure. It's possible something about how Flutter is building the macOS app is preventing that permissions prompt (or something specific about that example app), but I don't know much about how that works. I just did some searching and found this similar issue that was caused by not having a CFBundleDisplayName name set, so maybe it's something similar to that? 🤔

@exaby73
Copy link
Member

exaby73 commented Nov 4, 2022

I'll label this issue for further investigation and insights. Thank you :)

@exaby73 exaby73 added e: device-specific Only manifests on certain devices engine flutter/engine repository. See also e: labels. platform-mac Building on or for macOS specifically found in release: 3.3 Found to occur in 3.3 found in release: 3.4 Found to occur in 3.4 labels Nov 4, 2022
@exaby73 exaby73 removed the in triage Presently being triaged by the triage team label Nov 4, 2022
@chinmaygarde chinmaygarde added the P2 Important issues not at the top of the work list label Nov 7, 2022
@kingvhit
Copy link

Has same issue when running on Android Studio.

Just run by command-line or dirrectly from xcode will work fine. Otherwise, run from Android Studio - Run button has no effect (no permission request)

@flutter-triage-bot flutter-triage-bot bot added team-engine Owned by Engine team triaged-engine Triaged by Engine team labels Jul 8, 2023
@muknta
Copy link

muknta commented Mar 19, 2024

I have the same issue.
MacBook Pro 2021 16"
Macos Sonoma 14.3.1

Macos builds from Android Studio and console are not showing the permission dialog on my machine.
Macos build from Xcode 15 works fine every time.

UPD: I am wrong, requests for permissions are going from Android Studio and Terminal, but they are linked to Android Studio and Terminal accordingly in the Privacy&Security list

@muknta
Copy link

muknta commented Mar 22, 2024

solved locally:
Issue was observed in non-sandbox Macos build. Entitlements file with permissions was not recognized using custom build notarizing.
So issue solves if we either move to Macos sandbox, or pass the entitlements to custom notirizing command in CI/CD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e: device-specific Only manifests on certain devices engine flutter/engine repository. See also e: labels. found in release: 3.3 Found to occur in 3.3 found in release: 3.4 Found to occur in 3.4 P2 Important issues not at the top of the work list platform-mac Building on or for macOS specifically team-engine Owned by Engine team triaged-engine Triaged by Engine team
Projects
None yet
Development

No branches or pull requests

6 participants