Skip to content

Commit 345bc7c

Browse files
Stewart MilesGerrit Code Review
Stewart Miles
authored and
Gerrit Code Review
committed
Merge "Fixed IOSResolver errors when iOS support is not installed."
2 parents a2853e1 + 5d8b87a commit 345bc7c

25 files changed

+121
-55
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Version 1.2.6 - Nov 15, 2016
2+
## Bug Fixes
3+
* Fixed IOSResolver errors when iOS support is not installed.
4+
* Added fallback to "pod" executable search which queries the Ruby Gems
5+
package manager for the binary install location.
6+
17
# Version 1.2.5 - Nov 3, 2016
28
## Bug Fixes
39
* Added crude support for source only Cocoapods to the IOSResolver.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ project.ext {
138138
buildPath = file('build').absolutePath
139139
exportPath = file('build/plugin.unitypackage').absolutePath
140140
dllDir = 'Assets/PlayServicesResolver/Editor'
141-
pluginVersion = '1.2.5.0'
141+
pluginVersion = '1.2.6.0'
142142
currentPluginPath = file('.').absolutePath
143143
currentPluginBasename = 'play-services-resolver'
144144
currentPluginName = (currentPluginBasename + '-' + pluginVersion +

exploded/Assets/PlayServicesResolver/Editor.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.

exploded/Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.5.0.dll.meta renamed to exploded/Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.6.0.dll.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exploded/Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.5.0.dll.meta renamed to exploded/Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.6.0.dll.meta

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exploded/Assets/PlayServicesResolver/Editor/Google.VersionHandler_v1.2.5.0.dll.meta renamed to exploded/Assets/PlayServicesResolver/Editor/Google.VersionHandler_v1.2.6.0.dll.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exploded/Assets/PlayServicesResolver/Editor/play-services-resolver_v1.2.5.0.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.6.0.dll
2+
Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.6.0.dll
3+
Assets/PlayServicesResolver/Editor/Google.VersionHandler_v1.2.6.0.dll

exploded/Assets/PlayServicesResolver/Editor/play-services-resolver_v1.2.5.0.txt.meta renamed to exploded/Assets/PlayServicesResolver/Editor/play-services-resolver_v1.2.6.0.txt.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-41.4 KB
Binary file not shown.
41.8 KB
Binary file not shown.

plugin/Assets/PlayServicesResolver.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/Assets/PlayServicesResolver/Editor.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/Assets/PlayServicesResolver/Editor/Google.IOSResolver.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/Assets/PlayServicesResolver/Editor/Google.JarResolver.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/Assets/PlayServicesResolver/Editor/Google.VersionHandler.dll.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/Assets/PlayServicesResolver/Editor/play-services-resolver.txt.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/IOSResolver/IOSResolver.csproj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<DebugType>none</DebugType>
2727
<Optimize>True</Optimize>
2828
<OutputPath>bin\Release</OutputPath>
29+
<DefineConstants>DEBUG;UNITY_EDITOR;UNITY_IOS</DefineConstants>
2930
<ErrorReport>prompt</ErrorReport>
3031
<WarningLevel>4</WarningLevel>
3132
<ConsolePause>False</ConsolePause>
@@ -41,14 +42,16 @@
4142
<Reference Include="UnityEngine">
4243
<HintPath>$(UnityHintPath)/UnityEngine.dll</HintPath>
4344
</Reference>
44-
<Reference Include="Unity.UNetWeaver">
45-
<HintPath>$(UnityHintPath)/Unity.UNetWeaver.dll</HintPath>
46-
</Reference>
4745
<Reference Include="UnityEditor.iOS.Extensions.Xcode">
4846
<HintPath>$(UnityIosPath)/UnityEditor.iOS.Extensions.Xcode.dll</HintPath>
47+
<HintPath>$(UnityIosPath)/Unity.iOS.Extensions.Xcode.dll</HintPath>
4948
</Reference>
5049
<Reference Include="System" />
50+
<Reference Include="System.Core" />
5151
<Reference Include="System.Xml" />
52+
<Reference Include="Google.JarResolver" >
53+
<HintPath>..\PlayServicesResolver\bin\Release\Google.JarResolver.dll</HintPath>
54+
</Reference>
5255
</ItemGroup>
5356
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
5457
<ItemGroup>

source/IOSResolver/src/IOSResolver.cs

Lines changed: 86 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,13 @@ public static SortedDictionary<int, List<string>>
155155
" > sudo gem install -n /usr/local/bin cocoapods\n" +
156156
" > pod setup");
157157

158-
// Paths to search for the "pod" command.
158+
// Pod executable filename.
159+
private static string POD_EXECUTABLE = "pod";
160+
// Default paths to search for the "pod" command before falling back to
161+
// querying the Ruby Gem tool for the environment.
159162
private static string[] POD_SEARCH_PATHS = new string[] {
160-
"/usr/local/bin/pod",
161-
"/usr/bin/pod",
163+
"/usr/local/bin",
164+
"/usr/bin",
162165
};
163166

164167
// Extensions of pod source files to include in the project.
@@ -297,28 +300,35 @@ static IOSResolver() {
297300
// dependencies of a method are loaded before the method is executed
298301
// so we install the DLL loader first then try using the Xcode module.
299302
RemapXcodeExtension();
300-
InitializeTargetName();
303+
// NOTE: It's not possible to catch exceptions a missing reference
304+
// to the UnityEditor.iOS.Xcode assembly in this method as the runtime
305+
// will attempt to load the assemebly before the method is executed so
306+
// we handle exceptions here.
307+
try {
308+
InitializeTargetName();
309+
} catch (Exception exception) {
310+
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS) {
311+
Log("Failed: " + exception.ToString(), level: LogLevel.Error);
312+
if (exception is FileNotFoundException ||
313+
exception is TypeInitializationException ||
314+
exception is TargetInvocationException) {
315+
// It's likely we failed to load the iOS Xcode extension.
316+
Debug.LogWarning(
317+
"Failed to load the " +
318+
"UnityEditor.iOS.Extensions.Xcode dll. " +
319+
"Is iOS support installed?");
320+
} else {
321+
throw exception;
322+
}
323+
}
324+
}
301325
}
302326

