NativeScript / ios-jsc

NativeScript for iOS using JavaScriptCore
http://docs.nativescript.org/runtimes/ios
Apache License 2.0
298 stars 59 forks source link

Storyboards Support #219

Open PanayotCankov opened 9 years ago

PanayotCankov commented 9 years ago

Provide support for using Xcode IB with Storyboard and JavaScript for controllers.

This feature will involve generation of Objective-C headers out of the application JavaScript files so that the Xcode's IB can be used for the UI. As directions - we can use TypeScript with out TypeScript definitions (or another language service that is capable of providing static analysis of the JavaScript).

It should integrate with a "live-sync" like solution that will enable watchers on the JavaScript files to regenerate the headers files on save for easier workflow.

It will have certain known limitations. For example dragging a button from the IB on the header to create an IBOutlet may not work since the generated property in the header may not be generated back in the JavaScript.

fealebenpae commented 9 years ago

the generated property in the header may not be generated back in the JavaScript

Analyze the header with Clang and insert the property declaration in JavaScript.

PanayotCankov commented 9 years ago

:+1: We'll do our best.

TheBrousse commented 9 years ago

I believe a minimum viable product would be where the developer would have to name his actions and outlets properly in the JavaScript file. And the linking feature would be executed only at compile time.

If the variable (action, outlet, etc.) is not declared, the compilation should simply fail with a useable error message.

Something like: IBOutlet "myNewButton" is not defined in JavaScript source file "win.ios.js"

As time progresses and the tooling improves, we can help developers by generating these variables for them. Or even checking them when the file is saved (as @PanayotCankov suggested)

PanayotCankov commented 9 years ago

Well, if you have to write the header files by hand and have to name the actions and outlets properly in the JavaScript file, and can get the errors at run-time instead of compile-time then we currently support Storyboards.

Would you like me to write out an article about what and how Storyboards are supported and give it a try. After that we can decide whether its satisfactory or identify areas for improvement.

TheBrousse commented 9 years ago

Yes, that would be great. I think the goal here is to show the power of all you can do with {N} and that such things are possible.

Once developer actually use this feature, it will be easier to determine how it can be improved with the tooling.

jasssonpet commented 9 years ago

I just want to reference our Gameraww example in this issue, which uses a storyboard: https://github.com/NativeScript/ios-runtime/tree/master/examples/Gameraww