我正在尝试使用 gradle 在 iPhone 模拟器上运行一个基本的 Hello World libgdx 应用程序。我是 gradle 和 robovm 的新手。
首先我应该注意到,我能够使用以下命令成功构建和运行 tis 示例应用程序https://github.com/jtakakura/robovm-sample-ios-app:
./gradlew build launchIPhoneSimulator
只是作为一个小消遣,我很想知道为什么
./gradlew launchIPhoneSimulator
失败。显然“构建”需要明确。
wintermute:robovm-sample-ios-app matt$ ./gradlew launchIPhoneSimulator
:launchIPhoneSimulator
Classpath entry /Users/matt/code/robovm-sample-ios-app/build/classes/main does not exist
:launchIPhoneSimulator FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':launchIPhoneSimulator'.
> Main class org.robovm.sample.ios.RoboVMSampleIOSApp not found
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 7.115 secs
我原以为 launchIPhoneSimulator 任务将取决于构建任务,调用 lanuchIPhoneSimulator 会隐式调用构建。这是 gradle-robovm-plugin ( https://github.com/jtakakura/gradle-robovm-plugin ) 中的一个错误,还是我对 gradle 遗漏了什么?
好的,抱歉回到我的主要问题:
我使用 Gdx-setup ( https://github.com/libgdx/libgdx/tree/master/extensions/gdx-setup )提供的命令行工具生成了一个 libgdx 项目,并带有以下参数:
--dir /Users/matt/code/test --name test --package com.foo.bar --mainClass FooTest
我将生成的项目放到了 github 上,这样你就可以轻松地克隆它:
git clone https://github.com/mattwalters/libgdx-test libgdx-test
那我就跑
./gradlew build
构建所有子项目。但是我无法通过以下方式在模拟器上运行 ios 构建
./gradlew launchIPhoneSimulator
我收到与上述错误类似的错误:
wintermute:test matt$ ./gradlew ios:launchIPhoneSimulator
:ios:launchIPhoneSimulator
Classpath entry /Users/matt/code/test/ios/build/classes/main does not exist
:ios:launchIPhoneSimulator FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ios:launchIPhoneSimulator'.
> Main class com.foo.bar.IOSLauncher not found
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 12.759 secs
我仔细检查了主类的实际名称和声明为 gradle 的 mainClass 之间没有错字。并且在 ios/build 中确实没有 classes 目录,但我不知道为什么。
任何人都可以帮我解释一下吗?首先十分感谢。