303327
/// <summary>
304328
/// Initialize the TARGET_NAME property.
305329
/// </summary>
306330
private static void InitializeTargetName() {
307-
try {
308-
TARGET_NAME = UnityEditor.iOS.Xcode.PBXProject.GetUnityTargetName();
309-
} catch (Exception exception) {
310-
Log("Failed: " + exception.ToString(), level: LogLevel.Error);
311-
if (exception is FileNotFoundException ||
312-
exception is TypeInitializationException ||
313-
exception is TargetInvocationException) {
314-
// It's likely we failed to load the iOS Xcode extension.
315-
Debug.LogWarning(
316-
"Failed to load the UnityEditor.iOS.Extensions.Xcode " +
317-
"dll. Is iOS support installed?");
318-
} else {
319-
throw exception;
320-
}
321-
}
331+
TARGET_NAME = UnityEditor.iOS.Xcode.PBXProject.GetUnityTargetName();
322332
}
323333

324334
// Fix loading of the Xcode extension dll.
@@ -595,7 +605,15 @@ private static List<string> FindPodsWithBitcodeDisabled() {
595605
public static void OnPostProcessPatchProject(BuildTarget buildTarget,
596606
string pathToBuiltProject) {
597607
if (!InjectDependencies()) return;
608+
PatchProject(buildTarget, pathToBuiltProject);
609+
}
598610

611+
// Implementation of OnPostProcessPatchProject().
612+
// NOTE: This is separate from the post-processing method to prevent the
613+
// Mono runtime from loading the Xcode API before calling the post
614+
// processing step.
615+
internal static void PatchProject(
616+
BuildTarget buildTarget, string pathToBuiltProject) {
599617
var podsWithoutBitcode = FindPodsWithBitcodeDisabled();
600618
bool bitcodeDisabled = podsWithoutBitcode.Count > 0;
601619
if (bitcodeDisabled) {
@@ -633,7 +651,15 @@ public static void OnPostProcessPatchProject(BuildTarget buildTarget,
633651
public static void OnPostProcessGenPodfile(BuildTarget buildTarget,
634652
string pathToBuiltProject) {
635653
if (!InjectDependencies()) return;
654+
GenPodfile(buildTarget, pathToBuiltProject);
655+
}
636656

657+
// Implementation of OnPostProcessGenPodfile().
658+
// NOTE: This is separate from the post-processing method to prevent the
659+
// Mono runtime from loading the Xcode API before calling the post
660+
// processing step.
661+
public static void GenPodfile(BuildTarget buildTarget,
662+
string pathToBuiltProject) {
637663
using (StreamWriter file =
638664
new StreamWriter(Path.Combine(pathToBuiltProject, "Podfile"))) {
639665
file.Write("source 'https://github.com/CocoaPods/Specs.git'\n" +
@@ -654,8 +680,35 @@ public static void OnPostProcessGenPodfile(BuildTarget buildTarget,
654680
/// <returns>Path to the pod tool if successful, null otherwise.</returns>
655681
private static string FindPodTool() {
656682
foreach (string path in POD_SEARCH_PATHS) {
657-
if (File.Exists(path)) {
658-
return path;
683+
string podPath = Path.Combine(path, POD_EXECUTABLE);
684+
Log("Searching for cocoapods tool in " + podPath,
685+
verbose: true);
686+
if (File.Exists(podPath)) {
687+
Log("Found cocoapods tool in " + podPath, verbose: true);
688+
return podPath;
689+
}
690+
}
691+
Log("Querying gems for cocoapods install path", verbose: true);
692+
var result = CommandLine.Run("gem", "environment");
693+
if (result.exitCode == 0) {
694+
// gem environment outputs YAML for all config variables,
695+
// the following code only parses the executable dir from the
696+
// output.
697+
const string executableDir = "- EXECUTABLE DIRECTORY:";
698+
char[] variableSeparator = new char[] { ':' };
699+
foreach (var line in result.stdout.Split(
700+
new char[] { '\r', '\n' })) {
701+
if (line.Trim().StartsWith(executableDir)) {
702+
string path = line.Split(variableSeparator)[1].Trim();
703+
string podPath = Path.Combine(path, POD_EXECUTABLE);
704+
Log("Checking gems install path for cocoapods tool " +
705+
podPath, verbose: true);
706+
if (File.Exists(podPath)) {
707+
Log("Found cocoapods tool in " + podPath,
708+
verbose: true);
709+
return podPath;
710+
}
711+
}
659712
}
660713
}
661714
return null;
@@ -704,8 +757,10 @@ public static void OnPostProcessInstallPods(BuildTarget buildTarget,
704757
result = RunPodCommand("--version", pathToBuiltProject);
705758
if (result.exitCode != 0 || result.stdout[0] == '0') {
706759
Log("Error running cocoapods. Please ensure you have at least " +
707-
"version 1.0.0. " + COCOAPOD_INSTALL_INSTRUCTIONS,
708-
level: LogLevel.Error);
760+
"version 1.0.0. " + COCOAPOD_INSTALL_INSTRUCTIONS + "\n\n" +
761+
"'" + POD_EXECUTABLE + " --version' returned status: " +
762+
result.exitCode.ToString() + "\n" +
763+
"output: " + result.stdout, level: LogLevel.Error);
709764
return;
710765
}
711766

@@ -767,7 +822,15 @@ internal static List<string> FindFilesWithExtensions(
767822
public static void OnPostProcessUpdateProjectDeps(
768823
BuildTarget buildTarget, string pathToBuiltProject) {
769824
if (!InjectDependencies()) return;
825+
UpdateProjectDeps(buildTarget, pathToBuiltProject);
826+
}
770827

828+
// Implementation of OnPostProcessUpdateProjectDeps().
829+
// NOTE: This is separate from the post-processing method to prevent the
830+
// Mono runtime from loading the Xcode API before calling the post
831+
// processing step.
832+
public static void UpdateProjectDeps(
833+
BuildTarget buildTarget, string pathToBuiltProject) {
771834
// If the Pods directory does not exist, the pod download step
772835
// failed.
773836
var podsDir = Path.Combine(pathToBuiltProject, PODS_DIR);

source/PlayServicesResolver/PlayServicesResolver.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<DebugType>none</DebugType>
2727
<Optimize>True</Optimize>
2828
<OutputPath>bin\Release</OutputPath>
29+
<DefineConstants>DEBUG;UNITY_EDITOR</DefineConstants>
2930
<ErrorReport>prompt</ErrorReport>
3031
<WarningLevel>4</WarningLevel>
3132
<ConsolePause>False</ConsolePause>
@@ -40,10 +41,8 @@
4041
<Reference Include="UnityEngine">
4142
<HintPath>$(UnityHintPath)/UnityEngine.dll</HintPath>
4243
</Reference>
43-
<Reference Include="Unity.UNetWeaver">
44-
<HintPath>$(UnityHintPath)/Unity.UNetWeaver.dll</HintPath>
45-
</Reference>
4644
<Reference Include="System" />
45+
<Reference Include="System.Core" />
4746
<Reference Include="System.Xml" />
4847
</ItemGroup>
4948
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

source/VersionHandler/VersionHandler.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<DebugType>none</DebugType>
2727
<Optimize>True</Optimize>
2828
<OutputPath>bin\Release</OutputPath>
29+
<DefineConstants>DEBUG;UNITY_EDITOR</DefineConstants>
2930
<ErrorReport>prompt</ErrorReport>
3031
<WarningLevel>4</WarningLevel>
3132
<ConsolePause>False</ConsolePause>
@@ -40,10 +41,8 @@
4041
<Reference Include="UnityEngine">
4142
<HintPath>$(UnityHintPath)/UnityEngine.dll</HintPath>
4243
</Reference>
43-
<Reference Include="Unity.UNetWeaver">
44-
<HintPath>$(UnityHintPath)/Unity.UNetWeaver.dll</HintPath>
45-
</Reference>
4644
<Reference Include="System" />
45+
<Reference Include="System.Core" />
4746
<Reference Include="System.Xml" />
4847
</ItemGroup>
4948
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

0 commit comments

Comments
 (0)