Skip to content

Commit e96f33b

Browse files
committed
Update for Xcode Version 12.3 (12C33), fixes #47 and #46
1 parent 29aed85 commit e96f33b

File tree

18 files changed

+262
-369
lines changed

18 files changed

+262
-369
lines changed

README.md

+16-3
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 11.1 (11A1027)**
6+
**STATUS: This template is ready and works in production code, compatible with Xcode 12.3 (12C33)**
77

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

@@ -16,7 +16,7 @@ Your new Swift 5 module will immediately have working, compilable code, and all
1616
- Testing as a standard
1717
- Turnkey access to Travis CI
1818
- Semantic versioning and a CHANGELOG
19-
- Included example/demo app
19+
- Included example/demo app using SwiftUI
2020

2121
We make the assumption you are using an Xcode project to manage your code.
2222

@@ -53,6 +53,19 @@ To skip interactive prompts in the `./configure` script, use these environment v
5353

5454
For example, you may use: `export SMT_ORGANIZATION_NAME='Awesome Org'` before running `./configure`.
5555

56+
## How it works
57+
58+
```
59+
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
60+
│ Use │ │ Save │ │Use your own │
61+
│ Xcode │─Save recipe─▶│ template │─./configure─▶│ module │
62+
└─────────────┘ └─────────────┘ └─────────────┘
63+
▲ ▲ ▲ ▲ ▲
64+
65+
│ │ │ │ │
66+
Contributors to this project End users of this project
67+
```
68+
5669
## Contributing
5770

58-
See the file [`Recipe.md`](Recipe.md) for the complete steps (e.g. Open Xcode, make new project, click here, type that, …) of how we made the template.
71+
See the file [Recipe.md](Recipe.md) for the complete steps (e.g. Open Xcode, make new project, click here, type that, …) of how we made the template.

Recipe.md

+49-48
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
This recipe documents exactly how we created the Swift 5 Module Template. Please follow along and you should create a template that is identical to the one we provided. If this recipe is not perfect (or your result is different from our template in any way) then please submit an issue or pull request.
44

5+
This recipe may also be useful for other scenarios, for example maybe you want to make a project that has the iOS example app using storyboards instead of SwiftUI.
6+
57

68
## Ingredients
79

8-
During the steps of this recipe we enter specific values where needed. These are chosen carefully so that they can be found and replaced in the template to create your project.
10+
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.
911

1012
Some variables have spaces in them. That is intentional because it causes Xcode to use double quotes around them in its project configuration files.
1113

@@ -35,14 +37,15 @@ Some variables have spaces in them. That is intentional because it causes Xcode
3537

3638
Complete all these instructions on the same calendar day.
3739

38-
Use Xcode Version 11.1 (11A1027). *This is the latest publicly released or Gold Master version.*
40+
Use Xcode Version 12.3 (12C33). *This is the latest publicly released or Gold Master version.*
3941

4042
### I. Create a package for your module
4143

4244
1. In Xcode, choose File > New > Swift Package…
4345
1. Navigate to your Desktop folder
4446
2. Type the name `xxPROJECTxNAMExx`
45-
3. Click “Create"
47+
3. Ensure "Create Git repository on my Mac" is unchecked
48+
4. Click “Create"
4649

4750

4851
### II. Add some functionality to the module
@@ -52,45 +55,44 @@ Use Xcode Version 11.1 (11A1027). *This is the latest publicly released or Gold
5255
```sh
5356
cd ~/Desktop/xxPROJECTxNAMExx/Sources/xxPROJECTxNAMExx/
5457
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/Sources/xxPROJECTxNAMExx/xxPROJECTxNAMExx.swift' -o xxPROJECTxNAMExx.swift
55-
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/Sources/xxPROJECTxNAMExx/White King.swift' -o White\ King.swift
58+
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/Sources/xxPROJECTxNAMExx/White%20King.swift' -o White\ King.swift
5659
```
5760

5861
### III. Create a Swift project for your iOS Example application
5962

6063
1. In Xcode, choose File > New > Project…
6164
1. *Choose a template*
62-
1. Click "iOS" then "Single View App"
65+
1. Click "iOS" then "App"
6366

6467
2. Click "Next"
6568

