Skip to content

Commit 2eb686b

Browse files
committed
Extend iOS cross compile to all apple platforms
1 parent d7f8c78 commit 2eb686b

2 files changed

Lines changed: 60 additions & 39 deletions

File tree

.github/workflows/pull_request.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,20 @@ jobs:
7474
cd tests/TestPackage
7575
xcrun swift build
7676
77-
build_tests_ios:
78-
name: Build iOS Tests
77+
build_tests_apple_cc:
78+
name: Build
7979
uses: ./.github/workflows/swift_package_test.yml
8080
with:
8181
enable_linux_checks: false
8282
enable_windows_checks: false
83-
# iOS
84-
enable_ios_checks: true
85-
ios_build_command: |
83+
# Apple CC
84+
enable_apple_cc_checks: true
85+
apple_cc_scheme: TestPackage-Package
86+
apple_cc_pre_build_command: |
8687
cd tests/TestPackage
87-
xcodebuild -quiet -scheme TestPackage-Package -destination "generic/platform=ios" build
88+
apple_cc_build_command: |
89+
cd tests/TestPackage
90+
xcodebuild build-for-testing -quiet -scheme $APPLE_CC_SCHEME -destination "generic/platform=$APPLE_CC_PLATFORM"
8891
8992
soundness:
9093
name: Soundness

.github/workflows/swift_package_test.yml

