Settings.bundle not respecting app group for shared NSUserDefaults on tvOS - nsuserdefaults

I have a tvOS application with an accompanying topshelf extension.
For the main app and the extension to share UserDefaults, it is necessary to create an App Group with a unique identifier of the form group.com.organisation.app.identifier and to open not UserDefaults.standard but instead supply the app group name when opening UserDefaults, e.g. let defaults = UserDefaults(suiteName: "group.com.organisation.app.AppGroupTest1").
This works fine for sharing defaults between the app and its extension, but adding a Settings.bundle file so that the defaults can be set by the system settings panel will not work.
Apple's guidelines state that Root.plist of the Settings.bundle must contain the key ApplicationGroupContainerIdentifier set to the same app group identifier as used by the app, but when testing this even with the most minimal application setup, the group container identifier is not respected by the Settings.bundle, and all settings made by the Settings.bundle end up in UserDefaults.standard instead.
I have tried implementing the same minimal app+bundle project as an iOS project, and the settings are propagated into the app group's UserDefaults there, as expected. Have I encountered a tvOS bug in the implementation of settings bundles or is there an under-undocumented difference between the implementation in iOS and tvOS?

Related

Settings.bundle not respecting app group on iOS simulator or device

I had been using standardUserDefaults until recently but decided to use shared app groups because I created a watch extension. I have set up an app group and also added the ApplicationGroupContainerIdentifier to the settings bundle.
I have spent hours on this and, even after reading many articles, I just can’t get this to work. I am seeing that when I alloc my app group and print its contents, it has default values from standardUserDefaults.
All I am doing is [[NSUserDefaults alloc] initWithSuiteName: SUITE_NAME]] and then print its contents on the very next line.
I am puzzled by how it has values from my settings bundle. Moreover, when you edit the properties using the settings app, the settings in standardUserDefaults are changing but my app group values stay the same.
I see the same behaviour on the simulator and real device.
This turned out to be user error. There was a typo in the app group name as a result of the auto-correct feature. I did not realize it until I created a new app group.

Accessing User Defaults on Apple Watch app Extension with watchOS 5

I am building a workout app for Apple Watch with watchOS 5.
I am storing workout settings in UserDefaults plist. When the watch extension is launched I try to read the UserDefaults and have the workout settings restored for the user.
According to Apple Documentation
Additionally, iOS automatically forwards a read-only copy of your iOS
app’s preferences to Apple Watch. Your WatchKit extension can read
those preferences using an NSUserDefaults object, but it cannot make
changes directly to the defaults database.
If your Watch app needs to change the values stored in the defaults
database, use the Watch Connectivity framework to send the values back
to your iOS app, and save the values there.
Since UserDefaults is just read only for watch Extension, If user changes any setting on the watch, I send that settings to iPhone with WatchConnectivity and store it into UserDefaults on iPhone. So the next time user launches watch Extension he should get updated userDefaults.
Now the problem is watch App also has a complication, If an Apple Watch App has complication it stays in the background in order to launch the app quickly. So when will the iOS app sync the read only copy of userDefaults?
What can be the best practice to follow if a user wants to restore its settings every time the watch app extension is launched?

Hide Settings Bundle in Settings.app

I have created an iOS 4.0 app with a Settings bundle. I am using the InAppSettingsKit (http://www.inappsettingskit.com) which presents the settings in the app. This allows the user to modify those settings directly from within the app, without the need to go to the external iPhone Settings.app. As the settings are accessible from inside the app (and I am doing some custom styling to the in-app settings screen) I would like to stop the Settings bundle from appearing in the iPhone Settings.app. Is this possible?
Any help would be greatly appreciated.
InAppSettingKit allows the use of an internal only settings bundle. Rename Settings.bundle to be this and then the OS wont find it to put it in the Main Settings part
Check out "Some little extras" on the product page

InAppSettingsKit without saving to Settings app

I've seen there is a library called InAppSettingsKit - http://www.inappsettingskit.com/ - which lets your in-app settings mimic your settings within the Settings app.
But is there a way to get this to NOT use the Settings app as well? So it just allows you to change settings within the app. Or is there another library which does this?
InAppSettingKit lets you use a local bundle for the in-app part (see documentation) Try only including this and not including the Settings.bundle

Custom URL Scheme from settings.bundle

Is it possible to set a custom URL scheme to launch my app from a link but make this a user defined setting?
My app relies on a user defined server url and I would like to be able to set a URL scheme to launch my app using the users custom URL from lets say an email link.
I noticed the info.plist has these references
${EXECUTABLE_NAME}
can I define my own custom reference maybe?
Edit: Turns out these ${EXECUTABLE_NAME} are just references used during build in xcode.
I also learned that the app bundle is read only on device making the info.plist un-editable.
Looks like this is impossible. Anyone have any ideas?
There is no way to add a link to a Settings.bundle to launch your app.