Skip to content

Commit d26e353

Browse files
author
Eric Miller
committed
Add custom project paths to refresh script
1 parent 498bfa0 commit d26e353

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Sources/UBKit/Files/Unity/UnityProjectScript.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Foundation
2626

2727
extension File {
2828

29-
class func unityProjectScriptFile() -> Data? {
29+
class func unityProjectScriptFile(projectName: String, iOSProjectPath: String) -> Data? {
3030
let file = """
3131
using System.Linq;
3232
using System.Collections.Generic;
@@ -39,11 +39,11 @@ extension File {
3939
4040
public class XcodeRefresher {
4141
42-
private const string XcodeProjectRoot = "../../iOS";
43-
private const string XcodeProjectName = "UnityBuildKit";
42+
private const string iOSProjectRoot = \"\(iOSProjectPath)\";
43+
private const string iOSProjectName = \"\(projectName)\";
4444
private const string ClassesProjectPath = "Vendor/UBK/Classes";
4545
private const string LibrariesProjectPath = "Vendor/UBK/Libraries";
46-
private const string PbxFilePath = XcodeProjectName + ".xcodeproj/project.pbxproj";
46+
private const string PbxFilePath = iOSProjectName + ".xcodeproj/project.pbxproj";
4747
4848
public static void Refresh() {
4949
var pathToBuiltProject = GetArg ("-buildPath");
@@ -59,19 +59,19 @@ extension File {
5959
6060
private static void UpdateUnityProjectFiles(string pathToBuiltProject) {
6161
var pbx = new PBXProject();
62-
var pbxPath = Path.Combine(XcodeProjectRoot, PbxFilePath);
62+
var pbxPath = Path.Combine(iOSProjectRoot, PbxFilePath);
6363
pbx.ReadFromFile(pbxPath);
6464
6565
ProcessUnityDirectory(
6666
pbx,
6767
Path.Combine(pathToBuiltProject, "Classes"),
68-
Path.Combine(XcodeProjectRoot, ClassesProjectPath),
68+
Path.Combine(iOSProjectRoot, ClassesProjectPath),
6969
ClassesProjectPath);
7070
7171
ProcessUnityDirectory(
7272
pbx,
7373
Path.Combine(pathToBuiltProject, "Libraries"),
74-
Path.Combine(XcodeProjectRoot, LibrariesProjectPath),
74+
Path.Combine(iOSProjectRoot, LibrariesProjectPath),
7575
LibrariesProjectPath);
7676
7777
pbx.WriteToFile(pbxPath);
@@ -94,7 +94,7 @@ extension File {
9494
/// project for Unity code files. E.g. "DempApp/Unity/Classes" for all files
9595
/// under Classes folder from Unity iOS build output.</param>
9696
private static void ProcessUnityDirectory(PBXProject pbx, string src, string dest, string projectPathPrefix) {
97-
var targetGuid = pbx.TargetGuidByName(XcodeProjectName);
97+
var targetGuid = pbx.TargetGuidByName(iOSProjectName);
9898
9999
string[] newFiles, extraFiles;
100100
CompareDirectories(src, dest, out newFiles, out extraFiles);

Sources/UBKit/Workers/UnityProject.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Foundation
2525

2626
class UnityProject {
2727

28+
private let config: Config
2829
private let workingPath: String
2930
private let projectName: String
3031
private let unitySceneNames: [String]
@@ -34,6 +35,7 @@ class UnityProject {
3435
private let unityAppPath: String
3536

3637
init(config: Config) {
38+
self.config = config
3739
self.projectName = config.iOS.projectName
3840
self.workingPath = config.unity.projectPath
3941
self.unityAppPath = config.unity.applicationPath
@@ -163,7 +165,7 @@ private extension UnityProject {
163165

164166
guard fileManager.createFile(
165167
atPath: editorFilePath.appending("ProjectScript.cs"),
166-
contents: File.unityProjectScriptFile(),
168+
contents: File.unityProjectScriptFile(projectName: projectName, iOSProjectPath: config.iOS.projectPath),
167169
attributes: nil) else {
168170
return .failure(UBKitError.unableToCreateFile("Unity Project Script"))
169171
}

0 commit comments

Comments
 (0)