[TIMOB-24345] iOS: Today Extensions cannot access App Group UserDefaults or DirectoryForSuite
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2017-01-26T22:59:03.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | Lawrence Wilson |
Assignee | Chris Barber |
Created | 2017-01-25T14:08:38.000+0000 |
Updated | 2017-03-24T17:44:09.000+0000 |
Description
On trying to implement a Today Extension and share data, i have set up an App Group and tried using Ti.App.iOS.UserDefaults, Ti.Filesystem.directoryForSuite & Ti.Wormhole all of which failed.
I setup an empty XCode project called
Amy Today
with a Today Extension target called Amy Reminders
. Having changed the target capabilities for the App Group accordingly, a Amy Today.entitlements
file was created.
I included the extensions using the following in the TiApp.xml
:
<extensions>
<extension projectPath="extensions/Amy Today/Amy Today.xcodeproj">
<target name="Amy Reminders">
<provisioning-profiles>
<device/>
<dist-appstore/>
<dist-adhoc/>
</provisioning-profiles>
</target>
</extension>
</extensions>
I ran the project and tested and discovered the data was being written to the appropriate App Group folder/plist correctly from the app but could not be read by the Today Extension.
On further investigation I realised that a new Amy Reminders.entitlements
file was being created in a new folder within the build folder and this was being included in the built project not the actual entitlements file (see attached picture - red was the one included in the project, green is the one that should have been included.)
I delved into the 6.0.1.GA/iphone/cli/commands/_build.js
file and discovered on line 3434
the variable entFile
contained Amy Reminders/Amy Reminders.entitlement
which meant the following lines that join entFile
with targetName
was creating this new file.
This new file did not contain the key com.apple.security.application-groups
which meant the Today Extension did not have the appropriate security entitlements to read the shared data.
I removed the targetName from the path.join
as follows:
extBuildSettings.CODE_SIGN_ENTITLEMENTS = '"' + path.join(ext.relPath, entFile) + '"';
targetInfo.entitlementsFile = path.join(this.buildDir, ext.relPath, entFile);
and the Today Extension had the correct entitlements and could read the shared data. I'm not sure if the above fix is correct as I have not tested it with Watch Extensions.
Hope the above helps in the investigation on fixing this problem.
Attachments
File | Date | Size |
---|---|---|
Amy entitlements.png | 2017-01-25T14:00:04.000+0000 | 147370 |
Titanium supports defining App Groups in the
tiapp.xml
. You set them by adding them to the<ios>
section of the tiapp.xml like the following.These groups are baked into the
Entitlements.plist
files. It's worth noting that App Groups are the only capability that is currently supported.So that can be used instead of creating an Entitlements.plist file in the project? Might be an idea to update the documentation then as its not stated - http://docs.appcelerator.com/platform/latest/#!/guide/tiapp.xml_and_timodule.xml_Reference Would these entitlements be included in Today Extension projects?
[~lawrence.wilson@abannan.com] Correct, you don't need to muck with
Entitlements.plist
files, at least for app groups. Yes, the docs should be updated to include the<capabilities>
section. Honestly, I thought it was. I'm not familiar with "today extensions", so I'm going to guess sure.I created TIDOC-2732 to document the use of the
<capabilities>
section in the tiapp.xml. As for this ticket, I'm going to resolve this ticket as invalid. If the<capabilities>
doesn't solve the problem, then reopen this ticket with some details and I'd be happy to investigate.Closing ticket as invalid with reference to the above comments.