[TIMOB-19455] Add Swift versions of the applewatch templates
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-02-19T03:32:55.000+0000 |
Affected Version/s | Release 5.0.0 |
Fix Version/s | Release 5.2.0 |
Components | Templates |
Labels | notable, watchOS2 |
Reporter | Fokke Zandbergen |
Assignee | Lee Morris |
Created | 2015-09-02T08:30:18.000+0000 |
Updated | 2017-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
[~rblalock] since you use Swift for your Watch app, could look into this maybe?
[~fokkezb] - you just want the sample app in swift code?
[~rblalock] No, Swift versions of these templates: https://github.com/appcelerator/titanium_mobile/tree/master/templates/applewatch
Horrific - why on earth were the templates written in ObjC?? Aggro
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.
[~Spaceghost] what SDK version are you using? The error you mention should have been fixed by TIMOB-18844 in April.
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
?Since this renames
watchos2
towatchos2-swift
*and* makes it default this ticket should either replace CLI-794 or be merged after.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
orreachabilitychanged
.[~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.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.
Backport for 5.2.0: https://github.com/appcelerator/titanium_mobile/pull/7589
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 deviceExpected results
at 3. Look inside extensions/[~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
[~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 stillwatchos1
. With 5.2 it will becomewatchos2-swift
, but we won't drop the Obj-Cwatchos2
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.[~fokkezb] [~cng] Studio changes will be addressed through TISTUD-7960
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:
When I install on my hardware it says:
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?Approved. PRs merged.