diff --git a/Makefile b/Makefile index baad4d8..3b14ea6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ TOOL_NAME = UnityBuildKit -VERSION = 1.1.1 +VERSION = 1.1.2 PREFIX = /usr/local INSTALL_PATH = $(PREFIX)/bin/$(TOOL_NAME) diff --git a/README.md b/README.md index f5aa855..af357b6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@
- + @@ -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 ``` diff --git a/Sources/UBKit/Files/Config/configFile.swift b/Sources/UBKit/Files/Config/configFile.swift index 413bbba..679ce7e 100644 --- a/Sources/UBKit/Files/Config/configFile.swift +++ b/Sources/UBKit/Files/Config/configFile.swift @@ -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" ] diff --git a/Sources/UBKit/Models/Config.swift b/Sources/UBKit/Models/Config.swift index a2d5161..3051534 100644 --- a/Sources/UBKit/Models/Config.swift +++ b/Sources/UBKit/Models/Config.swift @@ -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 @@ -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) diff --git a/Sources/UBKit/Workers/UnityProject.swift b/Sources/UBKit/Workers/UnityProject.swift index c9ad9e7..e41abbb 100644 --- a/Sources/UBKit/Workers/UnityProject.swift +++ b/Sources/UBKit/Workers/UnityProject.swift @@ -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 @@ -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 @@ -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) diff --git a/Sources/UBKit/Workers/XcodeProject.swift b/Sources/UBKit/Workers/XcodeProject.swift index d201ccf..96efbc5 100644 --- a/Sources/UBKit/Workers/XcodeProject.swift +++ b/Sources/UBKit/Workers/XcodeProject.swift @@ -54,6 +54,7 @@ class XcodeProject { } func create() -> Result { + print("iOS Project Path: \(workingPath)") let iOSFolderResult = createiOSFolder() guard iOSFolderResult == .success else { return iOSFolderResult