How should I start with IOS?


#1

How do you integrate java and objective-c/swift?
From this page I can see how to build it, but the integration is a mystery to me.
https://wiki.jmonkeyengine.org/jme3/ios.html

Also, does anybody have any general tips about it?

Edit: also, how do I figure out if I am running on iOS from java? For Android I useSystem.getProperty(“java.runtime.name”).toLowerCase().equals(“android runtime”), but how can I check if it is running on iOS?


#2

System.getProperty("os.name") should provide a clue what you’re running on. For details see:
https://www.mkyong.com/java/how-to-detect-os-in-java-systemgetpropertyosname/

Sorry, I don’t have any tips on integration.


#3

Use the SDK and start a new iOS Project (Or was it only enabling iOS under Deployment settings?) Either way it generates an xCode Project to use later on. You just code in java and don’t care about the iOS side. Be aware that you need Mac OS.


#4

There’s a built in Enum for finding the platform. I think it’s JmeSystem.getPlatform() or something like that.

Edit: Yup.


#5

The IOS sdk menu is empty in a MacOS Mojave emulator with XCode and sdk 3.2


#6

I wouldn’t.

I’ve done some iOS work and would only tackle it again natively or using something like Unity that does all the work for me.

Not a very pro-active answer sorry, but it needs to be mentioned.


#7

“I wouldn’t”

I’m sorry, but not a very descriptive answer…

Are you referring to using ios and JME together?


#8

yep. The task appears to be a massive pain in the arse to me, I personally wouldn’t want to travel down that rocky road less travelled.

Just trying to save you huge headaches down the road. But by all means don’t let my pessimism stop you from doing it, I’m very often, if not always, wrong =)


#9

I’m prepared to deal with some issues… Not surprisingly, the android version works just fine, but I’m guessing this will be harder to integrate.


#10

good stuff =) I hope iOS works out smoothly so I/we can use it more.


#11

It might be because i dont seem to have the cmd line developer tools


#12

Followed this guide:

I got as far as linking.
I keep getting this error:

LD: -filelist file '../../build/iOS-arm64/libs.list' could not be opened errno=2 (no such file or directory)

Clang: error: linker command failed with exit code 1 (use -v to see invocation)

#13

mmmkay, so where is the file ?


#14

It looks like you need to switch on IOS in the Jmoneyengine SDK then compile in the SDK first.

It should build the IOS natives and project file for you. My guide assumes you have already got to that point. My guide was from the point where you are starting with XCODE.

Have you enabled IOS and allowed it download Avian and then build the natives?


#15

I think so, i did a clean-and-build, then enabled IOS deployment. Then I waited for the saving project properties dialog to go away, and opened XCODE. Lastly, I followed your steps until the linker bit.


#16

Are you building on OSX?

If so, if I remember correctly folder names are case sensitive. I notice you have got upper case in the folder name iOS-arm64/libs.txt

Does this folder exist and have you got the case correct?


#17

Sorry about that , typing on an iPad; it automtically changes that, it was lowercase.
I am building on a macos Mojave VirtualBox.


#18

Are you getting these messages when building in the SDK? Especially the last message???

If so, then check if the ios-arm64, ios-arm and ios-x86_64 folders exist in the build folder?
If so, then build in the XCODE project. Note: DO NOT use CLEAN in XCODE or it will delete these folders. Only use BUILD.

build-ios:
init:


Packaging iOS classpath and resources


Creating iOS resources object file for arm
Creating iOS bootimage and codeimage for arm


Compiling native code for arm


Expanding libavian.a for arm


Create library list for arm
build-ios-arm:
init:


Creating iOS resources object file for arm64
Creating iOS bootimage and codeimage for arm64


Compiling native code for arm64


Expanding libavian.a for arm64


Create library list for arm64
build-ios-arm64:
init:


Creating iOS resources object file for x86_64
Creating iOS bootimage and codeimage for x86_64


Compiling native code for x86_64


Expanding libavian.a for x86_64


Create library list for x86_64
build-ios-x86_64:

The needed native iOS libraries have been built, open the XCode project at ios/project to run the application on iOS.


#19

Getting an error:

