graalvm-mobile

https://github.com/phronmophobic/mobiletest
borkdude 2021-06-29T09:37:16.182200Z

@smith.adriane I got compilation working locally now, except the last part of the compile-shared script didn't work for me

borkdude 2021-06-29T09:37:28.182400Z

# Printing build artifacts to: mobiletest-uber.build_artifacts.txt
[mobiletest-uber:80025]      [total]: 178,607.13 ms,  8.18 GB
+ rm -rf ./build/out
+ mkdir -p build/out
++ find . -name llvm.o -print0
++ xargs -r -0 ls -1 -t
++ head -1
xargs: illegal option -- r
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
             [-L number] [-n number [-x]] [-P maxprocs] [-s size]
             [utility [argument ...]]
+ LLVM_PATH=
+ cp '' build/out
cp: : No such file or directory

borkdude 2021-06-29T09:37:58.182700Z

Also, after opening the project in xcode, what should I do to run it?

borkdude 2021-06-29T09:38:15.182900Z

I don't know what to do with this:

phronmophobic 2021-06-29T15:19:42.184700Z

@borkdude, I updated the script to not use xargs. The graalvm llvm backend produces *.o object files that need to get copied over. you can probably just run the last bit of the script instead of recompiling everything

cd library
find ./tmp -name 'llvm.o' -exec cp {} build/out \;
find ./tmp -name 'mobiletest-uber.o' -exec cp {} build/out \;

phronmophobic 2021-06-29T15:21:26.185300Z

You can press ⌘b to build without deploying. Hopefully no errors appear.

phronmophobic 2021-06-29T15:34:55.189100Z

After that, you'll need to connect a device to deploy. I don't remember the exact steps it takes to set up a new device. It's something along the lines of: • Connect a device with USB • Select trust device on your phone • I think it prompts you for more steps when you try to deploy Check to make sure you have an Apple account connected: 1. Click on the MobileTest Project from the Project navigator in the left pane 2. Click on the MobileTest Target 3. Click on Signing and Capabilities

borkdude 2021-06-29T15:35:18.189400Z

but I could also run a simulator right?

phronmophobic 2021-06-29T15:35:29.189500Z

borkdude 2021-06-29T15:35:45.190400Z

I think macOS would force me to upgrade macOS to upload to my phone. It's a trick I've stumbled upon before

phronmophobic 2021-06-29T15:35:47.190600Z

In theory, I have not tried building for simluator

borkdude 2021-06-29T15:36:25.190800Z

do you usually test on a real phone?

phronmophobic 2021-06-29T15:37:25.191700Z

In general, I use the simulator to test, but I just wanted to see if I could get it working on my phone

borkdude 2021-06-29T15:38:26.192800Z

so how do I run on a simulator? I mean "choose a simulated device", I didn't know how to do this, this is why I posted the message. Sorry that I wasn't clear :)

phronmophobic 2021-06-29T15:39:37.193700Z

oh, right. It's a different target and architecture for native image, so I think it's just a matter of passing the right native-image flags

phronmophobic 2021-06-29T15:43:05.194200Z

oh, and you have to link against some java native libraries in xcode, so you would need those too

borkdude 2021-06-29T15:45:38.194500Z

ok, I'm going to try it your way first

borkdude 2021-06-29T15:45:44.194700Z

I expect xcode nags me to upgrade macos

phronmophobic 2021-06-29T15:46:07.195100Z

that sounds like something xcode might do

borkdude 2021-06-29T15:46:19.195300Z

I can confirm your newest script works on my machine

🎉 1
phronmophobic 2021-06-29T15:54:35.196400Z

Ok, it's unclear whether iOS simulator is supported by graalvm currently, https://github.com/oracle/graal/pull/3340

borkdude 2021-06-29T15:54:55.196700Z

@smith.adriane

phronmophobic 2021-06-29T15:56:06.197100Z

That seems pretty odd

phronmophobic 2021-06-29T15:56:42.197700Z

That @main statement is on the same line in my AppDelegate.swift file

phronmophobic 2021-06-29T15:57:00.198100Z

and it's just part of the boilerplate code generated from a new project

borkdude 2021-06-29T15:59:00.198300Z

🤷

borkdude 2021-06-29T15:59:58.198500Z

I can only build for ios 13.2

borkdude 2021-06-29T16:00:03.198700Z

maybe that's the reason

phronmophobic 2021-06-29T16:00:09.198900Z

ah, ok

phronmophobic 2021-06-29T16:00:44.199800Z

I tried setting the deployment target to 13.2 and it still built

borkdude 2021-06-29T16:00:47.199900Z

I will retry when I upgrade my OS but I only tend to do this when I have a new laptop ;)

borkdude 2021-06-29T16:00:51.200100Z

oh

phronmophobic 2021-06-29T16:01:32.200200Z

phronmophobic 2021-06-29T16:01:51.200800Z

Not sure my Xcode navigation is optimal, but that's how I navigate to that setting

borkdude 2021-06-29T16:03:22.200900Z

phronmophobic 2021-06-29T16:04:12.201400Z

Same error?

borkdude 2021-06-29T16:04:13.201500Z

I also get #include <jni.h> not found

borkdude 2021-06-29T16:04:19.201700Z

when I remove the @main

phronmophobic 2021-06-29T16:06:46.202Z

Oh, right you're using a different graalvm version

borkdude 2021-06-29T16:07:06.202400Z

21.1.0

borkdude 2021-06-29T16:07:18.202600Z

which one were you using?

phronmophobic 2021-06-29T16:07:31.202800Z

21.1.0

phronmophobic 2021-06-29T16:07:32.203Z

nvmd

phronmophobic 2021-06-29T16:07:53.203400Z

If you search graalvm, in the build settings, it should show the Header Search Paths

phronmophobic 2021-06-29T16:08:01.203700Z

One is /Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home/include/darwin/

borkdude 2021-06-29T16:08:50.204Z

oh right, I haven't installed graalvm like that

borkdude 2021-06-29T16:09:04.204400Z

I usually just download it in my Downloads folder and set the environment manually

borkdude 2021-06-29T16:09:09.204600Z

but I can fix that

borkdude 2021-06-29T16:09:54.205Z

I'll continue another time

phronmophobic 2021-06-29T16:09:58.205200Z

:thumbsup: