question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iOS: Custom step download_realm.js fails -> Build error "realm/util/assert.hpp" not found

See original GitHub issue

Goals

Just installing/building realm for use in a React Native iOS app.

Expected Results

As a pre-build step, the RealmJS target executes node ../scripts/download-realm.js ios --sync, which should populate the vendor directory with some code and build dependencies.

Actual Results

The script fails, apparently because the wrong version of lzma-native is being run/built:

PhaseScriptExecution Download\ Core <snip>

Extracting realm-sync-cocoa-2.0.2.tar.xz => <myproject>l/node_modules/realm/vendor/realm-ios
{ Error: Cannot find module '<myproject>/node_modules/lzma-native/binding-v3.0.1-node-v51-darwin-x64/lzma_native.node'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at <myproject>/node_modules/lzma-native/index.js:13:14
    at Object.<anonymous> (<myproject>/node_modules/lzma-native/index.js:595:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12) code: 'MODULE_NOT_FOUND' }

Then on the compilation step:

CompileC <snip>/RealmJS.build/Objects-normal/arm64/index_set.o object-store/src/index_set.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler

<myproject>/node_modules/realm/src/object-store/src/index_set.cpp:21:10: fatal error: 'realm/util/assert.hpp' file not found
#include <realm/util/assert.hpp>
         ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Build failed    18/10/2017, 12:10

lzma-native is present (v3.0.1) but doesn’t contain the particular binding node wants:

ll node_modules/lzma-native
total 144
-rw-r--r--    1 rob  staff   4.4K  4 Jul 21:56 CHANGELOG.md
-rw-r--r--    1 rob  staff   1.1K 27 Apr  2016 LICENSE
-rw-r--r--    1 rob  staff    23K 24 Mar  2017 README.md
drwxr-xr-x    3 rob  staff   102B 17 Oct 23:00 bin
drwxr-xr-x    3 rob  staff   102B 17 Oct 23:00 binding-v1.5.3-node-v53-linux-x64
drwxr-xr-x    3 rob  staff   102B 17 Oct 23:00 binding-v2.0.0-node-v53-linux-x64
drwxr-xr-x    3 rob  staff   102B 17 Oct 23:00 binding-v2.0.1-node-v55-linux-x64
drwxr-xr-x    3 rob  staff   102B 17 Oct 23:00 binding-v2.0.2-node-v55-linux-x64
drwxr-xr-x    3 rob  staff   102B 17 Oct 23:00 binding-v2.0.3-node-v56-linux-x64
drwxr-xr-x    3 rob  staff   102B 17 Oct 23:00 binding-v2.0.4-electron-v1.7-linux-x64
drwxr-xr-x    3 rob  staff   102B 17 Oct 23:00 binding-v2.0.4-node-v48-linux-x64
drwxr-xr-x    3 rob  staff   102B 17 Oct 23:00 binding-v2.0.4-node-v56-linux-x64
drwxr-xr-x    3 rob  staff   102B 17 Oct 23:00 binding-v3.0.0-electron-v1.7-linux-x64
drwxr-xr-x    3 rob  staff   102B 17 Oct 23:00 binding-v3.0.0-node-v56-linux-x64
drwxr-xr-x    3 rob  staff   102B 17 Oct 23:01 binding-v3.0.1-node-v48-darwin-x64
drwxr-xr-x    3 rob  staff   102B 17 Oct 23:00 binding-v3.0.1-node-v56-linux-x64
-rw-r--r--    1 rob  staff   3.1K 24 Mar  2017 binding.gyp
-rwxr-xr-x    1 rob  staff   253B 12 Jan  2016 cflags.sh
drwxr-xr-x   12 rob  staff   408B 17 Oct 23:00 deps
-rw-r--r--    1 rob  staff    14K  4 Jul 21:55 index.js
-rwxr-xr-x    1 rob  staff    52B 28 Sep  2015 liblzma-build.sh
-rwxr-xr-x    1 rob  staff   443B 12 Jan  2016 liblzma-config.sh
drwxr-xr-x  111 rob  staff   3.7K 18 Oct 11:50 node_modules
-rw-r--r--    1 rob  staff   1.5K  4 Jul 21:55 package.json
drwxr-xr-x   11 rob  staff   374B 17 Oct 23:00 src

