Skip to content

Commit fb77c28

Browse files
committed
Updated README
1 parent b494eef commit fb77c28

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ jobs:
106106

107107
## Complete Examples
108108

109+
### Build and Test a Swift Package for iOS
110+
109111
Prepare an iOS device simulator (defaults to iPhone) using the latest device and operating system version in order to test a Swift Package. Beforehand, refresh simulators and download an appropriate simulator if one is not yet installed.
110112

111113
> [!TIP]
@@ -152,6 +154,58 @@ jobs:
152154
WORKSPACEPATH: ${{ steps.prep-sim.outputs.workspace-path }}
153155
```
154156

157+
### Build and Test a Swift Package for Multiple Platforms
158+
159+
Set up a matrix of jobs for iOS, tvOS, watchOS and visionOS to prepare a device simulator using the latest device and operating system version in order to test a Swift Package. Beforehand, refresh simulators and download an appropriate simulator if one is not yet installed.
160+
161+
> [!TIP]
162+
>
163+
> Separating the build and test phases into separate steps is recommended for organization and clarity.
164+
>
165+
> Building (unlike testing) typically does not require a simulator destination and a generic destination can be supplied.
166+
167+
```yaml
168+
env:
169+
SCHEME: "MySchemeName"
170+
171+
jobs:
172+
build:
173+
runs-on: macos-latest
174+
strategy:
175+
matrix:
176+
target: [iOS, tvOS, watchOS, visionOS]
177+
continue-on-error: true
178+
steps:
179+
- uses: actions/checkout@main
180+
- name: Prepare Device Simulator
181+
id: prep-sim
182+
uses: orchetect/xcode-simulator@main
183+
with:
184+
refresh: true
185+
download: true
186+
scheme: ${{ env.SCHEME }}
187+
target: ${{ matrix.target }}
188+
- name: Build
189+
run: |
190+
xcodebuild build \
191+
-workspace "$WORKSPACEPATH" \
192+
-scheme "$SCHEME" \
193+
-destination "generic/platform=$PLATFORMSHORT"
194+
env:
195+
PLATFORMSHORT: ${{ steps.prep-sim.outputs.platform-short }}
196+
WORKSPACEPATH: ${{ steps.prep-sim.outputs.workspace-path }}
197+
- name: Unit Test
198+
run: |
199+
xcodebuild test \
200+
-workspace "$WORKSPACEPATH" \
201+
-scheme "$SCHEME" \
202+
-destination "platform=$PLATFORM,id=$ID"
203+
env:
204+
ID: ${{ steps.prep-sim.outputs.id }}
205+
PLATFORM: ${{ steps.prep-sim.outputs.platform }}
206+
WORKSPACEPATH: ${{ steps.prep-sim.outputs.workspace-path }}
207+
```
208+
155209
## Documentation
156210

157211
This README serves as basic documentation.

0 commit comments

Comments
 (0)