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 support #471

Open
wants to merge 82 commits into
base: develop
Choose a base branch
from
Open

macOS support #471

wants to merge 82 commits into from

Conversation

IVLIVS-III
Copy link
Contributor

This PR adds macOS as a supported platform.

Closes #409.

As discussed on #466 we want to have a unified codebase for both iOS and macOS.
In this PR is heavily based on #466 but makes the changes necessary for a shared swift source.

The example app runs now both on iOS and macOS, with full feature support on both platforms.

nickrandolph and others added 25 commits May 13, 2021 13:47
Timezone implementation and fixes
Fixed fullDay with DateRange events creation (not only one fullday events possible to create)
Timezone should be set only if event is not full day
The example app runs now and can interact with the device calendar :)
This regression was introduced when unifying the swift code with macOS.
@IVLIVS-III IVLIVS-III requested a review from thomassth February 9, 2023 05:06
@IVLIVS-III
Copy link
Contributor Author

@thomassth Do you mind looking at this if you have some spare time?

Should this be a 4.4.0 release or bundled in the big 5.0?

@thomassth
Copy link
Contributor

I wasn't able to get any calendar details when running example app in MacOS

@IVLIVS-III
Copy link
Contributor Author

IVLIVS-III commented Feb 15, 2023

I wasn't able to get any calendar details when running example app in MacOS

What do you mean by calendar details? Events in that calendar, calendar name, calendar color, readonly/read/write state of the calendar, or something different?

Edit: Did you make sure, that calendar access was enabled in AppSandbox in the example app (macOS) in XCode?

@IVLIVS-III
Copy link
Contributor Author

I've created a shell command that can be run once from within the integrated terminal in Android Studio / VS Code / another IDE.
Afterwards, launching the macOS app from within the IDE should work with permissions set.

tccutil reset Calendar $(mdls -name kMDItemCFBundleIdentifier "$(mdfind "kMDItemFSName == '$(ps -o comm= -p $(ps -o ppid= -p $$) | awk -F'.app' '{print $1".app"}' | awk -F'/' '{print $NF}')'" | head -n 1)" | sed 's/.*= "\(.*\)"/\1/') && osascript -e 'tell application "Calendar" to get the name of every calendar'
Command explanation (click me)

In the following explanation <<i>> is a placeholder for the command from step i verbatim:

  1. ps -o comm= -p $(ps -o ppid= -p $$)
    Detects which executable hosts the integrated terminal, e.g. /Applications/Android Studio.app/Contents/MacOS/studio

  2. <<1>> | awk -F'.app' '{print $1".app"}' | awk -F'/' '{print $NF}'
    Extracts the application name (IDE), e.g Android Studio.app

  3. mdfind "kMDItemFSName == '$(<<2>>)'" | head -n 1
    Finds the application path, e.g. /Applications/Android Studio.app

Note: For VS Code the host executable path does not start with the application path, hence we need steps 2 and 3 instead of just truncating the output from step 1.

  1. mdls -name kMDItemCFBundleIdentifier "$(<<3>>)"
    Finds the application bundle identifier, e.g. kMDItemCFBundleIdentifier = "com.google.android.studio"

  2. <<4>> | sed 's/.*= "\(.*\)"/\1/'
    Extracts the application bundle identifier, e.g. com.google.android.studio

  3. tccutil reset Calendar $(mdls -name kMDItemCFBundleIdentifier "$(<<5>>)
    Resets the calendar permissions for the IDE

  4. <<6>> && osascript -e 'tell application "Calendar" to get the name of every calendar'
    Forces a calendar permission prompt by trying to list all calendar names

@IVLIVS-III
Copy link
Contributor Author

@lukemmtt thank you for your summary and collection of similar issues. Because of that, I was able to create a workaround. This is the first step in continuing work for macOS support.

@lukemmtt
Copy link

Glad to hear it @IVLIVS-III! Great to hear that you were able to come up with a workaround—this should make debugging calendar issues much less burdensome in Flutter + IDEs.

Worth noting, my daily planner app TimeFinder is in production on iOS, Android and Mac, and it leverages our device_calendar fork for calendar integration on all platforms—works well!

@IVLIVS-III IVLIVS-III marked this pull request as ready for review November 23, 2024 14:53
@IVLIVS-III
Copy link
Contributor Author

@thomassth revived this PR, it's ready for review.

Try the workaround detailed above for the issue with launching the example from an IDE.

I've created a shell command that can be run once from within the integrated terminal in Android Studio / VS Code / another IDE. Afterwards, launching the macOS app from within the IDE should work with permissions set.

tccutil reset Calendar $(mdls -name kMDItemCFBundleIdentifier "$(mdfind "kMDItemFSName == '$(ps -o comm= -p $(ps -o ppid= -p $$) | awk -F'.app' '{print $1".app"}' | awk -F'/' '{print $NF}')'" | head -n 1)" | sed 's/.*= "\(.*\)"/\1/') && osascript -e 'tell application "Calendar" to get the name of every calendar'

@neonio neonio mentioned this pull request Feb 9, 2025
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

Successfully merging this pull request may close these issues.

Mac OS support