-
Notifications
You must be signed in to change notification settings - Fork 93
Today Extension using App Groups #44
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
Conversation
Add APP_GROUP_IDENTIFIER build setting and corresponding "App Group Identifier" info.plist entries to resolve group identifiers in shared development environment.
|
Nice work!
|
|
Absolutely, that would be great.
|
|
This is awesome. Well worth the extra steps to install, for me. |
Today Extension using App Groups
|
nice work ! |
#33 introduced a basic widget. I've been looking into a full widget. Since this required quite a bit of more work, I made this a new PR.
UI and functions are simple but it's a good base to work from. I've been running this for a few days and it's quite stable.
Main Changes
App Groups
Extension and host app live in separate processes. They can only talk by using App Groups. Changing to app groups requires a bit of work:
group.<main bundle ID>.Problem: As with the main bundle ID, it seems we can’t share a group ID. Everyone has their own. The best I came up with:
APP_GROUP_IDENTIFIERfor everybody to set their group ID.NSUserDefaults
[[NSUserDefaults alloc] initWithSuiteName:<group ID>]instead ofstandardUserDefaults. I added a category so we can just call[NSUserDefaults groupDefaults].[defaults synchronize]when making changes.NSUserDefaultsDidChangeNotificationwon't get delivered between widget and app.GammaController
App and widget have their own
GammaControllerclass which write to their owngammatable.datfile. This leads to the problem where the widget initializes its file with already modified gamma data instead of the default screen values (or vice versa). It will then use this wrong data as the base level for adjustments.I changed it to write the
gammatable.datinto the shared app group space. Works for now but is not protected against concurrent writes. Although it's unlikely widget and app will write at the same time, this should be resolved. Maybe there is a better solution altogether that does not clutter GammaController with app group related stuff.Problem
The group ID stuff increases the barrier to entry for users who just want to install the thing. You now have to: (see linked screenshots)
I'm open for contributions and happy to change stuff as needed.
See also #14, #33.