Skip to content

Commit

Permalink
Update dependencies. Resolve issue with Data reference folder not pro…
Browse files Browse the repository at this point in the history
…perly being added to project.
  • Loading branch information
Eric Miller committed Jan 31, 2018
1 parent 66daddd commit 552e61c
Show file tree
Hide file tree
Showing 10 changed files with 1,064 additions and 1,258 deletions.
39 changes: 24 additions & 15 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"repositoryURL": "https://github.com/tadija/AEXML.git",
"state": {
"branch": null,
"revision": "2981eccd86a69ea12a7f71a4c6b4d5177c2972a9",
"version": "4.1.0"
"revision": "09f27784d9e328670ef0a181c832cce497117131",
"version": "4.2.2"
}
},
{
"package": "Commander",
"repositoryURL": "https://github.com/kylef/Commander.git",
"state": {
"branch": null,
"revision": "4c320a3507d621d27f89514eb576664becfee643",
"version": "0.6.1"
"revision": "e5b50ad7b2e91eeb828393e89b03577b16be7db9",
"version": "0.8.0"
}
},
{
Expand All @@ -33,16 +33,25 @@
"repositoryURL": "https://github.com/kylef/PathKit.git",
"state": {
"branch": null,
"revision": "891a3fec2699fc43aed18b7649950677c0152a22",
"version": "0.8.0"
"revision": "404d60fd725d1ba7dbf55cb95a3046285a066169",
"version": "0.9.0"
}
},
{
"package": "Rainbow",
"repositoryURL": "https://github.com/onevcat/Rainbow.git",
"state": {
"branch": null,
"revision": "df197437d8acefb2ae01ab073be1d531fe7781ef",
"revision": "f407235c7e473c3cb2d2907bb6822616d22a0b78",
"version": "3.0.3"
}
},
{
"package": "ShellOut",
"repositoryURL": "https://github.com/JohnSundell/ShellOut.git",
"state": {
"branch": null,
"revision": "f1c253a34a40df4bfd268b09fdb101b059f6d52d",
"version": "2.1.0"
}
},
Expand All @@ -51,35 +60,35 @@
"repositoryURL": "https://github.com/kylef/Spectre.git",
"state": {
"branch": null,
"revision": "e46b75cf03ad5e563b4b0a5068d3d6f04d77d80b",
"version": "0.7.2"
"revision": "e34d5687e1e9d865e3527dd58bc2f7464ef6d936",
"version": "0.8.0"
}
},
{
"package": "XcodeGen",
"repositoryURL": "https://github.com/yonaskolb/XcodeGen.git",
"state": {
"branch": null,
"revision": "4539ead7f99e4595856e4cb30fad5d2b515aa1d0",
"version": "1.3.0"
"revision": "1153e020e18408f8f2c77597450adc8f7e924cc8",
"version": "1.5.0"
}
},
{
"package": "Yams",
"repositoryURL": "https://github.com/jpsim/Yams.git",
"state": {
"branch": null,
"revision": "05921531200acff0d8d9caab5ec77b2bcf300b6b",
"version": "0.3.7"
"revision": "95f45caf07472ec78223ebada45255086a85b01a",
"version": "0.5.0"
}
},
{
"package": "xcproj",
"repositoryURL": "https://github.com/xcodeswift/xcproj.git",
"state": {
"branch": null,
"revision": "cd1c329c6e092fdf5afbddf10dd59da564293aa6",
"version": "0.4.1"
"revision": "1b0864a4417efc35c21fdc7d98d3c9bb0152eaf9",
"version": "1.8.0"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let package = Package(
.library(name: "UBKit", targets: ["UBKit"]),
],
dependencies: [
.package(url: "https://github.com/yonaskolb/XcodeGen.git", from: "1.2.4")
.package(url: "https://github.com/yonaskolb/XcodeGen.git", from: "1.4.0")
],
targets: [
.target(
Expand Down
20 changes: 19 additions & 1 deletion Sources/UBKit/Files/Unity/UnityEditorBuildScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,23 @@ import Foundation

extension File {

class func unityBuildScriptFile() -> Data? {
class func unityBuildScriptFile(iOSProjectFolderPath: String, iOSProjectName: String) -> Data? {
let file = """
using System.Collections;
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
using UnityEditor.iOS.Xcode;
public class iOSBuilder: MonoBehaviour {
private const string iOSProjectRoot = \"\(iOSProjectFolderPath)\";
private const string iOSProjectName = \"\(iOSProjectName)\";
private const string DataProjectPath = "Vendor/UBK/Data";
private const string PbxFilePath = iOSProjectName + ".xcodeproj/project.pbxproj";
public static void Perform () {
var outputLocation = GetArg ("-outputLocation");
var sceneName = GetArg ("-sceneName");
Expand All @@ -51,6 +58,17 @@ extension File {
playerOptions.target = BuildTarget.iOS;
playerOptions.options = BuildOptions.None;
BuildPipeline.BuildPlayer (playerOptions);
var pbx = new PBXProject();
var pbxPath = Path.Combine(iOSProjectRoot, PbxFilePath);
pbx.ReadFromFile(pbxPath);
var folderGuid = pbx.AddFolderReference(Path.Combine(outputLocation, "Data"), Path.Combine(iOSProjectRoot, DataProjectPath), PBXSourceTree.Absolute);
var targetGiud = pbx.TargetGuidByName(iOSProjectName);
var resourceGiud = pbx.GetResourcesBuildPhaseByTarget(targetGiud);
pbx.AddFileToBuildSection(targetGiud, resourceGiud, folderGuid);
pbx.WriteToFile(pbxPath);
}
private static string GetArg (string name) {
Expand Down
3 changes: 0 additions & 3 deletions Sources/UBKit/Files/Xcode/SpecFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ extension File {
sources:
- \(projectName)
- Vendor
postbuildScripts:
- script: rm -rf "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Data"\\ncp -Rf "$UNITY_IOS_EXPORT_PATH/Data" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Data"
name: UnityBuildKit Postbuild
settings:
PRODUCT_BUNDLE_IDENTIFIER: \(bundleIdentifier)
IOS_DEPLOYMENT_TARGET: 11.0
Expand Down
29 changes: 22 additions & 7 deletions Sources/UBKit/Workers/FileCopier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,21 @@ class FileCopier {
return parseProjectResult
}

// print("Preparing Build Phase")
let frameworkPhaseResult = addFrameworksBuildPhase()
guard frameworkPhaseResult == .success else {
return frameworkPhaseResult
}

// print("Saving Xcode project")
let saveResult = saveProject()
guard saveResult == .success else {
return saveResult
}

// print("Changing Unity Files")
let changeFilesResult = changeUnityFiles()
guard changeFilesResult == .success else {
return changeFilesResult
}

// print("Adding Unity Files")
let unityFilesResult = addUnityFiles()
guard unityFilesResult == .success else {
return unityFilesResult
Expand All @@ -105,14 +101,33 @@ private extension FileCopier {
return .failure(UBKitError.invalidXcodeProject("Failed to find project file"))
}

guard let mainTarget = project.pbxproj.nativeTargets.filter({ $0.name == config.iOS.projectName }).first else {
guard let mainTarget = project.pbxproj.objects.nativeTargets.filter({ $0.value.name == config.iOS.projectName }).first else {
return .failure(UBKitError.invalidXcodeProject("Missing main target"))
}

let frameworksBuildPhase = PBXFrameworksBuildPhase(reference: generateUUID(PBXFrameworksBuildPhase.self,
"frameworks".appending(nameSalt)))
mainTarget.buildPhases.append(frameworksBuildPhase.reference)
project.pbxproj.addObject(frameworksBuildPhase)
mainTarget.value.buildPhases.append(frameworksBuildPhase.reference)
project.pbxproj.objects.addObject(frameworksBuildPhase)

return .success
}

func x() -> Result {
guard let project = project else {
return .failure(UBKitError.invalidXcodeProject("Failed to find project file"))
}

guard let mainTarget = project.pbxproj.objects.nativeTargets.filter({ $0.value.name == config.iOS.projectName }).first else {
return .failure(UBKitError.invalidXcodeProject("Missing main target"))
}

for phase in mainTarget.value.buildPhases {
if phase.starts(with: "RBP_") {

break
}
}

return .success
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/UBKit/Workers/UnityProject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private extension UnityProject {

guard fileManager.createFile(
atPath: editorFilePath.appending("iOSBuildScript.cs"),
contents: File.unityBuildScriptFile(),
contents: File.unityBuildScriptFile(iOSProjectFolderPath: config.iOS.projectPath, iOSProjectName: projectName),
attributes: nil) else {
return .failure(UBKitError.unableToCreateFile("Unity iOS Build Script"))
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/UBKit/Workers/XcodeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private extension XcodeGenerator {

let spec: ProjectSpec
do {
spec = try SpecLoader.loadSpec(path: specPath)
spec = try ProjectSpec(path: specPath)
} catch let error as JSONUtilities.DecodingError {
return .failure(error)
} catch {
Expand Down
4 changes: 0 additions & 4 deletions Sources/UBKit/Workers/XcodeProject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class XcodeProject {
return iOSFolderResult
}

// print("Generating iOS spec file")
let specFileResult = createSpecFile()
guard specFileResult == .success else {
return specFileResult
Expand All @@ -66,7 +65,6 @@ class XcodeProject {
return projectFolderResult
}

// print("Generating iOS source files")
let sourceFileResult = createSourceFiles()
guard sourceFileResult == .success else {
return sourceFileResult
Expand All @@ -77,7 +75,6 @@ class XcodeProject {
return assetCatalogResult
}

// print("Generating Unity bridging files")
let unityFilesResult = createUnityBridgeFiles()
guard unityFilesResult == .success else {
return unityFilesResult
Expand All @@ -88,7 +85,6 @@ class XcodeProject {
return unityFolderResult
}

// print("Generating iOS project")
let projectGenerationResult = generateXcodeProject()
guard projectGenerationResult == .success else {
return projectGenerationResult
Expand Down
Loading

0 comments on commit 552e61c

Please sign in to comment.