Skip to content

Commit 545a424

Browse files
committed
ci: xcodebuild
1 parent af1f52b commit 545a424

4 files changed

Lines changed: 209 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: CI
2+
3+
# Comprehensive CI workflow that includes builds, tests, and validations
4+
on:
5+
push:
6+
branches: [ main, master, develop ]
7+
pull_request:
8+
branches: [ main, master, develop ]
9+
10+
# Cancel any in-progress workflow runs for the same branch
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
env:
16+
DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
17+
18+
jobs:
19+
# Swift Package Manager Build
20+
spm-build:
21+
name: SPM Build
22+
runs-on: macos-latest
23+
strategy:
24+
matrix:
25+
platform: [iOS, macOS, tvOS, watchOS, visionOS]
26+
27+
steps:
28+
- name: Checkout Repository
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Xcode
32+
uses: maxim-lobanov/setup-xcode@v1
33+
with:
34+
xcode-version: latest
35+
36+
- name: Build with SPM
37+
run: |
38+
case "${{ matrix.platform }}" in
39+
iOS)
40+
SDK_PATH=$(xcrun --sdk iphonesimulator --show-sdk-path)
41+
swift build \
42+
-Xcc "-isysroot" -Xcc "$SDK_PATH" \
43+
-Xswiftc "-sdk" -Xswiftc "$SDK_PATH" \
44+
-Xswiftc "-target" -Xswiftc "arm64-apple-ios13.0-simulator"
45+
;;
46+
macOS)
47+
swift build
48+
;;
49+
tvOS)
50+
SDK_PATH=$(xcrun --sdk appletvsimulator --show-sdk-path)
51+
swift build \
52+
-Xcc "-isysroot" -Xcc "$SDK_PATH" \
53+
-Xswiftc "-sdk" -Xswiftc "$SDK_PATH" \
54+
-Xswiftc "-target" -Xswiftc "arm64-apple-tvos13.0-simulator"
55+
;;
56+
watchOS)
57+
SDK_PATH=$(xcrun --sdk watchsimulator --show-sdk-path)
58+
swift build \
59+
-Xcc "-isysroot" -Xcc "$SDK_PATH" \
60+
-Xswiftc "-sdk" -Xswiftc "$SDK_PATH" \
61+
-Xswiftc "-target" -Xswiftc "arm64-apple-watchos6.0-simulator"
62+
;;
63+
visionOS)
64+
SDK_PATH=$(xcrun --sdk xrsimulator --show-sdk-path)
65+
swift build \
66+
-Xcc "-isysroot" -Xcc "$SDK_PATH" \
67+
-Xswiftc "-sdk" -Xswiftc "$SDK_PATH" \
68+
-Xswiftc "-target" -Xswiftc "arm64-apple-xros1.0-simulator"
69+
;;
70+
esac
71+
72+
# Xcode Build Test
73+
xcode-build:
74+
name: Xcode Build
75+
runs-on: macos-latest
76+
strategy:
77+
matrix:
78+
destination:
79+
- 'platform=iOS Simulator,name=iPhone 15,OS=latest'
80+
- 'platform=macOS'
81+
- 'platform=tvOS Simulator,name=Apple TV,OS=latest'
82+
- 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=latest'
83+
- 'platform=visionOS Simulator,name=Apple Vision Pro,OS=latest'
84+
85+
steps:
86+
- name: Checkout Repository
87+
uses: actions/checkout@v4
88+
89+
- name: Setup Xcode
90+
uses: maxim-lobanov/setup-xcode@v1
91+
with:
92+
xcode-version: latest
93+
94+
- name: Build with Xcode
95+
run: |
96+
xcodebuild clean build \
97+
-workspace EFQRCode.xcworkspace \
98+
-scheme "${{ contains(matrix.destination, 'iOS') && 'iOS Example' || contains(matrix.destination, 'macOS') && 'macOS Example' || contains(matrix.destination, 'tvOS') && 'tvOS Example' || contains(matrix.destination, 'watchOS') && 'watchOS Example' || 'iOS Example' }}" \
99+
-destination "${{ matrix.destination }}" \
100+
CODE_SIGN_IDENTITY="" \
101+
CODE_SIGNING_REQUIRED=NO \
102+
ONLY_ACTIVE_ARCH=NO
103+
104+
# Documentation Check
105+
documentation-check:
106+
name: Documentation Check
107+
runs-on: macos-latest
108+
steps:
109+
- uses: actions/checkout@v4
110+
- name: Install Jazzy
111+
run: sudo gem install jazzy
112+
- name: Resolve Swift Package dependencies
113+
run: xcodebuild -resolvePackageDependencies
114+
- name: Generate Documentation
115+
run: ./docs.sh
116+
continue-on-error: false
117+
118+
# Final Status Check
119+
status-check:
120+
name: Status Check
121+
runs-on: macos-latest
122+
needs: [spm-build, xcode-build, documentation-check]
123+
if: always()
124+
125+
steps:
126+
- name: Check Results
127+
run: |
128+
if [[ "${{ needs.spm-build.result }}" != "success" ]] || [[ "${{ needs.xcode-build.result }}" != "success" ]]; then
129+
echo "❌ Build checks failed - PR will be blocked"
130+
exit 1
131+
fi
132+
133+
echo "✅ All checks passed successfully!"