Full Log
ant -f /Users/indigo/Documents/JMonkeyEngine/Crushed -Dnb.internal.action.name=rebuild clean jar
init:
deps-clean:
Updating property file: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/built-clean.properties
Deleting directory /Users/indigo/Documents/JMonkeyEngine/Crushed/build
clean:
Building jar: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/assets.jar
init:
deps-jar:
Updating property file: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/built-jar.properties
Created dir: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/classes
Created dir: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/empty
Created dir: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/generated-sources/ap-source-output
Compiling 42 source files to /Users/indigo/Documents/JMonkeyEngine/Crushed/build/classes
Note: /Users/indigo/Documents/JMonkeyEngine/Crushed/src/com/indigoa/game/crushed/mode/ModeTimed.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Copying 1 file to /Users/indigo/Documents/JMonkeyEngine/Crushed/build/classes
compile:
Created dir: /Users/indigo/Documents/JMonkeyEngine/Crushed/dist
Copying 1 file to /Users/indigo/Documents/JMonkeyEngine/Crushed/build
Copy libraries to /Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib.
Building jar: /Users/indigo/Documents/JMonkeyEngine/Crushed/dist/MyGame.jar
To run this application from the command line without Ant, try:
java -jar "/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/MyGame.jar"
build-ios:
init:
Created dir: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/build
Compiling 1 source file to /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/build
Copying 1 file to /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/build
Created dir: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath
Packaging iOS classpath and resources
ProGuard, version 5.2.1
Reading program directory [/Users/indigo/Library/Application Support/jmonkeyplatform/v3.2.2-stable-sdk1/avian-openjdk/classpath]
Reading program directory [/Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/build]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/JME-SVG.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/JMEInterface.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/assets.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/gson-2.8.1.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/guava-12.0.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jinput-2.0.5.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jinput-platform-2.0.5-natives-linux.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jinput-platform-2.0.5-natives-osx.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jinput-platform-2.0.5-natives-windows.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jme-ttf-2.1.2.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jme3-core-3.2.2-stable.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jme3-ios-3.2.2-stable.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jme3-plugins-3.2.2-stable.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jutils-1.0.0.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/lemur-1.11.0.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/lwjgl-2.9.3.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/lwjgl-platform-2.9.3-natives-linux.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/lwjgl-platform-2.9.3-natives-osx.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/lwjgl-platform-2.9.3-natives-windows.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/slf4j-api-1.7.25.jar]
Reading program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/MyGame.jar]
Preparing output jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/resources.jar]
Preparing output directory [/Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath] (filtered)
  Copying resources from program directory [/Users/indigo/Library/Application Support/jmonkeyplatform/v3.2.2-stable-sdk1/avian-openjdk/classpath]
  Copying resources from program directory [/Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/build]
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/JME-SVG.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [JME-SVG.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/JMEInterface.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [JMEInterface.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/assets.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [assets.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/gson-2.8.1.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [gson-2.8.1.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/guava-12.0.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [guava-12.0.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jinput-2.0.5.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [jinput-2.0.5.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jinput-platform-2.0.5-natives-linux.jar]
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jinput-platform-2.0.5-natives-osx.jar]
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jinput-platform-2.0.5-natives-windows.jar]
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jme-ttf-2.1.2.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [jme-ttf-2.1.2.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jme3-core-3.2.2-stable.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [jme3-core-3.2.2-stable.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jme3-ios-3.2.2-stable.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [jme3-ios-3.2.2-stable.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jme3-plugins-3.2.2-stable.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [jme3-plugins-3.2.2-stable.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/jutils-1.0.0.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [jutils-1.0.0.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/lemur-1.11.0.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [lemur-1.11.0.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/lwjgl-2.9.3.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [lwjgl-2.9.3.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/lwjgl-platform-2.9.3-natives-linux.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [lwjgl-platform-2.9.3-natives-linux.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/lwjgl-platform-2.9.3-natives-osx.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [lwjgl-platform-2.9.3-natives-osx.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/lwjgl-platform-2.9.3-natives-windows.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [lwjgl-platform-2.9.3-natives-windows.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/lib/slf4j-api-1.7.25.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [slf4j-api-1.7.25.jar:META-INF/MANIFEST.MF])
  Copying resources from program jar [/Users/indigo/Documents/JMonkeyEngine/Crushed/dist/MyGame.jar]
Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [MyGame.jar:META-INF/MANIFEST.MF])
Expanding: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath/JME-SVG.jar into /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath
Expanding: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath/JMEInterface.jar into /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath
Expanding: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath/MyGame.jar into /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath
Expanding: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath/gson-2.8.1.jar into /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath
Expanding: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath/guava-12.0.jar into /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath
Expanding: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath/jme-ttf-2.1.2.jar into /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath
Expanding: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath/jme3-core-3.2.2-stable.jar into /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath
Expanding: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath/jme3-ios-3.2.2-stable.jar into /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath
Expanding: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath/jme3-plugins-3.2.2-stable.jar into /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath
Expanding: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath/lemur-1.11.0.jar into /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath
Expanding: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath/slf4j-api-1.7.25.jar into /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-classpath/classpath
Created dir: /Users/indigo/Documents/JMonkeyEngine/Crushed/build/ios-arm/libs
Creating iOS resources object file for arm
Creating iOS bootimage and codeimage for arm
java/lang/NoClassDefFoundError: com/google/typography/font/sfntly/table/Table
/Users/indigo/Documents/JMonkeyEngine/Crushed/nbproject/ios-impl.xml:5: The following error occurred while executing this line:
/Users/indigo/Documents/JMonkeyEngine/Crushed/nbproject/ios-impl.xml:179: exec returned: 255
BUILD FAILED (total time: 3 minutes 57 seconds)

The error is

Creating iOS resources object file for arm
Creating iOS bootimage and codeimage for arm
java/lang/NoClassDefFoundError: com/google/typography/font/sfntly/table/Table
/Users/indigo/Documents/JMonkeyEngine/Crushed/nbproject/ios-impl.xml:5: The following error occurred while executing this line:
/Users/indigo/Documents/JMonkeyEngine/Crushed/nbproject/ios-impl.xml:179: exec returned: 255
BUILD FAILED (total time: 3 minutes 57 seconds)

From the log, I gathered that JME copies all dependencies, so why the NoClassDefFound? (I don’t even know which library uses this, but it’s not mine…)
My guess why it fails for arm64/x86_64: it never got to the point of building for either.


#20

Wiithout looking into it: ProGuard obfuscates classes, maybe that’s part of the problem