Skip to content

Commit 9dbb723

Browse files
committed
Repeat recipe for latest version of Xcode
1 parent ea41648 commit 9dbb723

File tree

13 files changed

+304
-234
lines changed

13 files changed

+304
-234
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Swift 5 Module Template
44
Use this template as a starting point for any Swift 5 module that you want other people to include in their projects.
55

6-
**STATUS: This template is ready and works in production code, compatible with Xcode 12.4 (12D4e)**
6+
**STATUS: This template is ready and works in production code, compatible with Xcode 13.1 (13A1030d)**
77

88
![Swift 5 Module directory layout](https://user-images.githubusercontent.com/382183/66881876-63cca680-ef96-11e9-9dde-ae9d5c35350c.png)
99

@@ -14,7 +14,7 @@ Your new Swift 5 module will immediately have working, compilable code, and all
1414
- Clean folder structure
1515
- MIT license
1616
- Testing as a standard
17-
- Turnkey access to Travis CI
17+
- Turnkey access to GitHub Actions testing
1818
- Semantic versioning and a CHANGELOG
1919
- Included example/demo app using SwiftUI
2020

Recipe.assets/bad.png

-47.9 KB
Binary file not shown.

Recipe.assets/good.png

-46.9 KB
Binary file not shown.

Recipe.md

Lines changed: 34 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ This recipe may also be useful for other scenarios, for example maybe you want t
99

1010
During the steps of this recipe we enter specific values where needed. These are chosen carefully so that the `./configure` script can later find and replace these values in the template to create your project.
1111

12-
Some variables have spaces in them. That is intentional because it causes Xcode to use double quotes around them in its project configuration files.
12+
Some variables have spaces in them. That is intentional because Xcode only uses robust quoting in its project configuration files (which we want) if the variables have spaces in them.
1313

1414
- `xxPROJECTxNAMExx`
1515
- This must be a valid C99 extended identifier (otherwise the Xcode check dependencies step fails). It cannot contain spaces.
16-
- This must also be a Uniform Target Identifier (/^[a-zA-Z0-9-.]+$/).
16+
- This must also be a Uniform Target Identifier (``/^[a-zA-Z0-9-.]+$/``).
1717
- If this contains the characters `-` or `.` then they will be transliterated to `_` for file names.
1818

1919
- `__ORGANIZATION NAME__`
@@ -35,13 +35,13 @@ Some variables have spaces in them. That is intentional because it causes Xcode
3535

3636
Complete all these instructions on the same calendar day.
3737

38-
Use Xcode Version 12.4 (12D4e). *This is the latest publicly released or Gold Master version.*
38+
Use Xcode Version 13.1 (13A1030d). *This is the latest publicly released or Gold Master version.*
3939

4040
This recipe is also demonstrated in a YouTube flyover at https://youtu.be/ksYXtNn8lhE (15 minutes).
4141

4242
### I. Create a package for your module
4343

44-
1. In Xcode, choose File > New > Swift Package…
44+
1. In Xcode, choose File > New > Package…
4545
1. Navigate to your Desktop folder
4646
2. Type the name `xxPROJECTxNAMExx`
4747
3. Ensure "Create Git repository on my Mac" is unchecked
@@ -68,11 +68,10 @@ This recipe is also demonstrated in a YouTube flyover at https://youtu.be/ksYXtN
6868

6969
2. *Set the project options*
7070
1. Set Product Name to "iOS Example"
71-
2. Set Team to "NONE"
71+
2. Set Team to "None"
7272
3. Set Organization Identifier to `com.AN.ORGANIZATION.IDENTIFIER`
7373
4. Set User Interface to "SwiftUI"
74-
5. Set Life Cycle to "SwiftUI App"
75-
6. Set Language to "Swift"
74+
5. Set Language to "Swift"
7675
7. Ensure “Use Core Data” and "Include Tests" are not selected
7776
8. Click “Next"
7877
3. *Create the project*
@@ -85,18 +84,16 @@ This recipe is also demonstrated in a YouTube flyover at https://youtu.be/ksYXtN
8584

8685
1. *Move iOS Example source code to a folder named "Sources"*
8786
1. Open the file iOS Example.xcodeproj in Xcode
88-
2. Enable the Project navigator on the left (folder icon)
89-
3. Use the Project navigator to select the "iOS Example" folder (yellow icon)
87+
2. Show the Project navigator on the left (folder icon)
88+
3. Use the Project navigator to select the "iOS Example" folder (gray icon)
9089
4. From the Project navigator, rename this folder as "Sources"
91-
* :information_source: The Alamofire project uses [the folder name "Source"](https://github.com/Alamofire/Alamofire/tree/master/Example/Source) but we choose "Sources" here to be consistent with [the default of Swift Package Manager](https://github.com/apple/swift-package-manager/blob/b1a6f45aa9daed0c8a609d34af8f71cf4282ddd4/Sources/Workspace/InitPackage.swift#L256)
90+
* :information_source: The Alamofire project uses [the folder name "Source"](https://github.com/Alamofire/Alamofire/tree/master/Example/Source) but we choose "Sources" here to be consistent with [the default of Swift Package Manager](https://github.com/apple/swift-package-manager/blob/4fd4df4275627ebc91a0f288c38658738cd9fa0f/Sources/Workspace/InitPackage.swift#L275)
9291
2. *Fix the Info.plist file configuration and preview content folder (Xcode makes renaming folders a pain)*
9392
1. Click "iOS Example" on the left (the blue icon)
9493
2. Click the target "iOS Example" in the middle (white app icon)
9594
3. Click "Build Settings" on the top of the middle
96-
4. Enter "/Info" in the search box
97-
5. Edit the "Info.plist File" from "iOS Example/Info.plist" to be "Sources/Info.plist”
9895
6. Enter "Development Assets" in the search box
99-
7. Edit the value from “iOS Example/Preview Content” to "Sources/Preview Content"
96+
7. In the "Deployment" section, edit the value from “iOS Example/Preview Content” to "Sources/Preview Content"
10097

10198
### V. Add some functionality to your iOS Example application
10299

@@ -110,28 +107,20 @@ This recipe is also demonstrated in a YouTube flyover at https://youtu.be/ksYXtN
110107
### VI. Make your iOS Example application depend on your module
111108

112109
1. Open iOS Example.xcodeproj in Xcode
110+
2. In Xcode, choose File > Add Packages...
111+
1. Click "Add Local..."
112+
2. Select the `xxPROJECTxNAMExx` folder on your desktop
113+
3. Click "Add Package"
113114

114-
3. Drag the `xxPROJECTxNAMExx` folder on your desktop into the Xcode Project navigator at the bottom, be sure it is subordinated under iOS Example
115-
:x:: ![bad](Recipe.assets/bad.png)
116-
117-
:white_check_mark:: ![good](Recipe.assets/good.png)
118-
119-
1. At the dialog "Do you want to save this project in a new workspace?" click "Save"
120-
2. Navigate inside the iOS Example folder, in the `xxPROJECTxNAMExx` folder on your desktop
121-
3. Set the name as "iOS Example"
122-
4. Click Save
123-
- ⚠️ Xcode will also show the iOS Example folder inside the `xxPROJECTxNAMExx` module. Swift packages are unable to specify excluded files. You can safely ignore that folder.
124-
- :warning: Xcode has an error where this added dependency will show as ".." instead of the correct name. This discrepency can be safely ignored and it will show correctly the next time you open "iOS Example.xcworkspace".
125-
126-
4. *Add a build dependency*
127-
128-
1. Click "iOS Example" on the left (the blue icon) at the top-level (not subordinated to the `xxPROJECTxNAMExx` module)
129-
2. Click the target "iOS Example" in the middle (white app icon)
130-
3. Click "Build Phases" on the top
131-
4. Open the section Link Binary With Libraries
132-
5. Click the plus (+) button
133-
6. Select `xxPROJECTxNAMExx` (the building icon)
134-
7. Click "Add"
115+
3. *Add a build dependency*
116+
1. :information_source: You may or may not need to quit and reopen Xcode to proceed and see the required library, this is a known Xcode issue
117+
1. Click "iOS Example" on the left (the blue icon)
118+
1. Click the target "iOS Example" in the middle (white app icon)
119+
1. Click "Build Phases" on the top
120+
1. Open the section Link Binary With Libraries
121+
1. Click the plus (+) button
122+
1. Select `xxPROJECTxNAMExx` (the building icon)
123+
1. Click "Add"
135124

136125
### VII. Add additional project management files to the module
137126

@@ -141,14 +130,15 @@ This recipe is also demonstrated in a YouTube flyover at https://youtu.be/ksYXtN
141130

142131
```sh
143132
cd ~/Desktop/xxPROJECTxNAMExx/
144-
curl 'https://raw.githubusercontent.com/github/gitignore/master/Swift.gitignore' -o .gitignore
145-
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/.travis.yml' -o .travis.yml
146-
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/LICENSE' -o LICENSE
147-
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/README.md' -o README.md
148-
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/CHANGELOG.md' -o CHANGELOG.md
149-
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/CONTRIBUTING.md' -o CONTRIBUTING.md
150-
echo 'xxPROJECTxNAMExx.framework.zip' >> .gitignore
151-
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/Tests/CheckCocoaPodsQualityIndexes.rb' -o Tests/CheckCocoaPodsQualityIndexes.rb
133+
curl 'https://raw.githubusercontent.com/github/gitignore/master/Swift.gitignore' -o .gitignore
134+
mkdir -p .github/workflows
135+
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/.github/workflows/ci.yml' -o .github/workflows/ci.yml
136+
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/LICENSE' -o LICENSE
137+
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/README.md' -o README.md
138+
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/CHANGELOG.md' -o CHANGELOG.md
139+
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/CONTRIBUTING.md' -o CONTRIBUTING.md
140+
echo 'xxPROJECTxNAMExx.framework.zip' >> .gitignore
141+
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/Tests/CheckCocoaPodsQualityIndexes.rb' -o Tests/CheckCocoaPodsQualityIndexes.rb
152142
```
153143
### VIII. Remove identifying parts of your project
154144

@@ -164,14 +154,6 @@ This recipe is also demonstrated in a YouTube flyover at https://youtu.be/ksYXtN
164154
'{}' \;
165155
```
166156

167-
2. Use Terminal.app to remove all references to development team IDs
168-
169-
```sh
170-
find ~/Desktop/xxPROJECTxNAMExx -name project.pbxproj \
171-
-exec sed -i '' -E -e '/DevelopmentTeam = /d
172-
s/(DEVELOPMENT_TEAM = )[^;]+/\1""/' '{}' \;
173-
```
174-
175157
## Taste testing
176158

177159
1. Open iOS Example.xcworkspace in Xcode
@@ -180,7 +162,7 @@ This recipe is also demonstrated in a YouTube flyover at https://youtu.be/ksYXtN
180162

181163
3. Choose Product > Run
182164

183-
* :white_check_mark: You should see a big white king (♔). That means it worked!
165+
* :white_check_mark: You should see a big white king (♔) after a few moments. That means it worked!
184166

185167
4. *Compare with the distributed Swift 5 Module Template repository*
186168

@@ -199,6 +181,6 @@ This recipe is also demonstrated in a YouTube flyover at https://youtu.be/ksYXtN
199181
git diff
200182
```
201183

202-
* :white_check_mark: You should see an empty screen (press <kbd>q</kbd> to close)
184+
* :white_check_mark: You should see an empty screen indicating no differences (press <kbd>q</kbd> to close)
203185
* :mega: If you see differences, please raise an issue in the project repository
204186

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
name: "xxPROJECTxNAMExx CI"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'Source/**'
9+
- 'Tests/**'
10+
- '.github/workflows/**'
11+
- 'Package.swift'
12+
pull_request:
13+
paths:
14+
- 'Source/**'
15+
- 'Tests/**'
16+
- '.github/workflows/**'
17+
- 'Package.swift'
18+
19+
concurrency:
20+
group: ci
21+
cancel-in-progress: true
22+
# Keep this up to date with https://github.com/xxPROJECTxNAMExx/xxPROJECTxNAMExx/blob/master/.github/workflows/ci.yml
23+
jobs:
24+
macOS_5_3:
25+
name: Test macOS 10.15 (5.3)
26+
runs-on: macOS-10.15
27+
env:
28+
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
29+
timeout-minutes: 10
30+
steps:
31+
- uses: actions/checkout@v2
32+
- name: macOS 10.15 (5.3)
33+
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "xxPROJECTxNAMExx.xcodeproj" -scheme "xxPROJECTxNAMExx macOS" -destination "platform=macOS" clean test | xcpretty
34+
macOS_5_4:
35+
name: Test macOS 11 (5.4)
36+
runs-on: macOS-11
37+
env:
38+
DEVELOPER_DIR: /Applications/Xcode_12.5.1.app/Contents/Developer
39+
timeout-minutes: 10
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: macOS 11 (5.4)
43+
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "xxPROJECTxNAMExx.xcodeproj" -scheme "xxPROJECTxNAMExx macOS" -destination "platform=macOS" clean test | xcpretty
44+
macOS_5_5:
45+
name: Test macOS 11 (5.5)
46+
env:
47+
DEVELOPER_DIR: /Applications/Xcode_13.1.app/Contents/Developer
48+
timeout-minutes: 10
49+
steps:
50+
- uses: actions/checkout@v2
51+
- name: macOS 11 (5.5)
52+
run: set -o pipefail && arch -arch arm64e env NSUnbufferedIO=YES xcodebuild -project "xxPROJECTxNAMExx.xcodeproj" -scheme "xxPROJECTxNAMExx macOS" -destination "platform=macOS" clean test | xcpretty
53+
Catalyst:
54+
name: Test Catalyst
55+
runs-on: macOS-11
56+
env:
57+
DEVELOPER_DIR: /Applications/Xcode_13.1.app/Contents/Developer
58+
timeout-minutes: 10
59+
steps:
60+
- uses: actions/checkout@v2
61+
- name: Catalyst
62+
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "xxPROJECTxNAMExx.xcodeproj" -scheme "xxPROJECTxNAMExx iOS" -destination "platform=macOS" clean test | xcpretty
63+
iOS:
64+
name: Test iOS 15
65+
env:
66+
DEVELOPER_DIR: /Applications/Xcode_13.1.app/Contents/Developer
67+
timeout-minutes: 10
68+
strategy:
69+
matrix:
70+
destination: ["OS=15.0,name=iPhone 13 Pro"]
71+
steps:
72+
- uses: actions/checkout@v2
73+
- name: iOS - ${{ matrix.destination }}
74+
run: set -o pipefail && arch -arch arm64e env NSUnbufferedIO=YES xcodebuild -project "xxPROJECTxNAMExx.xcodeproj" -scheme "xxPROJECTxNAMExx iOS" -destination "${{ matrix.destination }}" clean test | xcpretty
75+
iOS_Concurrency:
76+
name: Test Swift Concurrency
77+
runs-on: macOS-11
78+
env:
79+
DEVELOPER_DIR: /Applications/Xcode_13.2.app/Contents/Developer
80+
timeout-minutes: 10
81+
strategy:
82+
matrix:
83+
destination: ["OS=15.2,name=iPhone 13 Pro"]
84+
steps:
85+
- uses: actions/checkout@v2
86+
- name: iOS - ${{ matrix.destination }}
87+
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "xxPROJECTxNAMExx.xcodeproj" -scheme "xxPROJECTxNAMExx iOS" -destination "${{ matrix.destination }}" -enableThreadSanitizer NO clean test | xcpretty
88+
tvOS:
89+
name: Test tvOS
90+
env:
91+
DEVELOPER_DIR: /Applications/Xcode_13.1.app/Contents/Developer
92+
timeout-minutes: 10
93+
strategy:
94+
matrix:
95+
destination: ["OS=15.0,name=Apple TV"]
96+
steps:
97+
- uses: actions/checkout@v2
98+
- name: tvOS - ${{ matrix.destination }}
99+
run: set -o pipefail && arch -arch arm64e env NSUnbufferedIO=YES xcodebuild -project "xxPROJECTxNAMExx.xcodeproj" -scheme "xxPROJECTxNAMExx tvOS" -destination "${{ matrix.destination }}" clean test | xcpretty
100+
watchOS:
101+
name: Test watchOS
102+
env:
103+
DEVELOPER_DIR: /Applications/Xcode_13.1.app/Contents/Developer
104+
timeout-minutes: 10
105+
strategy:
106+
matrix:
107+
destination: ["OS=8.0,name=Apple Watch Series 7 - 45mm"]
108+
steps:
109+
- uses: actions/checkout@v2
110+
- name: watchOS - ${{ matrix.destination }}
111+
run: set -o pipefail && arch -arch arm64e env NSUnbufferedIO=YES xcodebuild -project "xxPROJECTxNAMExx.xcodeproj" -scheme "xxPROJECTxNAMExx watchOS" -destination "${{ matrix.destination }}" clean test | xcpretty
112+
SPM:
113+
name: Test with SPM
114+
env:
115+
DEVELOPER_DIR: /Applications/Xcode_13.1.app/Contents/Developer
116+
timeout-minutes: 10
117+
steps:
118+
- uses: actions/checkout@v2
119+
- name: SPM Test
120+
run: arch -arch arm64e swift test -c debug
121+
Linux:
122+
name: Linux
123+
runs-on: ubuntu-20.04
124+
container:
125+
image: swift:5.5.1-focal
126+
timeout-minutes: 10
127+
steps:
128+
- uses: actions/checkout@v2
129+
- name: SPM Linux build
130+
run: swift build --build-tests -c debug
131+
Linux_Nightly:
132+
name: Linux Nightly
133+
runs-on: ubuntu-20.04
134+
container:
135+
image: swiftlang/swift:nightly-focal
136+
timeout-minutes: 10
137+
steps:
138+
- uses: actions/checkout@v2
139+
- name: SPM Linux build
140+
run: swift build --build-tests -c debug
141+
Windows:
142+
name: Windows
143+
runs-on: windows-2019
144+
timeout-minutes: 10
145+
steps:
146+
- name: "Clone Project"
147+
uses: actions/checkout@v2
148+
- uses: seanmiddleditch/gha-setup-vsdevenv@master
149+
- name: Install Swift
150+
run: |
151+
Install-Binary -Url "https://swift.org/builds/swift-5.5.1-release/windows10/swift-5.5.1-RELEASE/swift-5.5.1-RELEASE-windows10.exe" -Name "installer.exe" -ArgumentList ("-q")
152+
- name: Set Environment Variables
153+
run: |
154+
echo "SDKROOT=C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
155+
echo "DEVELOPER_DIR=C:\Library\Developer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
156+
- name: Adjust Paths
157+
run: |
158+
echo "C:\Library\Swift-development\bin;C:\Library\icu-67\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
159+
echo "C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
160+
- name: Install Supporting Files
161+
run: |
162+
Copy-Item "$env:SDKROOT\usr\share\ucrt.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\ucrt\module.modulemap"
163+
Copy-Item "$env:SDKROOT\usr\share\visualc.modulemap" -destination "$env:VCToolsInstallDir\include\module.modulemap"
164+
Copy-Item "$env:SDKROOT\usr\share\visualc.apinotes" -destination "$env:VCToolsInstallDir\include\visualc.apinotes"
165+
Copy-Item "$env:SDKROOT\usr\share\winsdk.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\um\module.modulemap"
166+
- name: SPM Windows build
167+
shell: cmd
168+
run: |
169+
cd ${{ github.workspace}}
170+
set SDKROOT=%SystemDrive%\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk
171+
%SystemDrive%\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swift-build.exe --build-tests -c debug -Xlinker /INCREMENTAL:NO -v
172+
if not exist .build\x86_64-unknown-windows-msvc\debug\xxPROJECTxNAMExx.swiftmodule exit 1

xxPROJECTxNAMExx/.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

xxPROJECTxNAMExx/Tests/LinuxMain.swift

Lines changed: 0 additions & 7 deletions
This file was deleted.

xxPROJECTxNAMExx/Tests/xxPROJECTxNAMExxTests/XCTestManifests.swift

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)