Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Fix xcode paths #1040

Merged
merged 7 commits into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;

namespace Improbable.Gdk.Mobile
{
public static class BuildPostProcessXCode
{
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
{
// Only run for iOS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need that comment? think that if check is pretty self-explanatory. that's a general comment: some of the comments are good, some of them are not needed like this one or the last one for example

if (buildTarget != BuildTarget.iOS)
{
return;
}

// Load xcode project
var projPath = PBXProject.GetPBXProjectPath(path);
var xcodeProject = new PBXProject();
xcodeProject.ReadFromString(File.ReadAllText(projPath));

// Get GUIDs for target and testing targets
var targetGUID = xcodeProject.TargetGuidByName(PBXProject.GetUnityTargetName());
var targetTestingGUID = xcodeProject.TargetGuidByName(PBXProject.GetUnityTestTargetName());

// Generate list of all config guids
var configGUIDs = xcodeProject.BuildConfigNames()
.Select(configName => xcodeProject.BuildConfigByName(targetGUID, configName))
.Concat(
xcodeProject.BuildConfigNames().Select(configName =>
xcodeProject.BuildConfigByName(targetTestingGUID, configName)));

foreach (var configGUID in configGUIDs)
{
// Remove search paths unity has added for all platforms
xcodeProject.UpdateBuildPropertyForConfig(configGUID, "LIBRARY_SEARCH_PATHS", null, new[]
{
"$(SRCROOT)/Libraries/io.improbable.worker.sdk.mobile/Plugins/Improbable/Core/iOS/arm",
"$(SRCROOT)/Libraries/io.improbable.worker.sdk.mobile/Plugins/Improbable/Core/iOS/x86_64"
});

// Add platform specific paths
xcodeProject.UpdateBuildPropertyForConfig(configGUID, "LIBRARY_SEARCH_PATHS[sdk=iphoneos*]", new[]
{
"$(inherited)",
"$(SRCROOT)/Libraries/io.improbable.worker.sdk.mobile/Plugins/Improbable/Core/iOS/arm"
}, null);

xcodeProject.UpdateBuildPropertyForConfig(configGUID, "LIBRARY_SEARCH_PATHS[sdk=iphonesimulator*]",
new[]
{
"$(inherited)",
"$(SRCROOT)/Libraries/io.improbable.worker.sdk.mobile/Plugins/Improbable/Core/iOS/x86_64"
}, null);
}

// Save it to file
xcodeProject.WriteToFile(projPath);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Improbable.Worker.Sdk.Mobile",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": [],
"versionDefines": []
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.