.github/workflows/docs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
- main
77
- docs
88

9+
# Cancel any in-progress workflow runs for the same branch
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
914
jobs:
1015
jazzy:
1116
runs-on: macos-latest

Package@swift-5.3.swift

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ let package = Package(
3333
.macOS(.v10_15),
3434
.iOS(.v13),
3535
.tvOS(.v13),
36-
.watchOS(.v6),
37-
.visionOS(.v1)
36+
.watchOS(.v6)
3837
],
3938
products: [
4039
.library(name: "EFQRCode", targets: ["EFQRCode"])
@@ -52,17 +51,15 @@ let package = Package(
5251
"SwiftDraw"
5352
],
5453
path: "Source",
55-
exclude: ["Info.plist", "Info-tvOS.plist"]),
54+
exclude: ["Info.plist", "Info-tvOS.plist"],
55+
resources: [
56+
.process("PrivacyInfo.xcprivacy")
57+
]),
5658
.testTarget(name: "EFQRCodeSwiftTests",
5759
dependencies: ["EFQRCode"],
5860
path: "Tests",
5961
exclude: ["Info.plist"],
6062
resources: [.process("Resources")]),
61-
.testTarget(name: "EFQRCodeObjCTests",
62-
dependencies: ["EFQRCode"],
63-
path: "Tests",
64-
exclude: ["Info.plist", "Tests.swift"],
65-
resources: [.process("Resources")]),
6663
],
6764
swiftLanguageVersions: [.v5]
6865
)

Package@swift-5.9.swift

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// swift-tools-version:5.9
2+
//
3+
// Package.swift
4+
// EFQRCode
5+
//
6+
// Created by EyreFree on 2017/4/1.
7+
//
8+
// Copyright (c) 2017-2021 EyreFree <eyrefree@eyrefree.org>
9+
//
10+
// Permission is hereby granted, free of charge, to any person obtaining a copy
11+
// of this software and associated documentation files (the "Software"), to deal
12+
// in the Software without restriction, including without limitation the rights
13+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
// copies of the Software, and to permit persons to whom the Software is
15+
// furnished to do so, subject to the following conditions:
16+
//
17+
// The above copyright notice and this permission notice shall be included in
18+
// all copies or substantial portions of the Software.
19+
//
20+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26+
// THE SOFTWARE.
27+
28+
import PackageDescription
29+
30+
let package = Package(
31+
name: "EFQRCode",
32+
platforms: [
33+
.macOS(.v10_15),
34+
.iOS(.v13),
35+
.tvOS(.v13),
36+
.watchOS(.v6),
37+
.visionOS(.v1)
38+
],
39+
products: [
40+
.library(name: "EFQRCode", targets: ["EFQRCode"])
41+
],
42+
dependencies: [
43+
.package(url: "https://github.com/EFPrefix/swift_qrcodejs.git",
44+
.upToNextMinor(from: "2.3.1")),
45+
.package(url: "https://github.com/swhitty/SwiftDraw.git",
46+
.upToNextMinor(from: "0.22.0")),
47+
],
48+
targets: [
49+
.target(name: "EFQRCode",
50+
dependencies: [
51+
.product(name: "QRCodeSwift", package: "swift_qrcodejs"),
52+
"SwiftDraw"
53+
],
54+
path: "Source",
55+
exclude: ["Info.plist", "Info-tvOS.plist"],
56+
resources: [
57+
.process("PrivacyInfo.xcprivacy")
58+
]),
59+
.testTarget(name: "EFQRCodeSwiftTests",
60+
dependencies: ["EFQRCode"],
61+
path: "Tests",
62+
exclude: ["Info.plist"],
63+
resources: [.process("Resources")]),
64+
],
65+
swiftLanguageVersions: [.v5]
66+
)

0 commit comments

Comments
 (0)