2015-12-16 02:02:20 +00:00
|
|
|
set -o pipefail
|
|
|
|
set -e
|
|
|
|
|
|
|
|
while pgrep -q Simulator; do
|
|
|
|
# Kill all the current simulator processes as they may be from a
|
|
|
|
# different Xcode version
|
|
|
|
pkill Simulator 2>/dev/null || true
|
|
|
|
# CoreSimulatorService doesn't exit when sent SIGTERM
|
|
|
|
pkill -9 Simulator 2>/dev/null || true
|
|
|
|
done
|
|
|
|
|
2015-12-17 02:14:14 +00:00
|
|
|
|
2015-12-16 02:02:20 +00:00
|
|
|
DESTINATION="-destination id=$(xcrun simctl list devices | grep -v unavailable | grep -m 1 -o '[0-9A-F\-]\{36\}')"
|
|
|
|
TARGET=$1
|
|
|
|
CONFIGURATION=${2:-"Debug"}
|
2015-12-17 18:56:08 +00:00
|
|
|
PACKAGER_OUT="packager_out.txt"
|
|
|
|
|
|
|
|
function start_packager()
|
|
|
|
{
|
|
|
|
if [ -f $PACKAGER_OUT ]; then
|
|
|
|
rm $PACKAGER_OUT
|
|
|
|
fi
|
|
|
|
react-native start > packager_out.txt &
|
|
|
|
while :;
|
|
|
|
do
|
|
|
|
if grep -Fxq "React packager ready." packager_out.txt
|
|
|
|
then
|
|
|
|
break
|
|
|
|
else
|
|
|
|
echo "Waiting for packager."
|
|
|
|
sleep 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function kill_packager()
|
|
|
|
{
|
|
|
|
if [ -f $PACKAGER_OUT ]; then
|
|
|
|
rm $PACKAGER_OUT
|
|
|
|
fi
|
|
|
|
|
|
|
|
pkill node || true
|
|
|
|
}
|
|
|
|
|
|
|
|
kill_packager
|
2015-12-16 02:02:20 +00:00
|
|
|
|
|
|
|
if [ "$TARGET" = "realmjs" ]; then
|
|
|
|
xcodebuild -scheme RealmJS -configuration "$CONFIGURATION" -sdk iphonesimulator $DESTINATION build test
|
|
|
|
elif [ "$TARGET" = "react-tests" ]; then
|
|
|
|
pushd tests/react-test-app
|
2015-12-16 02:18:18 +00:00
|
|
|
if [ -f ../../target=node_modules/react_tests_node_modules.zip ]; then
|
|
|
|
unzip ../../target=node_modules/react_tests_node_modules.zip
|
|
|
|
fi
|
2015-12-17 02:14:14 +00:00
|
|
|
npm update react-native
|
2015-12-17 18:56:08 +00:00
|
|
|
start_packager
|
2015-12-16 02:02:20 +00:00
|
|
|
popd
|
|
|
|
|
|
|
|
xcodebuild -scheme RealmReact -configuration "$CONFIGURATION" -sdk iphonesimulator $DESTINATION build test
|
|
|
|
elif [ "$TARGET" = "react-example" ]; then
|
|
|
|
pushd examples/ReactExample
|
2015-12-16 02:18:18 +00:00
|
|
|
if [ -f ../../target=node_modules/react_example_node_modules.zip ]; then
|
|
|
|
unzip ../../target=node_modules/react_example_node_modules.zip
|
|
|
|
fi
|
2015-12-17 02:14:14 +00:00
|
|
|
npm update react-native
|
2015-12-17 18:56:08 +00:00
|
|
|
start_packager
|
|
|
|
|
2015-12-16 02:02:20 +00:00
|
|
|
xcodebuild -scheme ReactExample -configuration "$CONFIGURATION" -sdk iphonesimulator build $DESTINATION
|
|
|
|
popd
|
2015-12-17 02:14:14 +00:00
|
|
|
else
|
|
|
|
echo "Invalid target '${TARGET}'"
|
2015-12-16 02:02:20 +00:00
|
|
|
fi
|
|
|
|
|
2015-12-17 18:56:08 +00:00
|
|
|
kill_packager
|
2015-12-16 02:02:20 +00:00
|
|
|
|