Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19455] Add Swift versions of the applewatch templates

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-02-19T03:32:55.000+0000
Affected Version/sRelease 5.0.0
Fix Version/sRelease 5.2.0
ComponentsTemplates
Labelsnotable, watchOS2
ReporterFokke Zandbergen
AssigneeLee Morris
Created2015-09-02T08:30:18.000+0000
Updated2017-03-16T22:46:15.000+0000

Description

Our current [applewatch](https://github.com/appcelerator/titanium_mobile/tree/master/templates/applewatch) templates are in Obj-C while many Xcode developers are switching to Swift. Titanium developers with no/little Xcode experience will likely also find Swift easier. So, we should have Swift-versions of the applewatch templates and probably default to that. * watchos2-swift Swift (new default) * watchos2-objc Obj-C (current) PR: https://github.com/appcelerator/titanium_mobile/pull/7496

Comments

  1. Fokke Zandbergen 2015-09-02

    [~rblalock] since you use Swift for your Watch app, could look into this maybe?
  2. Rick Blalock 2015-09-02

    [~fokkezb] - you just want the sample app in swift code?
  3. Fokke Zandbergen 2015-09-04

    [~rblalock] No, Swift versions of these templates: https://github.com/appcelerator/titanium_mobile/tree/master/templates/applewatch
  4. Jason Kneen 2015-09-08

    Horrific - why on earth were the templates written in ObjC?? Aggro
  5. John McMahon 2015-10-18

    Another headache is that you cannot use Swift even if you want to within the watch OS2 extension Xcode project, nor can you add a share extension or other app extension using the same template Xcode file paradigm... because I want to add a swift share extension I figured I would add swift code to the watchOS2 Xcode template. No matter what I do I get an Xcode compile error: [ERROR] : iOS extension "xxx" target "xxx WatchApp Extension" contains Swift code, but "Embedded Content Contains Swift Code" is not enabled. And yes, I set the Embedded Content Contains Swift Code setting in the watchOS2 template AND the Titanium.xcodeproj files to no avail. My overall complaint is that this is all extremely circuitous and it seems if Appcelerator would just make it convenient to merge Xcode projects at build time, we could have all of the extension support we wanted without the byzantine workarounds to nowhere.
  6. Fokke Zandbergen 2015-10-19

    [~Spaceghost] what SDK version are you using? The error you mention should have been fixed by TIMOB-18844 in April.
  7. Fokke Zandbergen 2015-11-25

    PR on master: https://github.com/appcelerator/titanium_mobile/pull/7496 Tested both watchos2 (now watchos2-objc) and watchos2-swift on Simulator and device. [~cbarber] I can't get watchos1 (before or after changes) to build. Can't we just remove this template and the related stuff in _build.js?
  8. Fokke Zandbergen 2015-11-25

    Since this renames watchos2 to watchos2-swift *and* makes it default this ticket should either replace CLI-794 or be merged after.
  9. Fokke Zandbergen 2015-11-25

    Note: as part of this PR I reverted most of TIMOB-19412 except for adding the WatchConnectivity framework and creating the watch session when the app activates. This is enough to get people started and allow them to verify it works by listening to Ti.Watchsession:watchstatechanged or reachabilitychanged.
  10. Chee Kiat Ng 2015-12-02

  11. Fokke Zandbergen 2015-12-02

    [~cng] my PR just removes the watchos1 template, not the related code in the build script. We can do that later since it's not affecting anything. And for the sake of getting this PR merged I think it's better to rip out that code later and keep the changes to _build.js minimal for now.
  12. Fokke Zandbergen 2015-12-02

    As commented in CLI-794 we should *not* merge that, but this one instead and close CLI-794 as invalid. It would only result in having two places where we set the default watch template, which is no good.
  13. Fokke Zandbergen 2015-12-17

    Backport for 5.2.0: https://github.com/appcelerator/titanium_mobile/pull/7589
  14. Chee Kiat Ng 2015-12-17

    FT passed. PRs merged!.

    Steps to test

    1. *appc new* -> Native App 2. enter project 3. *appc new* -> Apple Watch App 4. *appc run -p ios --launch-watch-app* 5. repeat step 1-2 6. *appc new -t applewatch --template watchos2-swift* 7. *appc run -p ios --launch-watch-app* 8. repeat step 1-2 9. *appc new -t applewatch --template watchos2* 10. *appc run -p ios --launch-watch-app* 11. repeat step 1-2 12. *appc new -t applewatch --template watchos2-objc* 13. *appc run -p ios --launch-watch-app* 14. repeat all using device

    Expected results

    at 3. Look inside extensions//Extension/ you should see swift files at 4. builds normally at 6. Look inside extensions//Extension/ you should see swift files at 7. builds normally at 9. Look inside extensions//Extension/ you should see m and h files at 10. builds normally at 2. Look inside extensions//Extension/ you should see m and h files at 13. builds normally at 14. same results as above.
  15. Chee Kiat Ng 2016-01-06

    [~kkolipaka] please take note of this and see if studio needs a ticket to conform with this. If so, it has to be ready for 5.2.0
  16. Fokke Zandbergen 2016-01-06

    [~kkolipaka] I think it needs updates here: * https://github.com/appcelerator/titanium_studio/blob/master/plugins/com.appcelerator.titanium.ios.core/src/com/appcelerator/titanium/ios/core/IOSConstants.java#L85-L93 ( * https://github.com/appcelerator/titanium_studio/search?q=APPLEWATCHKIT&type=Code I think it would be best to leave out the --template option so that you let the CLI pick the default for the type, but the problem is that currently that default is still watchos1. With 5.2 it will become watchos2-swift, but we won't drop the Obj-C watchos2 until 6.0. So I think we should check the SDK version of the project and if it's >= 5.2 leave out the option.
  17. Kondal Kolipaka 2016-01-19

    [~fokkezb] [~cng] Studio changes will be addressed through TISTUD-7960
  18. Fokke Zandbergen 2016-02-18

    Reopening because for some reason this no longer works in the 5.2.0 RC. When I generate an extension with the Obj-C template it works, but when I use the new (default) Swift template it starts to load (shows spinner) the Watch app and then fails with:
        [ERROR] [Ti 5.2.0 WatchKit App] (Error) WatchKit: <SPApplicationDelegate.m __55-[SPApplicationDelegate _startActivatingAssertionTimer]_block_invoke:2067> We've held the CSLSActivatingUIAssertion for 30 secs. Giving up
        
    When I install on my hardware it says:
        Feb 18 17:20:32 Fokkes-AppleWatch Ti 5.2.0 WatchKit Extension[3874] <Warning>: WatchKit error - unable to find interface controller class '_TtC27Ti_5.2.0_WatchKit_Extension19InterfaceController' to instantiate
        Feb 18 17:20:32 Fokkes-AppleWatch Ti 5.2.0 WatchKit Extension[3874] <Notice>: (Error) WatchKit: ComF: -[SPRemoteInterface _interfaceControllerWithID:] interfaceController for interfaceControllerID:F210002 not found (clientIdentifier=(null))
        Feb 18 17:20:32 Fokkes-AppleWatch Ti 5.2.0 WatchKit Extension[3874] <Notice>: (Error) WatchKit: ComF: -[SPRemoteInterface _interfaceControllerWithID:] interfaceController for interfaceControllerID:F210002 not found (clientIdentifier=(null))
        Feb 18 17:20:32 Fokkes-AppleWatch Ti 5.2.0 WatchKit Extension[3874] <Warning>: *********** ERROR -[SPRemoteInterface _interfaceControllerClientIDForControllerID:] clientIdentifier for interfaceControllerID:F210002 not found
        Feb 18 17:20:32 Fokkes-AppleWatch Ti 5.2.0 WatchKit Extension[3874] <Notice>: (Error) WatchKit: ComF:<-Plugin _RunLoopHandler controller ID F210002 has no client identifier
        
  19. Fokke Zandbergen 2016-02-18

    The Watch App couldn't find the Extension with the InterfaceController because the IBSC_MODULE we populated only stripped out spaces, but not other non-alphanum characters. Fix for master: https://github.com/appcelerator/titanium_mobile/pull/7754 Backport for 5_2_X: https://github.com/appcelerator/titanium_mobile/pull/7755 Tested with the same project as above and works like clockwork. [~cng] or [~cbarber] could you review and merge for 5.2.0?
  20. Chee Kiat Ng 2016-02-19

    Approved. PRs merged.

JSON Source