Skip to content

Commit

Permalink
Update how the iOS and Unity project paths are entered in the config …
Browse files Browse the repository at this point in the history
…file and built internally
  • Loading branch information
Eric Miller committed Feb 6, 2018
1 parent 732d214 commit 39a0e18
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TOOL_NAME = UnityBuildKit
VERSION = 1.1.1
VERSION = 1.1.2

PREFIX = /usr/local
INSTALL_PATH = $(PREFIX)/bin/$(TOOL_NAME)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="Assets/ubk_logo.png">
</p>
<p align="center">
<img src="https://img.shields.io/badge/version-1.1.1-blue.svg?style=flat-square" />
<img src="https://img.shields.io/badge/version-1.1.2-blue.svg?style=flat-square" />
<a href="https://github.com/handsomecode/UnityBuildKit/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square"/>
</a>
Expand Down Expand Up @@ -44,12 +44,12 @@ mkdir ExampleProject
cd ExampleProject
```

2. Run the following to generate the `ubconfig.json` file where you can specify project information
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))
```
UnityBuildKit config
```

3. After filling out the config file information, run
3. After filling out the config file, run
```
$ UnityBuildKit generate
```
Expand Down
8 changes: 4 additions & 4 deletions Sources/UBKit/Files/Config/configFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ extension File {
"ios": {
"projectName": "ExampleProject",
"bundleId": "com.example.ExampleProject",
"projectPath": "" // Defaults to iOS/
"projectPath": "" // e.g. iOS/
},
"unity": {
"projectName": "ExampleProject",
"applicationPath": "", // e.g /Applications/Unity/Unity.app/Contents/MacOS/Unity
"version": "", // e.g. 2017.1.f1
"projectPath": "", // Defaults to Unity/
"applicationPath": "", // e.g. /Applications/Unity/Unity.app/Contents/MacOS/Unity
"version": "", // e.g. 2017.2.1.f1
"projectPath": "", // e.g. Unity/
"sceneNames": [
"ExampleScene"
]
Expand Down
32 changes: 24 additions & 8 deletions Sources/UBKit/Models/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,18 @@ struct iOSConfig: Decodable {
}

let projectPath: String
if let path = try? container.decode(String.self, forKey: .projectPath), !path.isEmpty {
projectPath = path
} else {
projectPath = FileManager.default.currentDirectoryPath.appending("/iOS/")
do {
let path = try container.decode(String.self, forKey: .projectPath)
if path.isEmpty {
throw UBKitError.invalidConfigArgument(Keys.projectPath.rawValue)
}
projectPath = FileManager.default.currentDirectoryPath.appending("/").appending(path)
} catch {
throw UBKitError.invalidConfigArgument(Keys.projectPath.rawValue)
}

if !projectPath.hasSuffix("/") {
throw UBKitError.invalidConfigArgument("Project Path must end with a \"/\"")
}

self.projectName = projectName
Expand Down Expand Up @@ -113,10 +121,18 @@ struct UnityConfig {
}

let projectPath: String
if let path = try? container.decode(String.self, forKey: .projectPath), !path.isEmpty {
projectPath = path
} else {
projectPath = FileManager.default.currentDirectoryPath.appending("/Unity/")
do {
let path = try container.decode(String.self, forKey: .projectPath)
if path.isEmpty {
throw UBKitError.invalidConfigArgument(Keys.projectPath.rawValue)
}
projectPath = FileManager.default.currentDirectoryPath.appending("/").appending(path)
} catch {
throw UBKitError.invalidConfigArgument(Keys.projectPath.rawValue)
}

if !projectPath.hasSuffix("/") {
throw UBKitError.invalidConfigArgument("Project Path must end with a \"/\"")
}

let sceneNames = try container.decode([String].self, forKey: .sceneNames)
Expand Down
5 changes: 3 additions & 2 deletions Sources/UBKit/Workers/UnityProject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class UnityProject {
return .failure(UBKitError.invalidFolder(unityAppPath))
}

print("Unity Project Path: \(workingPath)\n")
let unityFolderResult = createUnityFolder()
guard unityFolderResult == .success else {
return unityFolderResult
Expand All @@ -59,7 +60,7 @@ class UnityProject {
return projectGenerationResult
}

print("\nGenerating Unity Editor scripts")
print("Generating Unity Editor scripts")
let editorScriptsResult = createUnityEditorScripts()
guard editorScriptsResult == .success else {
return editorScriptsResult
Expand Down Expand Up @@ -192,7 +193,7 @@ private extension UnityProject {
if statusCode == 0 {
return .success
} else {
return .failure(UBKitError.shellCommand("Initializing Unity Project"))
return .failure(UBKitError.shellCommand("Initializing Unity Project: \(statusCode)"))
}
case .timedOut:
return .failure(UBKitError.waitTimedOut)
Expand Down
1 change: 1 addition & 0 deletions Sources/UBKit/Workers/XcodeProject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class XcodeProject {
}

func create() -> Result {
print("iOS Project Path: \(workingPath)")
let iOSFolderResult = createiOSFolder()
guard iOSFolderResult == .success else {
return iOSFolderResult
Expand Down

0 comments on commit 39a0e18

Please sign in to comment.