Developing iOS applications with Kotlin

Showing 1-14 of 14 messages
Developing iOS applications with Kotlin Ilya Ryzhenkov 2/5/14 7:23 AM
Hi,

I'm trying to make use of Kotlin (http://kotlin.jetbrains.org/) with RoboVM to develop iOS applications. Since Kotlin and RoboVM are not even close to release, and I'm newbie in iOS development (this is my first time trying to write my), I'm somewhat screwed. Some basic stuff works, but I can't get autolayout constraints to work. I literally translated https://github.com/mmorey/MDMViewProgrammatically into Kotlin. Now running in simulator doesn't seem to kick in autolayout. If I set bounds manually, it works. Any ideas? 

Thanks!
Re: Developing iOS applications with Kotlin Ilya Ryzhenkov 2/5/14 7:38 AM
Here is the code in Kotlin:

package krobo

import org.robovm.cocoatouch.coregraphics.*;
import org.robovm.cocoatouch.foundation.*;
import org.robovm.cocoatouch.uikit.*;

public class MyView() : UIView(CGRect(0f,0f,0f,0f)) {
    {
        setTranslatesAutoresizingMaskIntoConstraints(false)
        setBackgroundColor(UIColor.whiteColor())

        val subView = UIView(CGRect(0f,0f,0f,0f))
        subView.setTranslatesAutoresizingMaskIntoConstraints(false)
        subView.setBackgroundColor(UIColor.greenColor())

        addSubview(subView)

        addConstraint(NSLayoutConstraint.create(subView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 0.5f, 0f) as NSLayoutConstraint)
        addConstraint(NSLayoutConstraint.create(subView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 0.5f, 0f) as NSLayoutConstraint)
        addConstraint(NSLayoutConstraint.create(subView, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0f) as NSLayoutConstraint)
        addConstraint(NSLayoutConstraint.create(subView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterX, 1f, 0f) as NSLayoutConstraint)
    }
}

class MyController : UIViewController() {
    override fun loadView() {
        setView(MyView())
    }
}

public class MyDemo : UIApplicationDelegate.Adapter() {

    var clickCount = 0

    fun didFinishLaunching(application: UIApplication?, launchOptions : NSDictionary<NSObject, NSObject>?) : Boolean {
        val window =  UIWindow(UIScreen.getMainScreen()!!.getBounds());
        window.setBackgroundColor(UIColor.whiteColor());
        window.setRootViewController(MyController())
        window.makeKeyAndVisible();
        return true
    }
}

public fun main(args: Array<String>) {
    val pool = NSAutoreleasePool()
    UIApplication.main<UIApplication, MyDemo>(args, null, javaClass<MyDemo>())
    pool.drain();
}

Re: Developing iOS applications with Kotlin Ilya Ryzhenkov 2/5/14 12:06 PM
So far I invented some way to "debug" RoboVM applications by attaching debugger to running process in Simulator (you will need empty Mac OS project) and setting symbolic breakpoints, like to

-[UIView(UIConstraintBasedLayout) _addConstraint:]

It actually gets called (sendmsged), so I think it's not an issue with bindings. 

Re: Developing iOS applications with Kotlin Niklas Therning 2/6/14 8:01 AM
Hi,

I can only confirm that it doesn't work. I have tried the exact code from MDMViewProgrammatically ported to Java. The ObjC code works properly but not the Java code. I cannot say whether it's a problem with the bindings or if there's some misconfiguration (e.g. some bad value in Info.plist).


--
You received this message because you are subscribed to the Google Groups "RoboVM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robovm+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Developing iOS applications with Kotlin Ilya Ryzhenkov 2/7/14 6:11 AM
As for Info.plist, I copied it from the generated plist.xml from Xcode, didn't help. 
Re: Developing iOS applications with Kotlin Erlend Sogge Heggen 3/5/14 2:06 AM
Seems you pulled it off eh?

Would love to hear more about what was required. This is becoming increasingly significant because LWJGL 3 is written largely in Kotlin:
Re: Developing iOS applications with Kotlin Erlend Sogge Heggen 3/5/14 2:29 AM
Ilya replied:

It’s on my plate :) But the plate is way too big… Right now I’m working on Kotlin stdlib to fill in the blanks and make it decent library for everyday development.
As for iOS, I still want to write programs for device in Kotlin, but I don’t have enough time to investigate why this or that doesn’t work in RoboVM, sorry. 
However, on the IntelliJ side, I discussed it with team, and here is what we have:
* AppCode has integration with iOS (sim/device) debugger, which is detachable and is actually used in plugin for Ruby Motion. We could reuse it. Need to generate adequate dsym, of course.
* Run Configurations and other bulding/deploying stuff is not that hard to do, but doesn’t make much sense without debugger. 
* All basic stuff should work in RoboVM (including layouts), otherwise it is hard for me to justify resources allocation.
So basically, generate dsym, write some application (to-do list?) in modern UI, even in Java, and we can go further with IDEA. 
Re: Developing iOS applications with Kotlin Ilya Ryzhenkov 3/5/14 4:10 AM
Yep, didn't realise it was from google-groups :)
Re: Developing iOS applications with Kotlin Jon Renner 3/14/14 7:38 AM
I am currently working on a small kotlin + libgdx game that I will try to build for iOS soon, will report back later
Re: Developing iOS applications with Kotlin Jon Renner 3/15/14 2:25 AM
So at first I was trying to build a kotlin + libgdx app on mac for iOS, but I ran into the hurdle of Kotlin only working with IntelliJ (I couldn't get the kotlin-eclipse github repo working)
and RoboVM only working with eclipse.  Without a new plugin for one or the other, seems like things would have to be done in the command line (both Kotlin and RoboVM can be run from the command line).   This is not a problem, but I don't have the time to play around with that yet.

I decided to do a very simple test of compiling a HelloWorld.kt through RoboVM for linux/x86(just for my convenience) to prove at least that RoboVM and Kotlin can work together.  Happy to report this was successful, though hardly a thorough test case.  Compile log for proof, if anyone is interested: https://gist.github.com/jrenner/9563958
Re: Developing iOS applications with Kotlin Jon Renner 3/15/14 6:08 AM
I decided to spend the time on it anways. I was able to get a working libgdx app written completely in Kotlin to run on an iPad2!
Re: Developing iOS applications with Kotlin Erlend Sogge Heggen 3/15/14 7:08 AM
Wow, nice! Any special trick to it?


On 15 March 2014 14:08, Jon Renner <renn...@gmail.com> wrote:
I decided to spend the time on it anways. I was able to get a working libgdx app written completely in Kotlin to run on an iPad2!

--
You received this message because you are subscribed to a topic in the Google Groups "RoboVM" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/robovm/p3HJisndt-4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to robovm+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Developing iOS applications with Kotlin Jon Renner 3/15/14 10:07 PM
I made a github Repo to share my bash script for others who need to use RoboVM from the command line

Re: Developing iOS applications with Kotlin Niklas Therning 5/27/14 2:14 AM
Ilya, auto layout works as expected with the latest version of RoboVM. Attached is a Java port of your original Kotlin code which uses the new CocoaTouch bindings. The result looks like this:





On Wed, Feb 5, 2014 at 9:06 PM, Ilya Ryzhenkov <ilya.ry...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "RoboVM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robovm+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.