MichaD
MichaD

Reputation: 985

JavaFXPorts and robovm-cocoatouch import

I’m trying to use JavaFXPorts and RoboVM-cocoatouch but I can’t use the native stuff from RoboVM like UIButton.

I have the following dependencies in my build.gradle file:

    classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b5'
    classpath 'org.robovm:robovm-cocoatouch:1.0.0'

And I'm trying to import org.robovm.apple.uikit.* but eclipse can't find the Packages.

What I have to do that I can use JavaFXPorts and the native stuff from RoboVM?

Upvotes: 0

Views: 273

Answers (1)

Joeri Sykora
Joeri Sykora

Reputation: 514

The short answer:

you need to create a folder src/ios/java in which your iOS specific source files should be located. The source files within this folder automatically have the correct classpath set, so you can use the RoboVM classes there.

The long answer:

In addition to the default main source set, the jfxmobile plugin also adds a source set for every platform the plugin supports: android, ios and desktop. Each source set has a src/PLATFORM/java and src/PLATFORM/resources directory which contains the platform specific source files and resource files respectively.

Platform independent code must be written inside the folder src/main/java, while platform specific code must be written inside the matching platform sources folder. For instance, in your case, iOS code should be put inside the src/ios/java folder.

The plugin also makes sure that the dependencies are correctly configured for each source set. Also, when you are for instance generating your IPA, it will only contain the class files from the main and ios source sets.

For more information about the structure of a jfxmobile project, look at the Structure section on this webpage: http://javafxports.org/page/Setting_up

You can read more information about gradle source sets in the java plugin documentation: http://gradle.org/docs/current/userguide/java_plugin.html

Upvotes: 1

Related Questions