1#!/bin/bash 2# Copyright (c) Meta Platforms, Inc. and affiliates. 3# 4# This source code is licensed under the MIT license found in the 5# LICENSE file in the root directory of this source tree. 6 7# This script validates that iOS is set up correctly for the 8# testing environment. 9# 10# In particular, it checks that the minimum required Xcode version is installed. 11# It also checks that the correct Node version is installed. 12 13# Function used to compare dot separated version numbers 14function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; } 15 16# Check that node is installed. 17if [ -z "$(which node)" ]; then 18 echo "Could not find Node binary. Please check your nodejs install." 19 echo "See https://reactnative.dev/docs/getting-started for instructions." 20 exit 1 21fi 22 23# Check that the correct version of node is installed 24NODE_VERSION="$(command node --version | sed 's/[-/a-zA-Z]//g' |sed 's/.\{2\}$//')" 25 26if (( $(echo "${NODE_VERSION} < 14.0" | bc -l) )); then 27 echo "Node ${NODE_VERSION} detected. This version of Node is not supported." 28 echo "See https://reactnative.dev/docs/getting-started for instructions." 29 exit 1 30fi 31 32# Check that Xcode is installed. 33if [ -z "$(which xcodebuild)" ]; then 34 echo "Could not find Xcode build tools. Please check your Xcode install." 35 echo "See https://reactnative.dev/docs/getting-started for instructions." 36 exit 1 37fi 38 39MIN_XCODE_VERSION=9.4 40# Check that the correct version of Xcode is installed 41XCODE_VERSION="$(command xcodebuild -version | sed '$ d' | sed 's/[-/a-zA-Z]//g')" 42if (version_gt $MIN_XCODE_VERSION $XCODE_VERSION) && [ "$XCODE_VERSION" != "$MIN_XCODE_VERSION" ]; then 43 echo "Xcode ${XCODE_VERSION} detected. React Native requires ${MIN_XCODE_VERSION} or newer." 44 echo "Older versions of Xcode may cause cryptic build errors." 45 echo "See https://reactnative.dev/docs/getting-started for instructions." 46 exit 1 47fi 48