WatermelonDB icon indicating copy to clipboard operation
WatermelonDB copied to clipboard

cannot find installWatermelonJSI & watermelondbProvideSyncJson in scope

Open conghai opened this issue 3 years ago • 14 comments

My source code build ios app on MacOS chip M1: success But fail if build it on MacOS chip Intel x86_64

both same:

  • MacOS 12.1
  • Xcode: 13.2.1 ---- and ----
  • MacOS 12.0
  • Xcode: 13.2.0
› Compiling @nozbe/watermelondb Pods/WatermelonDB » std_ext.swift
› Compiling @nozbe/watermelondb Pods/WatermelonDB » DatabaseBridge.swift

❌  (node_modules/@nozbe/watermelondb/native/ios/WatermelonDB/DatabaseBridge.swift:93:13)

  91 |         methodQueue.sync {
  92 |             // swiftlint:disable all
> 93 |             installWatermelonJSI(bridge as? RCTCxxBridge)
     |             ^ cannot find 'installWatermelonJSI' in scope
  94 |         }
  95 |         return [:]
  96 |     }


❌  (node_modules/@nozbe/watermelondb/native/ios/WatermelonDB/DatabaseBridge.swift:103:9)

  101 |                          resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
  102 |         var error: NSError?
> 103 |         watermelondbProvideSyncJson(id.int32Value, json.data(using: String.Encoding.utf8.rawValue), &error)
      |         ^ cannot find 'watermelondbProvideSyncJson' in scope
  104 |         if let error = error {
  105 |             sendReject(reject, error)
  106 |         } else {

› Compiling @nozbe/watermelondb Pods/WatermelonDB » Database.swift
› Compiling @nozbe/watermelondb Pods/WatermelonDB » DatabaseDriver.swift

My package:

"@nozbe/watermelondb": "~0.24.0",
"expo": "^44.0.0",
"react-native": "0.64.3",

I don't know why? Please help me.

Thanks so much

conghai avatar Dec 22 '21 09:12 conghai

I'm having exactly the same issue. Happened to me when migrating from Unimodules to Expo Modules. I found out that my build runs if I remove either Watermelon or Expo from the project, but I need them both, obviously. I'm clueless as to why Watermelon breaks instead of Expo... Xcode be Xcode.

Yarkhan avatar Dec 22 '21 20:12 Yarkhan

I've also been able to reproduce this issue with a clean RN0.64.2 + Expo + Watermelon

Yarkhan avatar Dec 23 '21 16:12 Yarkhan

I'm having the same issue too, used https://www.npmjs.com/package/@morrowdigital/watermelondb-expo-plugin to add watermelon support to my dev client. Building with expo run:platform returns the error described in the title and building with EAS fails on fastlane step

thecoorum avatar Dec 27 '21 11:12 thecoorum

I wrote an issue on plugin repo (issue) and got an answer that the plugin is incompatible with Expo v44 SDK yet, but they are saying that the issue should be resolved soon

thecoorum avatar Dec 27 '21 12:12 thecoorum

Just to reiterate, this is a bare (react-native init) project, not an Expo one. The error seems to occur in all react native versions since expo SDK43, which deprecated unimodules in favor of expo-modules.

To reproduce the issue:

  • Create a new RN project: npx react-native init test
  • Installl watermelonDB (as per instructed in the docs https://nozbe.github.io/WatermelonDB/Installation.html)
  • Install Expo Modules npx install-expo-modules

Yarkhan avatar Jan 10 '22 16:01 Yarkhan

@Yarkhan I'm using Expo 43 on a bare project with expo-modules and it compiles fine. At least for me, it's only upgrading to Expo 44 that breaks it.

dmarkow avatar Jan 10 '22 17:01 dmarkow

@Yarkhan I'm using Expo 43 on a bare project with expo-modules and it compiles fine. At least for me, it's only upgrading to Expo 44 that breaks it.

The same for me

thecoorum avatar Jan 10 '22 17:01 thecoorum

@dmarkow Yes, I wish I've tested SDK43 before commenting, lol. I've just tested it and it works fine with Expo SDK43 npx install--expo-modules --sdk-version 43.0.0. It seems the problem is with Expo after all, it maybe messing with Watermelon bridging or something. I will open an issue there later.

Yarkhan avatar Jan 10 '22 17:01 Yarkhan

yup same for me, expo 44 breaks it.. 43 works like a charm

enahum avatar Jan 20 '22 17:01 enahum

I've created an issue on the Expo repository. https://github.com/expo/expo/issues/15986

Yarkhan avatar Jan 20 '22 21:01 Yarkhan

Expo44 is breaking a handful of other libraries as well. https://github.com/expo/expo/issues/15622

In any case, Expo is the culprit here, and I think this issued can be closed here and tracked on the Expo repository.

Yarkhan avatar Jan 20 '22 21:01 Yarkhan

The good folk at Expo sent a pull request fixing this problem (https://github.com/Nozbe/WatermelonDB/pull/1249). I've tested it and it works. It is a simple fix, something to do with "old style / new style" import headers.

I'm using patch-package to get the fixes applied to my project while the pull request gets reviewed.

Yarkhan avatar Jan 25 '22 14:01 Yarkhan

@Yarkhan how do I do that?

jhonatabonadio1 avatar Mar 03 '22 03:03 jhonatabonadio1

@jhonatabonadio1

  1. Setup patch-package in your project
  2. After installing watermelonDB, find these two files in your node_modules directory and make the changes: https://github.com/Nozbe/WatermelonDB/pull/1249/files
  3. Run patch-package @nozbe/watermelondb and commit the patch files until a future, fixed version is released

jwoo92 avatar May 01 '22 18:05 jwoo92