iOS: Custom step download_realm.js fails -> Build error "realm/util/assert.hpp" not found
See original GitHub issueGoals
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:
- Created 6 years ago
- Comments:14 (3 by maintainers)

Top Related StackOverflow Question
After some debugging I found Xcode uses node from
/usr/local/bin/directory.So syncing both node versions to
7.6.0fixed the issue and the download script didn’t fail anymore.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