Skip to content

Fix native iOS Compilation Warnings #4566

@shai-almog

Description

@shai-almog

1) [asset-catalog] (41) - DONE

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/Images.xcassets:./AppIcon.appiconset/(null)[2d][Icon.png]: warning: The app icon set "AppIcon" has 3 unassigned children.
  • Initial root-cause analysis:
    • The generated Images.xcassets references icon/launch-image slots whose files are missing or unmapped in Contents.json.
    • This is likely due to legacy launch-image/icon templates being emitted without matching assets for all size idioms.

2) [-Wdeprecated-declarations] (10) - DONE

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/com_codenameone_examples_hellocodenameone_LocalNotificationNativeImpl.m:12:35: warning: 'scheduledLocalNotifications' is deprecated: first deprecated in iOS 10.0 - Use UserNotifications Framework's -[UNUserNotificationCenter getPendingNotificationRequestsWithCompletionHandler:] [-Wdeprecated-declarations]
  • Initial root-cause analysis:
    • App-native implementation still uses UILocalNotification era APIs.
    • Migration to UserNotifications (UNUserNotificationCenter, UNNotificationRequest) would remove these warnings.

iOS Port / Runtime Warnings

1) [-Wdeprecated-declarations] (1080)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/EAGLView.h:47:31: warning: 'EAGLContext' is deprecated: first deprecated in iOS 12.0 - OpenGLES API deprecated. (Define GLES_SILENCE_DEPRECATION to silence these warnings) [-Wdeprecated-declarations]
  • Initial root-cause analysis:
    • Major source is legacy OpenGL ES render path (EAGL*, gl*) and older iOS UI/media APIs.
    • Root issue is platform API modernization lag (Metal/AVKit/modern UIKit replacements not fully adopted).

2) [-Wshorten-64-to-32] (104)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/nativeMethods.m:301:70: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'JAVA_INT' (aka 'int') [-Wshorten-64-to-32]
  • Initial root-cause analysis:
    • Java bridge types (JAVA_INT) are 32-bit while iOS native integer types are often 64-bit on arm64.
    • Conversions happen without explicit range checks/casts.

3) [-Wunused-function] (16)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/Renderer.c:651:13: warning: unused function 'getSubpixMinY' [-Wunused-function]
  • Initial root-cause analysis:
    • Helper/static functions generated or retained for optional code paths are not referenced in the final compile unit.

4) [-Wnullability-completeness] (16)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/NetworkConnectionImpl.h:42:8: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
  • Initial root-cause analysis:
    • Objective-C headers predate modern nullability annotations.

5) [-Wpointer-sign] (14)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/IOSNative.m:8547:15: warning: assigning to 'jbyte *' (aka 'signed char *') from 'JAVA_ARRAY_BYTE *' (aka 'char *') converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
  • Initial root-cause analysis:
    • JNI-like bridge aliases char/signed char inconsistently for byte arrays.

6) [-Wundeclared-selector] (14)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/UIWebViewEventDelegate.m:96:58: warning: undeclared selector 'cn1FollowTargetBlank' [-Wundeclared-selector]
  • Initial root-cause analysis:
    • Dynamic selector checks are used without compile-time method declarations in visible headers/categories.

7) [-Wincompatible-pointer-types] (9)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/nativeMethods.m:1848:113: warning: incompatible pointer types sending 'char *' to parameter of type 'struct __va_list_tag *' [-Wincompatible-pointer-types]
  • Initial root-cause analysis:
    • Calls with varargs or pointer APIs use incorrect buffer types/signatures.

8) [-Wincompatible-pointer-types-discards-qualifiers] (8)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/IOSNative.m:9819:20: warning: initializing 'unsigned char *' with an expression of type 'const void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
  • Initial root-cause analysis:
    • const data is assigned into mutable pointers; qualifiers are dropped.

9) [-Wnonnull] (8)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/NetworkConnectionImpl.m:158:32: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
  • Initial root-cause analysis:
    • Code paths pass nil/NULL into APIs annotated nonnull.

10) [-Wpointer-to-int-cast] (6)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/nativeMethods.m:1066:12: warning: cast to smaller integer type 'JAVA_INT' (aka 'int') from 'JAVA_OBJECT' (aka 'struct JavaObjectPrototype *') [-Wpointer-to-int-cast]
  • Initial root-cause analysis:
    • Pointer values are encoded into 32-bit Java ints; unsafe on 64-bit platforms.

