Skip to content

Commit 70f7b18

Browse files
authored
add force-start simulator before ci tests (#226)
* add force-start simulator before ci tests
1 parent 2ba6ed1 commit 70f7b18

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ jobs:
5252
- gem install slather --no-document --quiet
5353
- gem install cocoapods -v '1.6.1'
5454
- pod install --repo-update
55+
# fix simulator known issue (https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_1_release_notes)
5556
- sudo mkdir '/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 9.3.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift'
57+
# install jq without cleaning up
58+
- HOMEBREW_NO_INSTALL_CLEANUP=true brew install jq
59+
# preload simulator
60+
- Scripts/start_simulator.sh
5661
script:
5762
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then xcodebuild test -workspace OptimizelySDK.xcworkspace -scheme $SCHEME -configuration Release CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -sdk $TEST_SDK -destination "platform=$PLATFORM,OS=$OS,name=$NAME" ONLY_ACTIVE_ARCH=YES > buildoutput; fi
5863
- cat buildoutput | xcpretty
@@ -66,8 +71,8 @@ jobs:
6671
env: SCHEME=OptimizelySwiftSDK-iOS TEST_SDK=iphonesimulator PLATFORM='iOS Simulator' OS=12.1 NAME='iPhone 7'
6772
name: PLATFORM='iOS Simulator' OS=12.1 NAME='iPhone 7'
6873
- <<: *unittests
69-
env: SCHEME=OptimizelySwiftSDK-tvOS TEST_SDK=appletvsimulator PLATFORM='tvOS Simulator' OS=12.1 NAME='Apple TV 4k'
70-
name: PLATFORM='tvOS Simulator' OS=12.1 NAME='Apple TV 4k'
74+
env: SCHEME=OptimizelySwiftSDK-tvOS TEST_SDK=appletvsimulator PLATFORM='tvOS Simulator' OS=12.1 NAME='Apple TV 4K'
75+
name: PLATFORM='tvOS Simulator' OS=12.1 NAME='Apple TV 4K'
7176

7277
- stage: 'Prepare for release'
7378
name: Prepare for release

Scripts/start_simulator.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -eou pipefail
3+
4+
# expects the following environment variables defined
5+
# PLATFORM (eg. iOS Simulator)
6+
# OS (eg. 12.0)
7+
# NAME (eg. iPad Air)
8+
9+
# prep jq arg because it doesnt allow parameter expansion within its single quotes
10+
echo ".devices.\"com.apple.CoreSimulator.SimRuntime.${PLATFORM/ Simulator/}-${OS/./-}\"" > /tmp/jq_file
11+
12+
xcrun simctl boot $( xcrun simctl list --json devices | jq -f /tmp/jq_file | jq -r '.[] | select(.name==env.NAME) | .udid' ) && sleep 30
13+
xcrun simctl list | grep Booted

0 commit comments

Comments
 (0)