Titanium JIRA Archive
Appcelerator Modules (MOD)

[MOD-2313] Ti.Facebook: Add CLI-hook to automatically inject capabilities updates

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-11-28T11:19:14.000+0000
Affected Version/sRelease 6.0.0, Release 5.5.0
Fix Version/sTi.Facebook 5.3.2, Ti.Facebook 5.2.9
ComponentsFacebook
Labelscapabilities, cli-hook, facebook, ios
ReporterHans Knöchel
AssigneeHans Knöchel
Created2016-11-17T15:31:46.000+0000
Updated2018-08-06T17:49:14.000+0000

Description

We talked about injecting the required keychain-capabilities automatically in Ti.Facebook, because curating two manual files will cause problems with our push settings that are also injected by the CLI. NOTE: This requires Titanium SDK 6.0.1. Here's the code that does this, but needs to be added to the module and tested. Preliminary testing indicates the code below works as advertised.
'use strict';

exports.id = 'com.appcelerator.facebook';

exports.cliVersion = '>=3.2';

exports.init = function init(logger, config, cli, appc) {
	cli.on('build.ios.writeEntitlements', {
		pre: function (data, finished) {
			var applicationIdentifier = '$(AppIdentifierPrefix)' + this.tiapp.id;
			var plist = data.args[0];

			Array.isArray(plist['keychain-access-groups']) || (plist['keychain-access-groups'] = []);
			if (!plist['keychain-access-groups'].some(function (id) { return id === applicationIdentifier; })) {
				plist['keychain-access-groups'].push(applicationIdentifier);
			}

			finished();
		}
	});
};

Comments

  1. Hans Knöchel 2016-11-18

    PR (ti.facebook/master): https://github.com/appcelerator-modules/ti.facebook/pull/75 PR (ti.facebook/5_2_X): https://github.com/appcelerator-modules/ti.facebook/pull/77 PR (titanium_mobile/master): https://github.com/appcelerator/titanium_mobile/pull/8627 PR (titanium_mobile/6_0_X): https://github.com/appcelerator/titanium_mobile/pull/8628 Also drafted 5.2.9 and 5.3.2 as a prerelease on the Github page. To test, run the [attached project](https://www.dropbox.com/s/tiiy6dmvzo5jkni/test_capabilities.zip?dl=1) that include the Ti.Facebook iOS version 5.2.9 from [here](https://github.com/appcelerator-modules/ti.facebook/releases/tag/ios-5.2.9) and run the project on simulator and device. Then:

    Check the generated capabilities file and ensure the keychain-access-groups dictionary was written from the CLI hook

    Click on the login button to ensure the Facebook login works (which means that the keychain access group was picked up correctly).

    Special note: You can either test with ti.facebook 5.2.9 (which will be used for 6.0.1) or with 5.3.2 (which will be used in 6.1.0).
  2. Eric Wieber 2016-12-01

    [~hansknoechel], I am seeing some unexpected behavior when building with a custom entitlements file in /platform/ios. On first/clean builds, the custom file looks to be copied to the build folder. On subsequent builds, the entitlements file in the build folder is overwritten with the generated file. I would expect the same file in the build folder on each build, without any modifications to the project. Tested with SDK 6.0.1.v20161130023500 and Facebook Module 5.2.9 The generated entitlements file has two keychain-access-groups values: One for the team-id and one for $(AppIdentifierPrefix). Facebook login still appears to work with both of these values present.
  3. Eric Merriman 2018-08-06

    Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.

JSON Source