Skip to content

Release build crash: PushNotificationIOS re-export from react-native core #509

@antonijap

Description

@antonijap

Reproduction: https://github.com/antonijap/uniwind-pushnotification-repro

Clone, install, run a release build on iOS:

git clone https://github.com/antonijap/uniwind-pushnotification-repro
cd uniwind-pushnotification-repro
npm install
npx expo run:ios --configuration Release

App crashes on launch. Works fine in dev mode.


src/components/index.ts line ~199 re-exports PushNotificationIOS from react-native:

get PushNotificationIOS() {
    return require('react-native').PushNotificationIOS
},

RN removed this from core (deprecated since 0.60). Dev mode does not crash because Metro lazy-evaluates the getter. Release builds evaluate all getters eagerly, which triggers:

uniwind/src/components/index.ts:200
-> react-native/Libraries/PushNotificationIOS/PushNotificationIOS.js:67
-> new NativeEventEmitter() with null argument -> crash

Errors:

ERROR [Invariant Violation: new NativeEventEmitter() requires a non-null argument.]
ERROR [TypeError: Cannot read property 'default' of undefined]

We are patching via postinstall (return null instead of the require). Clipboard in the same file is also deprecated and could hit the same thing.

  • uniwind 1.6.3
  • react-native 0.83.6
  • Expo SDK 55
  • iOS release build

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions