#!/bin/bash set -o pipefail set -e usage() { cat < Cartfile else echo "github \"realm/realm-cocoa\" \"${sha:-master}\"" > Cartfile fi if [[ $PLATFORM == ios ]]; then carthage update --platform iOS elif [[ $PLATFORM == osx ]]; then carthage update --platform Mac elif [[ $PLATFORM == watchos ]]; then carthage update --platform watchOS fi ) elif [[ $LANG == swift* ]]; then download_zip_if_needed swift else download_zip_if_needed $LANG fi DESTINATION="" if [[ $PLATFORM == ios ]]; then simulator_id="$(xcrun simctl list devices | grep -v unavailable | grep -m 1 -o '[0-9A-F\-]\{36\}')" xcrun simctl boot $simulator_id DESTINATION="-destination id=$simulator_id" elif [[ $PLATFORM == watchos ]]; then if xcrun simctl list devicetypes | grep -q 'iPhone Xs'; then DESTINATION="-destination id=$(xcrun simctl list devices | grep -v unavailable | grep 'iPhone Xs' | grep -m 1 -o '[0-9A-F\-]\{36\}')" fi fi CMD="-project $PROJECT" if [ -d $WORKSPACE ]; then CMD="-workspace $WORKSPACE" fi ACTION="" if [[ $PLATFORM == watchos ]]; then ACTION="build" else ACTION="build test" fi if [[ $PLATFORM == ios ]]; then xcodebuild $CMD -scheme $NAME clean $ACTION $DESTINATION CODE_SIGN_IDENTITY= else xcodebuild $CMD -scheme $NAME clean $ACTION $DESTINATION CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO fi } swiftpm() { PLATFORM="$1" cd SwiftPMExample xcrun swift build } source "$(dirname "$0")/../../scripts/swift-version.sh" set_xcode_and_swift_versions # exports REALM_SWIFT_VERSION, REALM_XCODE_VERSION, and DEVELOPER_DIR variables if not already set PLATFORM=$(echo $COMMAND | cut -d - -f 2) LANGUAGE=$(echo $COMMAND | cut -d - -f 3) case "$COMMAND" in "test-all") for target in ios-swift-dynamic ios-swift-cocoapods osx-swift-dynamic ios-swift-carthage osx-swift-carthage; do ./build.sh test-$target || exit 1 done if (( $(xcode_version_major) >= 11 )); then for target in ios osx watchos tvos; do ./build.sh test-$target-spm || exit 1 done fi ;; test-*-*-static) xctest $PLATFORM $LANGUAGE StaticExample ;; test-*-*-dynamic) xctest $PLATFORM $LANGUAGE DynamicExample ;; test-*-*-cocoapods) xctest $PLATFORM $LANGUAGE CocoaPodsExample ;; test-*-*-cocoapods-dynamic) xctest $PLATFORM $LANGUAGE CocoaPodsDynamicExample ;; test-*-*-carthage) xctest $PLATFORM $LANGUAGE CarthageExample ;; test-*-spm) swiftpm $PLATFORM ;; *) echo "Unknown command '$COMMAND'" usage exit 1 ;; esac