Unsupported iOS SDK after updating to MOE 1.9.0

Hi all!

We recently updated to 1.9.0 but it looks like we lost support for iOS 12.x.

We used to have this code with MOE 1.7.4:

    AVAudioSession.sharedInstance().setCategoryWithOptionsError(
            AVFoundation.AVAudioSessionCategoryPlayAndRecord(),
            AVAudioSessionCategoryOptions.DefaultToSpeaker,
            null

When we upgraded to MOE 1.9.0 then we needed to update the code above to:

    AVAudioSession.sharedInstance().setCategoryWithOptionsError(
            AVFAudio.AVAudioSessionCategoryPlayAndRecord(),
            AVAudioSessionCategoryOptions.DefaultToSpeaker,
            null
    );

This code fails on 12.4 with this:

2022-04-07 19:54:04.842 SurveyCTO Collect[29663:8003789] *** Terminating app due to uncaught exception 'java.lang.ExceptionInInitializerError', reason: 'java.lang.ExceptionInInitializerError
    at com.surveycto.collect.ios.application.Collect.<init>(Collect.java:139)
    at com.surveycto.collect.ios.application.Collect.getInstance(Collect.java:154)
    at com.surveycto.collect.ios.Main.applicationDidFinishLaunchingWithOptions(Main.java:45)
    at apple.uikit.c.UIKit.UIApplicationMain(Native Method)
    at com.surveycto.collect.ios.Main.main(Main.java:28)
    at java.lang.reflect.Method.invoke(Native Method)
    at org.moe.IOSLauncher.main(IOSLauncher.java:34)
Caused by: java.lang.RuntimeException: Failed to register class apple.avfaudio.AVAudioSession
    at org.moe.natj.general.NatJ.register(NatJ.java:270)
    at apple.avfaudio.AVAudioSession.<clinit>(AVAudioSession.java:37)
    ... 7 more

So, does this mean that we can no longer run the app in iOS 12.4?

i do believe there 's a mistake by building the MOE natives with the apple.avfaudio… package.
i have an audio interface implemented in MOE and also in RoboVM. In Moe, i had to change the imported packages names, in RoboVM also the most recent version still has the same package naming (org.robovm.apple.avfoundation).

So @Noisyfox, is it maybe possible to rename the package created in MOE 1.9.0 apple.avfoundation instead of apple.avfaudio… It’s just an assumption and could solve Meletis problem (even i do think i m going to run into the same problem, i just was not able to build my App in 1.9 yet :- (

The renaming of the package seems to be just the symptom of the error. It looks like Apple tries to rename the AVFoundation framework to AVFAudio (haven’t found anything documented, just a guess).
The MOE bindings were in 1.9.0 generated with the new AVFAudio framework, which doesn’t exist on iOS 12.x. Therefor NatJ fails trying to load the framework.
I as temporary solution may work:

  1. Create own bindings for AVFoundation and reference them. (Actually just create bindings for AVFAudio but change the @Library annotation)

What the solution could be on MOE’s side:

  1. Adding some fallback code somewhere to use AVFoundation if AVFAudio fails to load. (Or extend the @Library annotation)

Berstanio may be right @Meletis_Margaritis, i was yesterday finally able to compile, build and deploy my audio App, (which uses MOE 1.9.0 and newest AS, gradle 7… etc) on my own apple devices: mini13 wirth 15.3.1 (i m going to update it tonight to the newest 15.4.1), iPhone X -> 15.3.1 too and iPhose 5s, 12.5.5. So, try to build your apps with MOE 1.9.0.
In case you need support, don’t hesitate to ask, everyone is very friendly here :heart:

@yarnee, thank you for your reply!

I did try to build with MOE 1.9.0 but it made the app crash in iOS 12.4, that’s why I started this thread here

So, what exactly is your suggestion? To try to solve it with either approach #1 or #2 of Berstanio, or wait for the next MOE version that will solve it (hopefully)?

I’m not able to reproduce this issue on iOS 12.4 emulator and not able to acquire an iOS 12.4 device. Could you try adding “AVFoundation.framework” to your app in Xcode and see if that solves the crash issue on iOS 12.4? If that solves the problem then we might be able to fix this issue in the next release.

I’m able to also reproduce the issue in a 12.4 simulator.
And there it also doesn’t matter whether I link against AVFoundation or not, the crash always happens.

Odd… Could you send me a project that could reproduce this issue?