If I run the script manually (outside xcode) it succeeds:

node ../scripts/download-realm.js ios --sync
Extracting realm-sync-cocoa-2.0.2.tar.xz => <myproject>/node_modules/realm/vendor/realm-ios

(../vendor/ream-ios is now populated) However the build still fails unless I also remove the pre-build step from xcode, because a failed execution appears to wipe the realm-ios directory.

Whenever yarn reinstalls realm, I need to repeat this process. I’ve tried totally cleaning everything out - node_modules, yarn cache clean, Clean build in xcode, removing Derived data, to no avail. For some reason I always end up with a mismatched lzma-native build.

Steps to Reproduce

yarn add realm@2.0.0
react-native link realm
...build in xcode

Code Sample

Version of Realm and Tooling

  • Realm JS SDK Version: 2.0.0
  • Node or React Native: React Native 0.49, Node 6.3.1, yarn 0.27.5
  • Client OS & Version: macOS Sierra building for iOS 11
  • Which debugger for React Native: N/A (build issue)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
pekqcommented, Nov 21, 2017

After some debugging I found Xcode uses node from /usr/local/bin/ directory.

$ node --version
v7.6.0
$ /usr/local/bin/node --version
v6.2.2

So syncing both node versions to 7.6.0 fixed the issue and the download script didn’t fail anymore.

1reaction
gino8080commented, Nov 2, 2017

both versions on xterm e “regular term” are 7.10.1

but i keep the similar error of

Resolved requirements: { SYNC_SERVER_FOLDER: 'sync', SYNC_ARCHIVE: 'realm-sync-cocoa-2.1.0.tar.xz', SYNC_ARCHIVE_ROOT: 'core' } No lockfile found at the target, proceeding. Extracting realm-sync-cocoa-2.1.0.tar.xz => /Users/magic/PROJECTS/REACT_NATIVE/happysalus_police/node_modules/realm/vendor/realm-ios { Error: Cannot find module '/Users/magic/PROJECTS/REACT_NATIVE/happysalus_police/node_modules/lzma-native/binding-v3.0.1-node-v57-darwin-x64/lzma_native.node' at Function.Module._resolveFilename (module.js:513:15) at Function.Module._load (module.js:463:25) at Module.require (module.js:556:17) at require (internal/module.js:11:18) at /Users/magic/PROJECTS/REACT_NATIVE/happysalus_police/node_modules/lzma-native/index.js:13:14 at Object.<anonymous> (/Users/magic/PROJECTS/REACT_NATIVE/happysalus_police/node_modules/lzma-native/index.js:595:3) at Module._compile (module.js:612:30) at Object.Module._extensions..js (module.js:623:10) at Module.load (module.js:531:32) at tryModuleLoad (module.js:494:12) code: 'MODULE_NOT_FOUND' } Command /bin/sh failed with exit code 1

Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS swift app build fails with cyclic dependency error in Xcode ...
I use cmake to set the dependencies and generate the Xcode project. What is this error? What am I missing here? I've been...
Read more >
Troubleshooting for React Native | Sentry Documentation
iOS Build Script Failed. Try passing --force-foreground to the Sentry CLI command in the build script. This is possibly a bug with our...
Read more >
Xcode 14 Release Notes | Apple Developer Documentation
Workaround: Build AppIntents code with Xcode 14 beta 6, or on a Mac running macOS Monterey 12 with Xcode 14. Xcode 14 cannot...
Read more >
Read and Write Data on Apple platforms - Firebase - Google
Before talking about how your app reads from and writes to Realtime Database, let's introduce a set of tools you can use to...
Read more >
Troubleshooting iOS - OneSignal Documentation
Common setup issues with iOS. ... Troubleshooting iOS Steps ... when iOS doesn't fire a success or failure message if a connection is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found