Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25164] Ti.iCloud: Inject iCloud SystemCapabilities via module-hook

GitHub Issuen/a
TypeNew Feature
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-08-15T15:22:39.000+0000
Affected Version/sn/a
Fix Version/sTi.iCloud 2.0.0
ComponentsiOS
Labelsicloud, system-capabilities
ReporterDawson Toth
AssigneeHans Knöchel
Created2017-08-12T11:57:06.000+0000
Updated2018-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;
	};
};

Comments

  1. Hans Knöchel 2017-08-13

    Hey there! Can't you just use the entitlements-keys ?
       <?xml version="1.0" encoding="UTF-8"?>
       <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
       <plist version="1.0">
       <dict>
       	<key>com.apple.developer.icloud-container-identifiers</key>
       	<array/>
       	<key>com.apple.developer.ubiquity-kvstore-identifier</key>
       	<string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
       </dict>
       </plist>
       
    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 the com.apple.iCloud object and set it to true. The module should provide that functionality already, so if you bought it, the vendor should add it.
  2. Dawson Toth 2017-08-13

    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.
  3. Hans Knöchel 2017-08-13

    Is the module open source? I can only find a commercial version.
  4. Dawson Toth 2017-08-14

    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/
  5. Dawson Toth 2017-08-14

    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.
  6. Hans Knöchel 2017-08-14

    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).
  7. Hans Knöchel 2017-08-14

    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.
  8. Hans Knöchel 2017-08-15

    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!

JSON Source