Skip to content

Commit b8e71fb

Browse files
committed
The ios build process now automatically attempts to handle pod repo update failures.
BUG=32092582 Change-Id: I4e487db89ed72bb0aa129789a719069dc8af1191
1 parent bcfbb91 commit b8e71fb

21 files changed

+93
-39
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ project.ext {
133133
buildPath = file('build').absolutePath
134134
exportPath = file('build/plugin.unitypackage').absolutePath
135135
dllDir = 'Assets/PlayServicesResolver/Editor'
136-
pluginVersion = '1.2.3.0'
136+
pluginVersion = '1.2.4.0'
137137
currentPluginPath = file('.').absolutePath
138138
currentPluginBasename = 'play-services-resolver'
139139
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.IOSResolver_v1.2.3.0.dll.meta renamed to exploded/Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.4.0.dll.meta

Lines changed: 6 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.JarResolver_v1.2.3.0.dll.meta renamed to exploded/Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.4.0.dll.meta

Lines changed: 6 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.VersionHandler_v1.2.3.0.dll.meta renamed to exploded/Assets/PlayServicesResolver/Editor/Google.VersionHandler_v1.2.4.0.dll.meta

Lines changed: 6 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.3.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.4.0.dll
2+
Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.4.0.dll
3+
Assets/PlayServicesResolver/Editor/Google.VersionHandler_v1.2.4.0.dll

exploded/Assets/PlayServicesResolver/Editor/play-services-resolver_v1.2.3.0.txt.meta renamed to exploded/Assets/PlayServicesResolver/Editor/play-services-resolver_v1.2.4.0.txt.meta

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-41.6 KB
Binary file not shown.
43.7 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/src/IOSResolver.cs

Lines changed: 62 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,35 @@ private static string FindPodTool() {
636636
return null;
637637
}
638638

639+
/// <summary>
640+
/// Finds and executes the pod command on the command line, using the
641+
/// correct environment.
642+
/// </summary>
643+
/// <param name="podArgs">Arguments passed to the pod command.</param>
644+
/// <param name="pathToBuiltProject">The path to the unity project, given
645+
/// from the unity [PostProcessBuildAttribute()] function.</param>
646+
/// <returns>The CommandLine.Result from running the command.</returns>
647+
private static CommandLine.Result RunPodCommand(string podArgs,
648+
string pathToBuiltProject) {
649+
string pod_command = FindPodTool();
650+
if (String.IsNullOrEmpty(pod_command)) {
651+
CommandLine.Result r = new CommandLine.Result();
652+
r.exitCode = 1;
653+
r.stderr = "'pod' command not found; unable to generate a usable" +
654+
" Xcode project. " + COCOAPOD_INSTALL_INSTRUCTIONS;
655+
Log(r.stderr, level: LogLevel.Error);
656+
return r;
657+
}
658+
659+
return CommandLine.Run(
660+
pod_command, podArgs, pathToBuiltProject,
661+
// cocoapods seems to require this, or it spits out a warning.
662+
envVars: new Dictionary<string,string>() {
663+
{"LANG", (System.Environment.GetEnvironmentVariable("LANG") ??
664+
"en_US.UTF-8").Split('.')[0] + ".UTF-8"}
665+
});
666+
}
667+
639668
/// <summary>
640669
/// Downloads all of the framework dependencies using pods.
641670
/// </summary>
@@ -645,36 +674,48 @@ public static void OnPostProcessInstallPods(BuildTarget buildTarget,
645674
if (!InjectDependencies()) return;
646675
if (UpdateTargetSdk()) return;
647676

648-
string pod_command = FindPodTool();
649-
if (String.IsNullOrEmpty(pod_command)) {
650-
Log("'pod' command not found; unable to generate a usable" +
651-
" Xcode project. " + COCOAPOD_INSTALL_INSTRUCTIONS,
652-
level: LogLevel.Error);
653-
return;
654-
}
655-
656677
// Require at least version 1.0.0
657-
CommandLine.Result result =
658-
CommandLine.Run(pod_command, "--version", pathToBuiltProject);
678+
CommandLine.Result result;
679+
result = RunPodCommand("--version", pathToBuiltProject);
659680
if (result.exitCode != 0 || result.stdout[0] == '0') {
660681
Log("Error running cocoapods. Please ensure you have at least " +
661682
"version 1.0.0. " + COCOAPOD_INSTALL_INSTRUCTIONS,
662683
level: LogLevel.Error);
663684
return;
664685
}
665686

666-
result = CommandLine.Run(
667-
pod_command, "install", pathToBuiltProject,
668-
// cocoapods seems to require this, or it spits out a warning.
669-
envVars: new Dictionary<string,string>() {
670-
{"LANG", (System.Environment.GetEnvironmentVariable("LANG") ??
671-
"en_US.UTF-8").Split('.')[0] + ".UTF-8"}
672-
});
687+
result = RunPodCommand("install", pathToBuiltProject);
688+
689+
// If pod installation failed it may be due to an out of date pod repo.
690+
// We'll attempt to resolve the error by updating the pod repo -
691+
// which is a slow operation - and retrying pod installation.
673692
if (result.exitCode != 0) {
674-
Log("Pod install failed. See the output below for " +
675-
"details.\n\n" + result.stdout + "\n\n" +
676-
result.stderr, level: LogLevel.Error);
677-
return;
693+
bool updateSucceeded =
694+
RunPodCommand("repo update", pathToBuiltProject).exitCode != 0;
695+
696+
// Second attempt result.
697+
// This is isolated in case it fails, so we can just report the
698+
// original failure.
699+
CommandLine.Result result2;
700+
result2 = RunPodCommand("install", pathToBuiltProject);
701+
702+
// If the repo update still didn't fix the problem...
703+
if (result2.exitCode != 0) {
704+
Log("iOS framework addition failed due to a " +
705+
"Cocoapods installation failure. This will will likely " +
706+
"result in an non-functional Xcode project.\n\n" +
707+
"After the failure, \"pod repo update\" " +
708+
"was executed and " +
709+
(updateSucceeded ? "succeeded. " : "failed. ") +
710+
"\"pod install\" was then attempted again, and still " +
711+
"failed. This may be due to a broken Cocoapods " +
712+
"installation. See: " +
713+
"https://guides.cocoapods.org/using/troubleshooting.html " +
714+
"for potential solutions.\n\n" +
715+
"See the output below for details.\n\n" + result.stdout +
716+
"\n\n" + result.stderr, level: LogLevel.Error);
717+
return;
718+
}
678719
}
679720
}
680721

0 commit comments

Comments
 (0)