roboscala / sbt-robovm

An sbt plugin for iOS development in Scala
BSD 2-Clause "Simplified" License
108 stars 16 forks source link

Interface Builder support #36

Closed ajhager closed 8 years ago

ajhager commented 9 years ago

It looks like we'll need to support both support for doing this as part of the build, and as a daemon sbt ib-daemon that keeps the xcode and sbt projects in sync as storyboards are edited.

Darkyenus commented 9 years ago

I have crated a prototype of how it could look, here. What it basically does: RoboVM picks up the storyboard and other assets through properly configured robovmConfiguration and generates XCode project. Then there is command (not task) interfaceBuilder, which opens the XCode with generated project and waits for changes to the source, similarly to how "~" behaves in SBT. When source changes, it compiles it and updates XCode project, like robovm-idea plugin. When user presses return/enter in sbt console, the watching terminates. However, if the user enters name of robovm task first, that task is executed: for example typing "iphoneSim" while in interfaceBuilder command and pressing enter, will execute the iphoneSim task normally. This should allow for a fast iteration cycle.

Next up is probably generating projects (templates?).

Ideas, suggestions, critique?

Darkyenus commented 9 years ago

I have added some documentation to the IB integration and tackled using RoboVM's newIOSStoryboard/ViewController/... to generate new IB files. It works, but these functions crash with NPE and obfuscated trace, which is obviously not very good and hard to debug. So we either need to figure out what is wrong, or include our own storyboard-from-template functions.

Working with the rest of the "API" isn't very pleasant either, all I have is source code of other tools using it (robovm-idea) which do not explain the usage very well. For example, the IBIntegrator class takes "classpath" and "sourceFolders". Currently, they are being set to the same values, because that is what robovm-idea does, but it determines each of these values differently and both methods just seem to end up with the same result (which works for me as well, but is probably not entirely correct).

Other caveat: interfaceBuilder had to be implemented as a command, not as a task, because it evaluates other tasks repeatedly. It works, but causes a few problems with scoping: it is impossible to write something like myIOSProject/debug:interfaceBuilder, so it has to be done via workarounds. But when all is properly configured, it is quite pleasant to work with.

As a result of these, I am not sure this is the correct approach, but I can't think of anything better. Integration works, but I don't know what is RoboVM doing under the hood and as a result, it feels brittle. I will continue on testing and trying though.

ajhager commented 9 years ago

I think this is looking great, but I need just a little longer to play with it. I'll give feedback this weekend and hopefully we can get this merged for 1.7!

Darkyenus commented 9 years ago

Great, see if you can reproduce the createSomething NPE. It didn't happen at one point, then I have changed something and now it appears consistently. You may have more chances of fixing that if you have access to the original IBIntegrator source.

Darkyenus commented 8 years ago

Further discussion on createStoryboard in #50 . Closed by #52.