6669
2. *Set the project options*
6770
1. Set Product Name to "iOS Example"
68-
2. Set Organization Name to `__ORGANIZATION NAME__`
71+
2. Set Team to "NONE"
6972
3. Set Organization Identifier to `com.AN.ORGANIZATION.IDENTIFIER`
70-
4. Set Language to "Swift"
71-
5. Set User Interface to "Storyboard"
72-
6. Ensure "Include Unit Tests" is not selected
73-
7. Ensure "Include UI Tests" is not selected
73+
4. Set User Interface to "SwiftUI"
74+
5. Set Life Cycle to "SwiftUI App"
75+
6. Set Language to "Swift"
76+
7. Ensure "Include Tests" is not selected
7477
8. Click “Next"
7578
3. *Create the project*
76-
1. Ensure “Create Git Repository" is not selected
77-
2. Ensure the 'add to' function is “Don’t add to any project or workspace"
78-
3. Select the folder `xxPROJECTxNAMExx` on the desktop
79+
1. Ensure “Create Git Repository on my Mac" is not selected
80+
2. Ensure "Add to" is “Don’t add to any project or workspace"
81+
3. Select the folder `xxPROJECTxNAMExx` on the desktop (don't double click it)
7982
4. Click “Create"
8083

8184
### IV. Use the directory layout structure like Alamofire
8285

8386
1. *Move iOS Example source code to a folder named "Sources"*
8487
1. Open the file iOS Example.xcodeproj in Xcode
85-
2. Enable the Project navigator on the left
88+
2. Enable the Project navigator on the left (folder icon)
8689
3. Use the Project navigator to select the "iOS Example" folder (yellow icon)
8790
4. From the Project navigator, rename this folder as "Sources"
88-
* :warning: Using the File inspector to rename a folder would result in the change being reverted. This is an Xcode bug that we work around.
89-
* :information_source: The Alamofire project uses the folder name "Source" but we choose "Sources" here to be consistent with the default of Swift Package Manager
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)
9092
2. *Fix the Info.plist file configuration and preview content folder (Xcode makes renaming folders a pain)*
9193
1. Click "iOS Example" on the left (the blue icon)
9294
2. Click the target "iOS Example" in the middle (app icon)
93-
3. Click 'Build Settings' on the top of the middle
95+
3. Click "Build Settings" on the top of the middle
9496
4. Enter "/Info" in the search box
9597
5. Edit the "Info.plist File" from "iOS Example/Info.plist" to be "Sources/Info.plist"
9698

@@ -100,16 +102,12 @@ Use Xcode Version 11.1 (11A1027). *This is the latest publicly released or Gold
100102

101103
```sh
102104
cd ~/Desktop/xxPROJECTxNAMExx/iOS\ Example/Sources
103-
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/iOS Example/Sources/Base.lproj/Main.storyboard' -o Base.lproj/Main.storyboard
105+
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/iOS Example/Sources/ContentView.swift' -o ContentView.swift
104106
```
105107

106108
### VI. Make your iOS Example application depend on your module
107109

108-
1. Close everything that is open in Xcode
109-
110-
- ⚠️ This is a workaround an Xcode bug where adding a Swift package to a workspace, when that Swift package is open in a separate window, will improperly load the package as ".." instead of the correct package name.
111-
112-
2. Open iOS Example.xcodeproj in Xcode
110+
1. Open iOS Example.xcodeproj in Xcode
113111

114112
3. Drag the `xxPROJECTxNAMExx` folder on your desktop into the Xcode Project navigator at the bottom, be sure it is subordinated under iOS Example
115113
:x:: ![bad](Recipe.assets/bad.png)
@@ -121,15 +119,17 @@ Use Xcode Version 11.1 (11A1027). *This is the latest publicly released or Gold
121119
3. Set the name as "iOS Example.xcworkspace"
122120
4. Click Save
123121
- ⚠️ 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-
122+
- :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 this workspace.
123+
125124
4. *Add a build dependency*
126125

127126
1. Click "iOS Example" on the left (the blue icon)
128127
2. Click the target "iOS Example" in the middle (app icon)
129-
3. Click 'Build Phases' on the top of the middle
128+
3. Click "Build Phases" on the top
130129
4. Open the section Link Binary With Libraries
131130
5. Click the plus (+) button
132-
6. Select xxPROJECTxNAMExx (the building icon)
131+
6. Select `xxPROJECTxNAMExx` (the building icon)
132+
7. Click "Add"
133133

134134
### VII. Add additional project management files to the module
135135

@@ -138,7 +138,7 @@ These files represent best practices which every Swift module author should adop
138138
1. Use Terminal.app to add additional files to the project
139139

140140
2. ```sh
141-
cd ~/Desktop/xxPROJECTxNAMExx/
141+
cd ~/Desktop/xxPROJECTxNAMExx/
142142
curl 'https://raw.githubusercontent.com/github/gitignore/master/Swift.gitignore' -o .gitignore
143143
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/.travis.yml' -o .travis.yml
144144
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/LICENSE' -o LICENSE
@@ -148,19 +148,18 @@ These files represent best practices which every Swift module author should adop
148148
echo 'xxPROJECTxNAMExx.framework.zip' >> .gitignore
149149
curl 'https://raw.githubusercontent.com/fulldecent/swift5-module-template/master/xxPROJECTxNAMExx/Tests/CheckCocoaPodsQualityIndexes.rb' -o Tests/CheckCocoaPodsQualityIndexes.rb
150150
```
151-
152151
### VIII. Remove identifying parts of your project
153152

