3

我刚刚发现了非常棒的 RoboVM,并想尝试一下。现在,作为第一步,我只想尝试“开始”页面上的两个示例。不幸的是,我已经被困在这里了。

我尝试了命令行示例,而不是 eclipse 插件示例(我不使用 eclipse)。

HelloWorld示例运行良好。但我对IOSDemo示例有疑问。它用 javac 编译得很好,并且似乎被 RoboVM 正确处理。问题是iPhone模拟器启动后,向终端写入以下内容:

2014-06-01 07:14:25.820 IOSDemo[324:70b] Application windows are expected to have a root view controller at the end of application launch

模拟器中没有显示任何内容(空白屏幕)。

这是完整的输出以及我在终端中写的内容:

Xxxs-Mac:IOSDemo xxx$ javac -cp ../../../robovm-0.0.13/lib/robovm-rt.jar:../../../robovm-0.0.13/lib/robovm-objc.jar:../../../robovm-0.0.13/lib/robovm-cocoatouch.jar -d classes/ IOSDemo.java
Xxxs-Mac:IOSDemo xxx$ ../../../robovm-0.0.13/bin/robovm -verbose -arch x86 -os ios -cp ../../../robovm-0.0.13/lib/robovm-objc.jar:../../../robovm-0.0.13/lib/robovm-cocoatouch.jar:classes/ -run IOSDemo
Compiling IOSDemo (ios x86)
Compiling IOSDemo$1 (ios x86)
Linking 2009 classes
Building executable /var/folders/0y/k5k7wl3510d_7p8g6k9mjgc80000gn/T/robovm1960244380699928960.tmp/IOSDemo
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -o /var/folders/0y/k5k7wl3510d_7p8g6k9mjgc80000gn/T/robovm1960244380699928960.tmp/IOSDemo -g -arch i386 -Wl,-filelist,/var/folders/0y/k5k7wl3510d_7p8g6k9mjgc80000gn/T/robovm1960244380699928960.tmp/objects -L "/Volumes/My Disk/robovm/robovm-0.0.13/lib/vm/ios/x86" -ObjC -exported_symbols_list /var/folders/0y/k5k7wl3510d_7p8g6k9mjgc80000gn/T/robovm1960244380699928960.tmp/exported_symbols -Wl,-no_implicit_dylibs -Wl,-dead_strip -mios-simulator-version-min=5.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -lrobovm-bc -force_load "/Volumes/My Disk/robovm/robovm-0.0.13/lib/vm/ios/x86/librobovm-rt.a" -lrobovm-debug -lrobovm-core -lgc -lpthread -ldl -lm -liconv -lsqlite3 -framework Foundation -framework UIKit
Creating stripped archive file /var/folders/0y/k5k7wl3510d_7p8g6k9mjgc80000gn/T/robovm1960244380699928960.tmp/IOSDemo.app/lib/boot/robovm-rt.jar
Creating stripped archive file /var/folders/0y/k5k7wl3510d_7p8g6k9mjgc80000gn/T/robovm1960244380699928960.tmp/IOSDemo.app/lib/robovm-objc.jar
Creating stripped archive file /var/folders/0y/k5k7wl3510d_7p8g6k9mjgc80000gn/T/robovm1960244380699928960.tmp/IOSDemo.app/lib/robovm-cocoatouch.jar
Creating stripped archive file /var/folders/0y/k5k7wl3510d_7p8g6k9mjgc80000gn/T/robovm1960244380699928960.tmp/IOSDemo.app/lib/classes2.jar
Installing Info.plist to /var/folders/0y/k5k7wl3510d_7p8g6k9mjgc80000gn/T/robovm1960244380699928960.tmp/IOSDemo.app
xcrun dsymutil -o /var/folders/0y/k5k7wl3510d_7p8g6k9mjgc80000gn/T/robovm1960244380699928960.tmp/IOSDemo.app.dSYM /var/folders/0y/k5k7wl3510d_7p8g6k9mjgc80000gn/T/robovm1960244380699928960.tmp/IOSDemo.app/IOSDemo
warning: no debug symbols in executable (-arch i386)
"/Volumes/My Disk/robovm/robovm-0.0.13/bin/ios-sim" launch /var/folders/0y/k5k7wl3510d_7p8g6k9mjgc80000gn/T/robovm1960244380699928960.tmp/IOSDemo.app --timeout 90 --unbuffered --family iphone --retina --tall --args -rvm:log=warn
2014-06-01 07:14:25.820 IOSDemo[324:70b] Application windows are expected to have a root view controller at the end of application launch

据我所知,除了来自 iOS 模拟器的错误(以及关于调试符号的行)之外,没有任何错误或警告。

我使用: -Mac
OSX 10.9
-RoboVM 0.0.13
-Javac 1.7.0_60(也尝试过 1.8.0_05)-XCode
5.1.1(5B1008)
-(模拟器:iOS 7.1(11D167))

我以前从未使用过Mac,以前从未使用过XCode,也不知道Objective-C,所以我不确定如何解决它。谷歌搜索错误似乎表明我需要在某处添加一行代码,但我还不确定如何将其转换为 RoboVM,因为这是从网站复制/粘贴的示例代码,我想它应该开箱即用,无需修改(对吗?)。所以其他的东西可能是错的。希望你们中的一些人能看出什么是错的。任何帮助,将不胜感激。谢谢:)


编辑:它可以在 eclipse 中使用,但仍然不能在命令行中使用。我上面提到的错误也显示在 eclipse 中(见下图),但由于它仍然有效,因此该错误可能不是问题的原因。当我从命令行执行它时,也许iOS模拟器只是以某种方式错误地启动?

4

2 回答 2

1

我在 Eclipse 中记录了相同的错误消息,但模拟器正确启动并且似乎可以正常工作。

于 2014-07-02T22:20:20.667 回答
1

我们在 robovm 网站上的示例是对 robovm 可以做什么的非常基本的演示,而不是最佳实践。

像这样的东西可能有点“更好”(未经测试):

主要应用:

public class MainApplication extends UIApplicationDelegateAdapter {

UIViewController myViewController;


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

    if (myViewController == null) {
        myViewController = new MyViewController();
    }

    UINavigationController navigationController = new UINavigationController();
    navigationController.pushViewController(myViewController, true);

    CGRect bounds = new CGRect(0, 0, UIScreen.getMainScreen().getCurrentMode().getSize().width(),
            UIScreen.getMainScreen().getCurrentMode().getSize().height());


    UIWindow window = new UIWindow(bounds);
    window.setBackgroundColor(UIColor.colorWhite());
    window.makeKeyAndVisible();

    /* show everything */
    window.setRootViewController(navigationController);
    window.makeKeyAndVisible();

    return true;
}


/* Main entry point */
public static void main(String[] args) {
    NSAutoreleasePool pool = new NSAutoreleasePool();
    UIApplication.main(args, null, MainApplication.class);
    pool.close();
}
}

我的导航控制器:

public class MyViewController extends UIViewController {


@Override
public void viewDidLoad() {

    final UIButton button = UIButton.create(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);
        }
    });
   getView().addSubview(button );
}
}
于 2014-08-31T21:44:43.220 回答