Fix iOS native stub -stop selector ambiguity on Xcode 26#5052
Merged
Conversation
The generated stub native_<class>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) <noreply@anthropic.com>
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Collaborator
Author
|
Compared 47 screenshots: 47 matched. |
Collaborator
Author
|
Compared 116 screenshots: 116 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
Collaborator
Author
|
Compared 116 screenshots: 116 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 116 screenshots: 116 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ptrto the lib's concrete peer class in the generated[ptr methodName...]message send, so clang resolves the selector against the lib's own@interfaceinstead of againstid.- (void)…selector exposed by AVFoundation / Foundation (e.g.stop,play,pause,start, …).Why
The generated stub
native_<class>ImplCodenameOne.mmessages the native peer through anid-typed pointer: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 thosevoiddeclarations when resolving the selector againstid, and the build fails with:(Reported in the wild against CN1Webserver, which has
-(BOOL)stop. HidingGCDWebServer.hin shannah/CN1Webserver#1 removed one source of collision but could not prevent AVFoundation — that header arrives transitively viaCodenameOne_GLViewController.h, so the same error reappears against AVFoundation's-stopoverloads.)Approach
The stub already
#imports<classNameWithUnderscores>Impl.h, which declares@interface <classNameWithUnderscores>Impl(a convention every cn1lib follows — verified across core tests, TestNativeInterfaces, parse4cn1, firebase-cn1, etc.). Castingptrat the message send gives clang a known receiver type so the selector resolves against the lib's@interface, not against the globalidpool.Runtime dispatch is unchanged — Objective-C method lookup is dynamic, the cast is a compile-time hint only. No cn1lib needs to be rebuilt once the new builder is deployed.
Test plan
start,stop,isRunning, etc. continue to function at runtime.🤖 Generated with Claude Code