一个简单的 iOS 应用程序:

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

public class IOSDemo extends UIApplicationDelegate.Adapter {

    private UIWindow window = null;
    private int clickCount = 0;

    @Override
    public boolean didFinishLaunching(UIApplication application,
            NSDictionary launchOptions) {

        final UIButton button = UIButton.fromType(UIButtonType.RoundedRect);
        button.setFrame(new CGRect(115.0f, 121.0f, 91.0f, 37.0f));
        button.setTitle("Click me!", UIControlState.Normal);

        button.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
            @Override
            public void onTouchUpInside(UIControl control, UIEvent event) {
                button.setTitle("Click #" + (++clickCount), UIControlState.Normal);
            }
        });

        window = new UIWindow(UIScreen.getMainScreen().getBounds());
        window.setBackgroundColor(UIColor.lightGrayColor());
        window.addSubview(button);
        window.makeKeyAndVisible();

        return true;
    }

    public static void main(String[] args) {
        NSAutoreleasePool pool = new NSAutoreleasePool();
        UIApplication.main(args, null, IOSDemo.class);
        pool.drain();
    }
}

首先用 Javac 编译:
mkdir classes

javac -cp /opt/robovm/lib/robovm-rt.jar:/opt/robovm/lib/robovm-objc.jar:/opt/robovm/lib/robovm-cocoatouch.jar -d classes/ IOSDemo.java

再用 RoboVM 编译生成 iOS 应用:

/opt/robovm/bin/robovm -verbose -arch x86 -os ios -cp /opt/robovm/lib/robovm-objc.jar:/opt/robovm/lib/robovm-cocoatouch.jar:classes/ -run IOSDemo

又一个神器诞生!!!

/opt/robovm/bin/robovm -verbose -properties robovm.properties -config robovm.xml -arch x86 -run -ios-sim-family ipad

使用IDEA生成ipa文件包

./gradlew -Probovm.ipaArchs=thumbv7:arm64 :ios:createIPA

发表评论

邮箱地址不会被公开。 必填项已用*标注