Handling third party build error on react-native 0.46x.

Jerry Han
3 min readAug 1, 2017

--

You may got an below build failed error messages with ‘react-native run-ios’.

  • `boost/iterator/iterator_adaptor.hpp’ file not found`
  • `An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2)`
  • or any error related with ‘third-party’ : glog, boost, folly.

With the react-native 0.46x, it uses four third party library for ios build. These files are downloaded from github with curl command.

The problem is from the curl command and pressing ctrl + c key by user.

In the build phase, the react-native script trying to download the third party lib via curl command like below.

/bin/sh -c /Volumes/Data/Workspace/react_native/AwesomeProjectN/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/double-conversion.build/Script-190EE32F1E6A43DE00A8543A.sh% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed100   119    0   119    0     0     14      0 --:--:--  0:00:08 --:--:--    28100  510k  100  510k    0     0  52938      0  0:00:09  0:00:09 --:--:--  353kcurl: Saved to filename 'glog-0.3.4.tar.gz'% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed100   132    0   132    0     0    156      0 --:--:-- --:--:-- --:--:--   156100 6847k  100 6847k    0     0   131k      0  0:00:52  0:00:52 --:--:--  139kcurl: Saved to filename 'double-conversion-1.1.5.tar.gz'% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed100   609    0   609    0     0    449      0 --:--:--  0:00:01 --:--:--   449100 11.7M  100 11.7M    0     0   173k      0  0:01:09  0:01:09 --:--:-- 86426curl: Saved to filename 'boost_1_63_0.tar.gz'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 130 0 130 0 0 131 0 --:--:-- --:--:-- --:--:-- 131100 1504k 100 1504k 0 0 85857 0 0:00:17 0:00:17 --:--:-- 92229curl: Saved to filename 'folly-2016.09.26.00.tar.gz'=== BUILD TARGET third-party OF PROJECT React WITH CONFIGURATION Debug ===

And this download was invoked in shell script.

#!/bin/bash#boostdir="`node ./node_modules/boost-lib/bin/boost-lib download -V 1.63`"
#cd "$boostdir"
#./bootstrap.sh
#./b2 headers
set -ecachedir="$HOME/.rncache"
mkdir -p "$cachedir"
function fetch_and_unpack () {
file=$1
url=$2
cmd=$3
if [ ! -f "$cachedir/$file" ]; then
(cd "$cachedir"; curl -J -L -O "$url")
fi
dir=$(basename "$file" .tar.gz)
if [ ! -d "third-party/$dir" ]; then
(cd third-party;
echo Unpacking "$cachedir/$file"...
tar zxf "$cachedir/$file"
cd "$dir"
eval "${cmd:-true}")
fi
}
mkdir -p third-partySCRIPTDIR=$(dirname "$0")fetch_and_unpack glog-0.3.4.tar.gz https://github.com/google/glog/archive/v0.3.4.tar.gz "$SCRIPTDIR/ios-configure-glog.sh"
fetch_and_unpack double-conversion-1.1.5.tar.gz https://github.com/google/double-conversion/archive/v1.1.5.tar.gz
fetch_and_unpack boost_1_63_0.tar.gz https://github.com/react-native-community/boost-for-react-native/releases/download/v1.63.0-0/boost_1_63_0.tar.gz
fetch_and_unpack folly-2016.09.26.00.tar.gz https://github.com/facebook/folly/archive/v2016.09.26.00.tar.gz

As you see, in happy scenario, all of third party libraries will be downloaded successfully.

But frequently, this download process is not done well. (I don’t know why github does not provide enough bandwidth for http download request.)
And the build process even looks like hanged by low speed of download.
That’s why users are interrupt the build process by pressing ctrl + c in here. ( I also did that. )

When the download process was interrupted, the curl command do not handle the unfinished or interrupted download file. It just save incomplete file to target file name.
It means that you may have broken .gz files in ~/.rncache folder.
And it causes the many build failed with file not found errors at build phase.

You should wait till the Saved to filename message be shown on console.
If your build trial failed, you should clean all files on ~/.rncache folder and rerun react-native run-ios command.

The correct size of libraries are below.

-rw-r--r--   1 jerry  staff   1.5M Aug  2 00:39 folly-2016.09.26.00.tar.gz
-rw-r--r-- 1 jerry staff 12M Aug 2 00:38 boost_1_63_0.tar.gz
-rw-r--r-- 1 jerry staff 6.7M Aug 2 00:37 double-conversion-1.1.5.tar.gz
-rw-r--r-- 1 jerry staff 510K Aug 2 00:36 glog-0.3.4.tar.gz

If you get any third-party library build error with react-native run-ios command:

  1. clean ~/.rncache folder.
  2. Download 4 third party library by manual
    or
    Rerun the
    react-native run-ios command and wait to print
    curl: Saved to filename message.
    You should check 100% Received status.
    Never press the ctrl+c on build phase.

Thanks for reading.

--

--