11) [other] (5)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/IOSNative.m:2333:17: warning: 'AudioPlayer' may not respond to 'stop'
  • Initial root-cause analysis:
    • Untyped/dynamic Objective-C receiver usage prevents compiler from proving method availability.

12) [-Wunsupported-availability-guard] (4)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/IOSNative.m:5431:23: warning: @available does not guard availability here; use if (@available) instead [-Wunsupported-availability-guard]
  • Initial root-cause analysis:
    • Availability macro appears in a context where it does not control execution flow.

13) [-Wobjc-missing-super-calls] (4)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/FillPolygon.m:200:1: warning: method possibly missing a [super dealloc] call [-Wobjc-missing-super-calls]
  • Initial root-cause analysis:
    • Manual memory-management patterns remain in code compiled with modern ARC expectations/checks.

14) [-Wobjc-method-access] (4)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/CN1TapGestureRecognizer.m:244:15: warning: instance method '-foldKeyboard:' not found (return type defaults to 'id') [-Wobjc-method-access]
  • Initial root-cause analysis:
    • Message send to receiver type lacking method declaration in scope.

15) [-Wint-to-void-pointer-cast] (4)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/IOSNative.m:1202:86: warning: cast to 'void *' from smaller integer type 'JAVA_INT' (aka 'int') [-Wint-to-void-pointer-cast]
  • Initial root-cause analysis:
    • Integer IDs/handles are reinterpreted as pointers in bridge plumbing.

16) [-Wincomplete-implementation] (4)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/EAGLView.m:45:17: warning: method definition for 'removePeerComponent:' not found [-Wincomplete-implementation]
  • Initial root-cause analysis:
    • Class/interface declares methods not implemented in that compile unit.

17) [-Wextra-tokens] (2)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/IOSNative.m:4386:7: warning: extra tokens at end of #endif directive [-Wextra-tokens]
  • Initial root-cause analysis:
    • Preprocessor directive formatting includes trailing tokens/comments in non-preferred form.

18) [-Wformat] (2)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/cn1_globals.m:657:91: warning: format specifies type 'long long' but the argument has type 'long' [-Wformat]
  • Initial root-cause analysis:
    • printf-style format specifier and argument C type mismatch.

19) [-Wliteral-range] (2)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/java_lang_Float.m:254:9: warning: floating-point comparison is always false; constant cannot be represented exactly in type 'float' [-Wliteral-range]
  • Initial root-cause analysis:
    • Constant chosen for float comparison cannot be represented in float precision.

20) [-Wmismatched-parameter-types] (2)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/CodenameOne_GLAppDelegate.m:449:167: warning: conflicting parameter types in implementation of 'userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:': 'void (^ _Nonnull)(void)' vs 'void (^ _Nonnull)()' [-Wmismatched-parameter-types]
  • Initial root-cause analysis:
    • Delegate method signature diverges from current SDK declaration.

21) [-Wnonportable-include-path] (2)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/CN1ES2compat.m:7:9: warning: non-portable path to file '<math.h>'; specified path differs in case from file name on disk [-Wnonportable-include-path]
  • Initial root-cause analysis:
    • Include-case mismatch tolerated on case-insensitive FS but flagged as non-portable.

22) [-Wobjc-designated-initializers] (2)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/ResetAffine.m:43:1: warning: designated initializer missing a 'super' call to a designated initializer of the super class [-Wobjc-designated-initializers]
  • Initial root-cause analysis:
    • Initializer chain does not call super’s designated initializer as required by modern Obj-C conventions.

23) [-Wobjc-multiple-method-names] (2)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/IOSNative.m:2333:13: warning: multiple methods named 'stop' found [-Wobjc-multiple-method-names]
  • Initial root-cause analysis:
    • Ambiguous selector resolution due to multiple candidates in visible interfaces.

24) [-Wunguarded-availability-new] (2)

  • Example:
    • dev/cn1/scripts/hellocodenameone/ios/target/hellocodenameone-ios-1.0-SNAPSHOT-ios-source/HelloCodenameOne-src/IOSNative.m:2659:75: warning: 'setInspectable:' is only available on iOS 16.4 or newer [-Wunguarded-availability-new]
  • Initial root-cause analysis:
    • API introduced in newer iOS version is referenced without fully effective availability guarding at call site.

Initial Prioritization Suggestion

  1. Reduce highest-noise categories first: [-Wdeprecated-declarations], [-Wshorten-64-to-32].
  2. Fix correctness-risk categories next: [-Wnonnull], pointer/integer cast families, and mismatched method signatures.
  3. Clean lower-risk hygiene categories after: nullability annotations, unused functions, include/path/style warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions