Few cents about my commits

Experiment 3: XrOS (Vision OS) support

|

Experiment 3 of RoboVMx started to play with additional platforms (such as TvOS). There was an interest for use RoboVM with XrOS project in gitter recently and this looks like a good point to kick off this experiment.
VisionOS SKS are mostly swift based and this a problem to provide bindings to RoboVM. But anyway its good point to just get RoboVM Java VM code running in RxOS environment. And first stage is to allow RoboVM to be available in Xcode project as framework.

How to use

Sadly at moment of writing there was no Xcode15 Beta2 Github Action runners available. Way to test it is to build it from source of this branch RoboVMX:experiments/experiment/3-additional-platforms.

  • Short story: run build.sh in root of source tree.
  • Long story: check MobiVM/Wiki for details.

To produce Framework for XrOS, robovm.xml should be adapted in following places:

<config>
    <!-- The framework targets XrOS. -->
    <os>xros</os>
    <arch>arm64</arch>
    <arch>arm64-simulator</arch>
    <target>xcframework</target>
    
    ....
    
</config>    

Technical details

Same as in Experiment#1: m1 support binary has to specify valid XrOS platform type in MachO/LC_BUILD_VERSION load command. It has to be in both: VM runtime binaries and object files produced from Java class files.

Compiling VM libs for XrOS

These steps are very common as with adding m1, to compile for XrOS changes related to adding two targets to CMakeFile:

  • “arm64-apple-xros${XROS_MIN_VERSION}-simulator”
  • “arm64-apple-xros${XROS_MIN_VERSION}”

Xcode 15.0 Beta2 with VisionOS runtime installed required to compile. All changes are in this commit.

Adapting LLVM

8 year old LLVM v3.6 knows nothing about XrOS. Will add changes there with patch. Lucky for me, LC_BUILD_VERSION support already was added there during m1 support integration. Changes related to add XrOS constant and related code to parse arm64-apple-xros1.0-simulator target and produce platform type (11, 12) in LC_BUILD_VERSION. Confusing things – these changes are not public yet, so had to introduce own name for these constants:

enum PlatformType {
    PLATFORM_MACOS = 1,
    PLATFORM_IOS = 2,
    PLATFORM_TVOS = 3,
    PLATFORM_WATCHOS = 4,
    PLATFORM_BRIDGEOS = 5,
    PLATFORM_MACCATALYST = 6,
    PLATFORM_IOSSIMULATOR = 7,
    PLATFORM_TVOSSIMULATOR = 8,
    PLATFORM_WATCHOSSIMULATOR = 9,
    PLATFORM_DRIVERKIT = 10,
   
    PLATFORM_XROS = 11,
    PLATFORM_XROSSIMULATOR = 12
 };

All changes are in this commit.

RoboVM compiler adaptation

Nothing special, just adding OS.xros enum entry and fixing everything around to get Framework built. All changes are in this commit.

Bonus

As a bonus, Framework target now is not limited to iOS only and can produce MacOS/XrOS binaries.

Code available on github as RoboVMx/Experiment3

Happy coding!

Please report any issue to tracker.

Comments