-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (87 loc) · 3.2 KB
/
Copy pathxcode.yml
File metadata and controls
101 lines (87 loc) · 3.2 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Build Xcode Project
on:
push:
pull_request:
jobs:
build:
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: List available Xcode versions
run: ls /Applications | grep Xcode
- name: Select latest Xcode
run: |
# Find the latest Xcode version installed
XCODE_PATH=$(find /Applications -maxdepth 1 -name "Xcode*.app" | sort -V | tail -n 1)
echo "Found Xcode at: $XCODE_PATH"
sudo xcode-select -s "$XCODE_PATH/Contents/Developer"
echo "Selected Xcode path: $(xcode-select -p)"
- name: Show Xcode and Swift versions
run: |
xcodebuild -version
swift --version
- name: Auto-detect project and scheme
id: detect
run: |
# Find workspace or project
WORKSPACE=$(find . -maxdepth 1 -name "*.xcworkspace" | head -n 1)
PROJECT=$(find . -maxdepth 1 -name "*.xcodeproj" | head -n 1)
if [ -n "$WORKSPACE" ]; then
echo "Found workspace: $WORKSPACE"
echo "build_target=-workspace" >> $GITHUB_OUTPUT
echo "build_file=$WORKSPACE" >> $GITHUB_OUTPUT
BUILD_FILE="$WORKSPACE"
elif [ -n "$PROJECT" ]; then
echo "Found project: $PROJECT"
echo "build_target=-project" >> $GITHUB_OUTPUT
echo "build_file=$PROJECT" >> $GITHUB_OUTPUT
BUILD_FILE="$PROJECT"
else
echo "Error: No .xcodeproj or .xcworkspace found!"
ls -la
exit 1
fi
# List available schemes
echo "Available schemes:"
if [ -n "$WORKSPACE" ]; then
xcodebuild -list -workspace "$WORKSPACE"
else
xcodebuild -list -project "$PROJECT"
fi
# Auto-detect scheme (get first scheme)
if [ -n "$WORKSPACE" ]; then
SCHEME=$(xcodebuild -list -workspace "$WORKSPACE" | grep -A 100 "Schemes:" | grep -v "Schemes:" | head -n 1 | xargs)
else
SCHEME=$(xcodebuild -list -project "$PROJECT" | grep -A 100 "Schemes:" | grep -v "Schemes:" | head -n 1 | xargs)
fi
echo "Detected scheme: $SCHEME"
echo "scheme=$SCHEME" >> $GITHUB_OUTPUT
- name: Cache build artifacts
uses: actions/cache@v4
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/Library/Developer/Xcode/DerivedData
key: ${{ runner.os }}-xcode-${{ hashFiles('**/*.xcodeproj') }}
restore-keys: |
${{ runner.os }}-xcode-
- name: Build project
run: |
xcodebuild clean build \
${{ steps.detect.outputs.build_target }} "${{ steps.detect.outputs.build_file }}" \
-scheme "${{ steps.detect.outputs.scheme }}" \
-configuration Debug \
-destination 'platform=macOS' \
-derivedDataPath DerivedData \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO
continue-on-error: false
- name: Upload build logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: build-logs
path: |
DerivedData/Logs
~/Library/Developer/Xcode/DerivedData/**/Logs