154-
This step allows everybody to achieve byte-for-byte consistency with the published Swift 5 Module Template but otherwise provides no value to you.
153+
This step allows everybody to achieve byte-for-byte consistency with [the published Swift 5 Module Template](https://github.com/fulldecent/swift5-module-template/tree/master/xxPROJECTxNAMExx) but otherwise provides no value to you.
155154

156155
1. Use Terminal.app to find and replace all occurrences of hard-coded strings with template variables
157156

158157
```sh
159158
find -E ~/Desktop/xxPROJECTxNAMExx \
160-
-regex '.*\.(h|swift)' -exec sed -i '' -E -e '
161-
s-(// +Created by ).*( on ).*\.-\1__AUTHOR NAME__\2__TODAYS_DATE__.-
162-
s-(// +Copyright © ).*-\1__TODAYS_YEAR__ __ORGANIZATION NAME__. All rights reserved.-' \
163-
'{}' \;
159+
-regex '.*\.(h|swift)' -exec sed -i '' -E -e '
160+
s-(// +Created by ).*( on ).*\.-\1__AUTHOR NAME__\2__TODAYS_DATE__.-
161+
s-(// +Copyright © ).*-\1__TODAYS_YEAR__ __ORGANIZATION NAME__. All rights reserved.-' \
162+
'{}' \;
164163
```
165164

166165
2. Use Terminal.app to remove all references to development team IDs
@@ -173,30 +172,32 @@ This step allows everybody to achieve byte-for-byte consistency with the publish
173172

174173
## Taste testing
175174

176-
1. Open `xxPROJECTxNAMExx`.xcworkspace
175+
1. Open iOS Example.xcodeproj in Xcode
177176

178177
2. Use the scheme navigator to select iOS Example and the latest iPhone version
179178

180179
3. Choose Product > Run
181180

181+
* :warning: There appears to be a bug with Xcode saying "One of the paths in DEVELOPMENT_ASSET_PATHS does not exist". The workaround is to delete Development Assets from the Build Settings on the iOS Example target.
182182
* :white_check_mark: You should see a big white king (♔). That means it worked!
183183

184-
4. *Compare with the distributed Swift 5 Module Template repository*
184+
4. *Compare with the distributed Swift 5 Module Template repository*
185+
186+
1. Use Terminal.app to clone the repository to your desktop
185187

186-
1. Clone the repository to your desktop use Terminal
188+
```sh
189+
git clone https://github.com/fulldecent/swift5-module-template.git ~/Desktop/swift5-module-template
190+
```
187191

188-
```sh
189-
git clone https://github.com/fulldecent/swift5-module-template.git ~/Desktop/swift5-module-template
190-
```
192+
2. Compare the distributed version with your version
191193

192-
2. Compare the distributed version with your version
194+
```sh
195+
cd ~/Desktop/swift5-module-template
196+
rm -rf xxPROJECTxNAMExx
197+
cp -r ~/Desktop/xxPROJECTxNAMExx .
198+
git diff
199+
```
193200

194-
```sh
195-
cd ~/Desktop/swift5-module-template
196-
rm -rf xxPROJECTxNAMExx
197-
cp -r ~/Desktop/xxPROJECTxNAMExx .
198-
git diff
199-
```
201+
* :white_check_mark: You should see an empty screen (press <kbd>q</kbd> to close)
202+
* :mega: If you see differences, please raise an issue in the project repository
200203

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

xxPROJECTxNAMExx/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xxPROJECTxNAMExx/Package.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// swift-tools-version:5.1
1+
// swift-tools-version:5.3
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55

66
let package = Package(
77
name: "xxPROJECTxNAMExx",
88
products: [
9-
// Products define the executables and libraries produced by a package, and make them visible to other packages.
9+
// Products define the executables and libraries a package produces, and make them visible to other packages.
1010
.library(
1111
name: "xxPROJECTxNAMExx",
1212
targets: ["xxPROJECTxNAMExx"]),
@@ -17,7 +17,7 @@ let package = Package(
1717
],
1818
targets: [
1919
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
20-
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
20+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
2121
.target(
2222
name: "xxPROJECTxNAMExx",
2323
dependencies: []),

xxPROJECTxNAMExx/iOS Example/Sources/AppDelegate.swift

-37
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}

0 commit comments

Comments
 (0)