Skip to content

Commit 39a0e18

Browse files
author
Eric Miller
committed
Update how the iOS and Unity project paths are entered in the config file and built internally
1 parent 732d214 commit 39a0e18

File tree

6 files changed

+36
-18
lines changed

6 files changed

+36
-18
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
TOOL_NAME = UnityBuildKit
2-
VERSION = 1.1.1
2+
VERSION = 1.1.2
33

44
PREFIX = /usr/local
55
INSTALL_PATH = $(PREFIX)/bin/$(TOOL_NAME)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img src="Assets/ubk_logo.png">
33
</p>
44
<p align="center">
5-
<img src="https://img.shields.io/badge/version-1.1.1-blue.svg?style=flat-square" />
5+
<img src="https://img.shields.io/badge/version-1.1.2-blue.svg?style=flat-square" />
66
<a href="https://github.com/handsomecode/UnityBuildKit/blob/master/LICENSE">
77
<img src="https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square"/>
88
</a>
@@ -44,12 +44,12 @@ mkdir ExampleProject
4444
cd ExampleProject
4545
```
4646

47-
2. Run the following to generate the `ubconfig.json` file where you can specify project information
47+
2. Run the following to generate the `ubconfig.json` file where you can specify project information (see more information [here](https://github.com/handsomecode/UnityBuildKit/wiki/Configuration-File))
4848
```
4949
UnityBuildKit config
5050
```
5151

52-
3. After filling out the config file information, run
52+
3. After filling out the config file, run
5353
```
5454
$ UnityBuildKit generate
5555
```

Sources/UBKit/Files/Config/configFile.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ extension File {
3131
"ios": {
3232
"projectName": "ExampleProject",
3333
"bundleId": "com.example.ExampleProject",
34-
"projectPath": "" // Defaults to iOS/
34+
"projectPath": "" // e.g. iOS/
3535
},
3636
"unity": {
3737
"projectName": "ExampleProject",
38-
"applicationPath": "", // e.g /Applications/Unity/Unity.app/Contents/MacOS/Unity
39-
"version": "", // e.g. 2017.1.f1
40-
"projectPath": "", // Defaults to Unity/
38+
"applicationPath": "", // e.g. /Applications/Unity/Unity.app/Contents/MacOS/Unity
39+
"version": "", // e.g. 2017.2.1.f1
40+
"projectPath": "", // e.g. Unity/
4141
"sceneNames": [
4242
"ExampleScene"
4343
]

Sources/UBKit/Models/Config.swift

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,18 @@ struct iOSConfig: Decodable {
6464
}
6565

6666
let projectPath: String
67-
if let path = try? container.decode(String.self, forKey: .projectPath), !path.isEmpty {
68-
projectPath = path
69-
} else {
70-
projectPath = FileManager.default.currentDirectoryPath.appending("/iOS/")
67+
do {
68+
let path = try container.decode(String.self, forKey: .projectPath)
69+
if path.isEmpty {
70+
throw UBKitError.invalidConfigArgument(Keys.projectPath.rawValue)
71+
}
72+
projectPath = FileManager.default.currentDirectoryPath.appending("/").appending(path)
73+
} catch {
74+
throw UBKitError.invalidConfigArgument(Keys.projectPath.rawValue)
75+
}
76+
77+
if !projectPath.hasSuffix("/") {
78+
throw UBKitError.invalidConfigArgument("Project Path must end with a \"/\"")
7179
}
7280

7381
self.projectName = projectName
@@ -113,10 +121,18 @@ struct UnityConfig {
113121
}
114122

115123
let projectPath: String
116-
if let path = try? container.decode(String.self, forKey: .projectPath), !path.isEmpty {
117-
projectPath = path
118-
} else {
119-
projectPath = FileManager.default.currentDirectoryPath.appending("/Unity/")
124+
do {
125+
let path = try container.decode(String.self, forKey: .projectPath)
126+
if path.isEmpty {
127+
throw UBKitError.invalidConfigArgument(Keys.projectPath.rawValue)
128+
}
129+
projectPath = FileManager.default.currentDirectoryPath.appending("/").appending(path)
130+
} catch {
131+
throw UBKitError.invalidConfigArgument(Keys.projectPath.rawValue)
132+
}
133+
134+
if !projectPath.hasSuffix("/") {
135+
throw UBKitError.invalidConfigArgument("Project Path must end with a \"/\"")
120136
}
121137

122138
let sceneNames = try container.decode([String].self, forKey: .sceneNames)

Sources/UBKit/Workers/UnityProject.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class UnityProject {
4747
return .failure(UBKitError.invalidFolder(unityAppPath))
4848
}
4949

50+
print("Unity Project Path: \(workingPath)\n")
5051
let unityFolderResult = createUnityFolder()
5152
guard unityFolderResult == .success else {
5253
return unityFolderResult
@@ -59,7 +60,7 @@ class UnityProject {
5960
return projectGenerationResult
6061
}
6162

62-
print("\nGenerating Unity Editor scripts")
63+
print("Generating Unity Editor scripts")
6364
let editorScriptsResult = createUnityEditorScripts()
6465
guard editorScriptsResult == .success else {
6566
return editorScriptsResult
@@ -192,7 +193,7 @@ private extension UnityProject {
192193
if statusCode == 0 {
193194
return .success
194195
} else {
195-
return .failure(UBKitError.shellCommand("Initializing Unity Project"))
196+
return .failure(UBKitError.shellCommand("Initializing Unity Project: \(statusCode)"))
196197
}
197198
case .timedOut:
198199
return .failure(UBKitError.waitTimedOut)

Sources/UBKit/Workers/XcodeProject.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class XcodeProject {
5454
}
5555

5656
func create() -> Result {
57+
print("iOS Project Path: \(workingPath)")
5758
let iOSFolderResult = createiOSFolder()
5859
guard iOSFolderResult == .success else {
5960
return iOSFolderResult

0 commit comments

Comments
 (0)