Lines changed: 51 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,26 @@ on:
2222
type: string
2323
description: "macOS arch list (JSON)"
2424
default: "[\"ARM64\"]"
25-
ios_host_xcode_versions:
25+
apple_cc_xcode_versions:
2626
type: string
27-
description: "Xcode version list (JSON)"
27+
description: "Xcode version list for Apple CC builds (JSON)"
2828
default: null
29-
ios_host_exclude_xcode_versions:
29+
apple_cc_exclude_xcode_versions:
3030
type: string
31-
description: "Exclude Xcode version list (JSON)"
31+
description: "Exclude Xcode version list for Apple CC builds (JSON)"
3232
default: null
33-
ios_host_versions:
33+
apple_cc_macos_versions:
3434
type: string
35-
description: "iOS host (macOS) version list (JSON)"
35+
description: "Apple CC host (macOS) version list (JSON)"
3636
default: null
37-
ios_host_archs:
37+
apple_cc_macos_archs:
3838
type: string
39-
description: "iOS host (macOS) arch list (JSON)"
39+
description: "Apple CC host (macOS) arch list (JSON)"
4040
default: null
41+
apple_cc_platforms:
42+
type: string
43+
description: "Apple CC target platforms as JSON array of objects with name and platform keys"
44+
default: '[{"name": "iOS", "platform": "iOS"}, {"name": "tvOS", "platform": "tvOS"}, {"name": "visionOS", "platform": "xrOS"}, {"name": "watchOS", "platform": "watchOS"}]'
4145
linux_swift_versions:
4246
type: string
4347
description: "Include Linux Swift version list (JSON)"
@@ -127,17 +131,21 @@ on:
127131
type: number
128132
description: "The default step timeout in minutes"
129133
default: 60
130-
ios_pre_build_command:
134+
apple_cc_pre_build_command:
131135
type: string
132-
description: "macOS command to execute before building the Swift package for iOS"
136+
description: "macOS command to execute before the Apple CC build"
133137
default: ""
134-
ios_build_command:
138+
apple_cc_scheme:
135139
type: string
136-
description: "macOS command to build the package for iOS"
137-
default: "\"$(xcrun -f swift)\" build --build-tests --sdk \"$(xcrun --sdk iphoneos --show-sdk-path)\" --triple arm64-apple-ios"
138-
ios_build_timeout:
140+
description: "Xcode scheme to build for Apple CC targets"
141+
default: ""
142+
apple_cc_build_command:
143+
type: string
144+
description: "macOS command to build the package for Apple CC targets"
145+
default: "xcodebuild build-for-testing -scheme $APPLE_CC_SCHEME -destination generic/platform=$APPLE_CC_PLATFORM"
146+
apple_cc_build_timeout:
139147
type: number
140-
description: "The default step timeout in minutes"
148+
description: "The default step timeout in minutes for Apple CC builds"
141149
default: 60
142150
linux_build_command:
143151
type: string
@@ -181,8 +189,8 @@ on:
181189
macos_env_vars:
182190
description: "Newline separated list of environment variables"
183191
type: string
184-
ios_host_env_vars:
185-
description: "Newline separated list of environment variables"
192+
apple_cc_env_vars:
193+
description: "Newline separated list of environment variables for Apple CC builds"
186194
type: string
187195
linux_env_vars:
188196
description: "Newline separated list of environment variables"
@@ -218,9 +226,9 @@ on:
218226
type: boolean
219227
description: "Boolean to enable macOS testing. Defaults to false"
220228
default: false
221-
enable_ios_checks:
229+
enable_apple_cc_checks:
222230
type: boolean
223-
description: "Boolean to enable iOS testing. Defaults to false"
231+
description: "Boolean to enable Apple cross-compilation builds. Defaults to false"
224232
default: false
225233
enable_windows_checks:
226234
type: boolean
@@ -278,18 +286,19 @@ jobs:
278286
run: ${{ inputs.macos_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
279287
timeout-minutes: ${{ inputs.macos_build_timeout }}
280288

281-
ios-build:
282-
name: iOS (Build Only, Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }})
283-
if: ${{ inputs.enable_ios_checks }}
289+
apple-cc-build:
290+
name: ${{ matrix.os.name }} (Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }})
291+
if: ${{ inputs.enable_apple_cc_checks }}
284292
runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"]
285293
strategy:
286294
fail-fast: false
287295
matrix:
288-
xcode_version: ${{ fromJson(inputs.ios_host_xcode_versions || inputs.macos_xcode_versions) }}
289-
os_version: ${{ fromJson(inputs.ios_host_versions || inputs.macos_versions) }}
290-
arch: ${{ fromJson(inputs.ios_host_archs || inputs.macos_archs) }}
296+
xcode_version: ${{ fromJson(inputs.apple_cc_xcode_versions || inputs.macos_xcode_versions) }}
297+
os_version: ${{ fromJson(inputs.apple_cc_macos_versions || inputs.macos_versions) }}
298+
arch: ${{ fromJson(inputs.apple_cc_macos_archs || inputs.macos_archs) }}
299+
os: ${{ fromJson(inputs.apple_cc_platforms) }}
291300
exclude:
292-
- ${{ fromJson(inputs.ios_host_exclude_xcode_versions || inputs.macos_exclude_xcode_versions) }}
301+
- ${{ fromJson(inputs.apple_cc_exclude_xcode_versions || inputs.macos_exclude_xcode_versions) }}
293302
steps:
294303
- name: Checkout repository
295304
uses: actions/checkout@v4
@@ -298,22 +307,31 @@ jobs:
298307
run: |
299308
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
300309
- name: Set environment variables
301-
if: ${{ inputs.ios_host_env_vars }}
310+
if: ${{ inputs.apple_cc_env_vars }}
302311
run: |
303-
for i in "${{ inputs.ios_host_env_vars }}"
312+
for i in "${{ inputs.apple_cc_env_vars }}"
304313
do
305314
printf "%s\n" $i >> $GITHUB_ENV
306315
done
316+
- name: Install xcbeautify
317+
run: |
318+
curl -L https://github.com/cpisciotta/xcbeautify/releases/download/2.28.0/xcbeautify-2.28.0-arm64-apple-macosx.zip -o xcbeautify.zip
319+
sha256 -c 00d16a08b426e004e5d101631515ea1bbc0ab20209541cd4cacb569d3289c9e7 xcbeautify.zip
320+
unzip xcbeautify.zip -d /tmp
321+
chmod +x /tmp/xcbeautify
322+
/tmp/xcbeautify --version
307323
- name: Select Xcode
308324
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV
309325
- name: Swift version
310-
run: |
311-
"$(xcrun -f swift)" --version
326+
run: xcrun swift --version
312327
- name: Pre-build
313-
run: ${{ inputs.ios_pre_build_command }}
328+
run: ${{ inputs.apple_cc_pre_build_command }}
314329
- name: Build
315-
run: ${{ inputs.ios_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
316-
timeout-minutes: ${{ inputs.ios_build_timeout }}
330+
env:
331+
APPLE_CC_PLATFORM: ${{ matrix.os.platform }}
332+
APPLE_CC_SCHEME: ${{ inputs.apple_cc_scheme }}
333+
run: ${{ inputs.apple_cc_build_command }} | /tmp/xcbeautify
334+
timeout-minutes: ${{ inputs.apple_cc_build_timeout }}
317335

318336
linux-build:
319337
name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }})

0 commit comments

Comments
 (0)