[TIMOB-25164] Ti.iCloud: Inject iCloud SystemCapabilities via module-hook
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-08-15T15:22:39.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Ti.iCloud 2.0.0 |
Components | iOS |
Labels | icloud, system-capabilities |
Reporter | Dawson Toth |
Assignee | Hans Knöchel |
Created | 2017-08-12T11:57:06.000+0000 |
Updated | 2018-08-02T21:50:17.000+0000 |
Description
One of my apps uses the Ti.ICloud module, which works great, if you have the SystemCapabilities properly configured. The Xcode project generated by Titanium doesn't have the proper capabilities turned on. So I have to
--build-only
, run some regular expressions to fix the SystemCapabilities, and then fastlane gym
my project to build and upload it as a part of my CI process. Outside of CI, I'd have to build from Xcode directly, if I want iCloud to work right.
If I run my regular expressions, and then do another appc ti build
, my changes to project.pbxproj are wiped out, so that doesn't work either.
Is there any way to customize the capabilities in the generated project?
SystemCapabilities = {
com.apple.iCloud = {
enabled = 1;
};
com.apple.InAppPurchase = {
enabled = 1;
};
};
Hey there! Can't you just use the entitlements-keys ?
If that does not work, the module should provide a hook to inject the keys. The [Ti.DynamicLib](https://github.com/appcelerator-modules/hook-embedded-frameworks/blob/master/ti.dynamiclib.js) plugin does something similar to enable dynamic libraries in Titanium. You basically just jump from the UUID's of the different PBX-sections until you reach the
SystemCapabilities
section and then add thecom.apple.iCloud
object and set it totrue
. The module should provide that functionality already, so if you bought it, the vendor should add it.I don't think the functionality existed when Matt wrote the original module, or when I worked on it. I finally thought to ask, years later... I'll add that support to it in the next couple of days and submit a PR.
Is the module open source? I can only find a commercial version.
I'm not convinced this is "not our bug", given it's the Appcelerator enterprise version of the module that has trouble -- https://github.com/appcelerator-modules/ti.icloud I'm guessing because it's enterprise, very few people have used it. Those that have used it have also figured out the Xcode settings or the Entitlements.plist. But if the general public tried to use it... There's even a guide on how to write it, essentially. It doesn't expose as many methods. Why not open source the module? http://www.lighthouselogic.com/icloud-in-titanium/
The Ti.StoreKit module could exhibit the same behavior. If StoreKit is enabled in the generated project, it's not deliberately enabled by the module.
Hey Dawson, I did not know it was an Appc-curated module. That makes it a whole different thing. For Ti.StoreKit, the capabilities are managed via the Entitlements.plist and the capabilities used in the provisioning profile. *EDIT*: Btw, the linked blog post also suggests to enable it via the entitlements file, which is necessary either way (since Xcode generates the file as well when you enable it).
I've added a PoC PR of injecting the required "com.apple.iCloud" key [here](https://github.com/appcelerator-modules/ti.icloud/pull/2). It is untested for now and would need a closer look. I basically just went through the pbx file, looked up the required UUID to handle and rewrote the system-capabilities to enable the iCloud key.
PR works for me, the
com.apple.iCloud
key is injected properly. Open-sourced the script [here](https://github.com/hansemannn/titanium-system-capabilities) for everyone else who wants to use it!