You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Contributors to this project End users of this project
67
+
```
68
+
56
69
## Contributing
57
70
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.
Copy file name to clipboardExpand all lines: Recipe.md
+49-48
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,12 @@
2
2
3
3
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.
4
4
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
+
5
7
6
8
## Ingredients
7
9
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.
9
11
10
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.
11
13
@@ -35,14 +37,15 @@ Some variables have spaces in them. That is intentional because it causes Xcode
35
37
36
38
Complete all these instructions on the same calendar day.
37
39
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.*
39
41
40
42
### I. Create a package for your module
41
43
42
44
1. In Xcode, choose File > New > Swift Package…
43
45
1. Navigate to your Desktop folder
44
46
2. Type the name `xxPROJECTxNAMExx`
45
-
3. Click “Create"
47
+
3. Ensure "Create Git repository on my Mac" is unchecked
48
+
4. Click “Create"
46
49
47
50
48
51
### 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
### III. Create a Swift project for your iOS Example application
59
62
60
63
1. In Xcode, choose File > New > Project…
61
64
1.*Choose a template*
62
-
1. Click "iOS" then "Single View App"
65
+
1. Click "iOS" then "App"
63
66
64
67
2. Click "Next"
65
68
66
69
2.*Set the project options*
67
70
1. Set Product Name to "iOS Example"
68
-
2. Set Organization Name to `__ORGANIZATION NAME__`
71
+
2. Set Team to "NONE"
69
72
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
74
77
8. Click “Next"
75
78
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)
79
82
4. Click “Create"
80
83
81
84
### IV. Use the directory layout structure like Alamofire
82
85
83
86
1.*Move iOS Example source code to a folder named "Sources"*
84
87
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)
86
89
3. Use the Project navigator to select the "iOS Example" folder (yellow icon)
87
90
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)
90
92
2.*Fix the Info.plist file configuration and preview content folder (Xcode makes renaming folders a pain)*
91
93
1. Click "iOS Example" on the left (the blue icon)
92
94
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
94
96
4. Enter "/Info" in the search box
95
97
5. Edit the "Info.plist File" from "iOS Example/Info.plist" to be "Sources/Info.plist"
96
98
@@ -100,16 +102,12 @@ Use Xcode Version 11.1 (11A1027). *This is the latest publicly released or Gold
### VI. Make your iOS Example application depend on your module
107
109
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
113
111
114
112
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
113
:x:: 
@@ -121,15 +119,17 @@ Use Xcode Version 11.1 (11A1027). *This is the latest publicly released or Gold
121
119
3. Set the name as "iOS Example.xcworkspace"
122
120
4. Click Save
123
121
- ⚠️ 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
+
125
124
4.*Add a build dependency*
126
125
127
126
1. Click "iOS Example" on the left (the blue icon)
128
127
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
130
129
4. Open the section Link Binary With Libraries
131
130
5. Click the plus (+) button
132
-
6. Select xxPROJECTxNAMExx (the building icon)
131
+
6. Select `xxPROJECTxNAMExx` (the building icon)
132
+
7. Click "Add"
133
133
134
134
### VII. Add additional project management files to the module
135
135
@@ -138,7 +138,7 @@ These files represent best practices which every Swift module author should adop
138
138
1. Use Terminal.app to add additional files to the project
### VIII. Remove identifying parts of your project
153
152
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.
155
154
156
155
1. Use Terminal.app to find and replace all occurrences of hard-coded strings with template variables
157
156
158
157
```sh
159
158
find -E ~/Desktop/xxPROJECTxNAMExx \
160
-
-regex '.*\.(h|swift)' -exec sed -i '' -E -e '
161
-
s-(// +Created by ).*( on ).*\.-\1__AUTHOR NAME__\2__TODAYS_DATE__.-
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
173
172
174
173
## Taste testing
175
174
176
-
1. Open `xxPROJECTxNAMExx`.xcworkspace
175
+
1. Open iOS Example.xcodeproj in Xcode
177
176
178
177
2. Use the scheme navigator to select iOS Example and the latest iPhone version
179
178
180
179
3. Choose Product > Run
181
180
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.
182
182
*:white_check_mark: You should see a big white king (♔). That means it worked!
183
183
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
185
187
186
-
1. Clone the repository to your desktop use Terminal
0 commit comments