expo / expo

An open-source framework for making universal native apps with React. Expo runs on Android, iOS, and the web.
https://docs.expo.dev
MIT License
34.67k stars 5.57k forks source link

[Expo Modules iOS] Values in dictionary are passed as Optionals #32692

Open abulenok opened 2 weeks ago

abulenok commented 2 weeks ago

Minimal reproducible example

https://github.com/abulenok/expo-bug-repro/tree/main

What platform(s) does this occur on?

iOS

Where did you reproduce the issue?

in a development build

Summary

Here is a function in ios/NvmModule.swift:

AsyncFunction("hello") { (_ params: [String: Any], promise: Promise) in
      print(params)
      promise.resolve(
        (params.flatMap({ (key, value) -> String in
          return "\(key)=\(value)"
        }) as Array).joined(separator: ";")
      )
    }.runOnQueue(.main)

When calling it from js with the following object, the swift code receives "boo" value wrapped in Optional.

NvmModule.hello({"foo":"boo"});

In the bare react native module "boo" value is passed without Optional. On Android this works properly.

Environment

expo-env-info 1.2.0 environment info:
    System:
      OS: macOS 15.0
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 22.9.0 - /usr/local/bin/node
      Yarn: 1.22.22 - /opt/homebrew/bin/yarn
      npm: 10.8.3 - ~/n/bin/npm
    Managers:
      CocoaPods: 1.15.2 - /Users/oleksiibulenok/.rvm/gems/ruby-3.2.2/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 24.0, iOS 18.0, macOS 15.0, tvOS 18.0, visionOS 2.0, watchOS 11.0
      Android SDK:
        API Levels: 34, 35
        Build Tools: 34.0.0, 35.0.0
        System Images: android-34 | Android TV ARM 64 v8a, android-34 | Google TV ARM 64 v8a, android-35 | Google Play ARM 64 v8a
    IDEs:
      Android Studio: 2024.1 AI-241.19072.14.2412.12360217
      Xcode: 16.0/16A242d - /usr/bin/xcodebuild
    npmGlobalPackages:
      eas-cli: 12.6.0
    Expo Workflow: bare

Expo Doctor Diagnostics

N/A
abulenok commented 2 weeks ago

discovered by @maxnfl