From e2303bf8deee0c751398960da4c6fbbcb7a70746 Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Wed, 27 May 2026 20:38:24 +0300 Subject: [PATCH] Fix iOS native interface stub -stop selector ambiguity on Xcode 26 The generated stub native_ImplCodenameOne.m messages the native peer through an `id`-typed pointer: id ptr = (id)get_field_..._nativePeer(me); JAVA_BOOLEAN returnValue = [ptr stop]; On the iOS 26 SDK, AVFoundation pulls in many classes with `- (void)stop` (AVAudioEngine, AVAudioPlayer, AVAudioPlayerNode, AVAudioRecorder, AVAudioSequencer, AVMIDIPlayer, AVCaptureExternalDisplayConfigurator, NSNetServices, ...). Clang in Xcode 26 picks one of those `void` declarations when resolving the selector against `id`, and the build fails with: error: initializing 'JAVA_BOOLEAN' (aka 'int') with an expression of incompatible type 'void' Hiding GCDWebServer.h (CN1Webserver PR #1) removed one source of collision but cannot prevent AVFoundation -- that header is imported transitively via CodenameOne_GLViewController.h, so the same crash reappears. Cast `ptr` to the lib's concrete peer class at the message send so clang resolves the selector against the @interface in the lib's own header (which is already #imported by the stub). Runtime dispatch is unchanged (ObjC is dynamic), so no cn1lib needs rebuilding. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../src/main/java/com/codename1/builders/IPhoneBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/IPhoneBuilder.java b/maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/IPhoneBuilder.java index 4b224eebc5..b47e005299 100644 --- a/maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/IPhoneBuilder.java +++ b/maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/IPhoneBuilder.java @@ -1438,7 +1438,7 @@ public void usesClassMethod(String cls, String method) { if(!(returnType.equals(Void.class) || returnType.equals(Void.TYPE))) { mFileBody += " " + typeToXMLVMName(returnType) + " returnValue = " + convertToJavaMethod(returnType); } - mFileBody += "[ptr " + name; + mFileBody += "[((" + classNameWithUnderscores + "Impl*)ptr) " + name; if(returnType.getName().equals("com.codename1.ui.PeerComponent")) { javaImplSourceFile += " public native long " + name + "(";