-
Notifications
You must be signed in to change notification settings - Fork 8
60 lines (55 loc) · 2.11 KB
/
ios.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: iOS starter workflow
on:
push:
branches: [ "development" ]
pull_request:
branches: [ "development" ]
jobs:
build:
name: Build and Test default scheme using any available iPhone simulator
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Default Scheme
run: |
scheme_list=$(xcodebuild -list -json | tr -d "\n")
default=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets'][0]")
echo $default | cat >default
echo Using default scheme: $default
- name: Build
env:
scheme: ${{ 'default' }}
platform: ${{ 'iOS Simulator' }}
run: |
device=$(xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//")
if [ $scheme = default ]; then scheme=$(cat default); fi
if [ -d "*.xcworkspace" ]; then
filetype_parameter="workspace"
file_to_build=$(find . -name "*.xcworkspace" | head -n 1)
elif [ -d "*.xcodeproj" ]; then
filetype_parameter="project"
file_to_build=$(find . -name "*.xcodeproj" | head -n 1)
else
echo "No Xcode project or workspace found."
exit 1
fi
xcodebuild build-for-testing -scheme "$scheme" -$filetype_parameter "$file_to_build" -destination "platform=$platform,name=$device"
- name: Test
env:
scheme: ${{ 'default' }}
platform: ${{ 'iOS Simulator' }}
run: |
device=$(xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//")
if [ $scheme = default ]; then scheme=$(cat default); fi
if [ -d "*.xcworkspace" ]; then
filetype_parameter="workspace"
file_to_build=$(find . -name "*.xcworkspace" | head -n 1)
elif [ -d "*.xcodeproj" ]; then
filetype_parameter="project"
file_to_build=$(find . -name "*.xcodeproj" | head -n 1)
else
echo "No Xcode project or workspace found."
exit 1
fi
xcodebuild test-without-building -scheme "$scheme" -$filetype_parameter "$file_to_build" -destination "platform=$platform,name=$device"