private static void CreateDesktopJsonFromPlist(string sourceFilename)
        {
            string projectDir = GenerateXmlFromGoogleServicesJson.GetProjectDir();
            string text       = Path.Combine(projectDir, sourceFilename);
            string text2      = Path.Combine(projectDir, GenerateXmlFromGoogleServicesJson.google_services_desktop_output_path);

            if (File.Exists(text2) && File.GetLastWriteTime(text2).CompareTo(File.GetLastWriteTime(text)) >= 0)
            {
                return;
            }
            if (GenerateXmlFromGoogleServicesJson.PrepareJsonDirectory())
            {
                CommandLine.Result result = GenerateXmlFromGoogleServicesJson.RunResourceGenerator(string.Concat(new string[]
                {
                    "-i \"",
                    text,
                    "\" -o \"",
                    text2,
                    "\" --plist"
                }), sourceFilename, false);
                if (result.exitCode != 0)
                {
                    Debug.LogError(DocStrings.DocRef.CouldNotTranslatePlist.Format(new object[]
                    {
                        sourceFilename
                    }));
                }
            }
        }
示例#2
0
        public static void OnPostProcessInstallPods(BuildTarget buildTarget,
                                                    string pathToBuiltProject)
        {
            if (!InjectDependencies())
            {
                return;
            }
            if (UpdateTargetSdk())
            {
                return;
            }

            string pod_command = FindPodTool();

            if (String.IsNullOrEmpty(pod_command))
            {
                Log("'pod' command not found; unable to generate a usable" +
                    " Xcode project. " + COCOAPOD_INSTALL_INSTRUCTIONS,
                    level: LogLevel.Error);
                return;
            }

            // Require at least version 1.0.0
            CommandLine.Result result =
                CommandLine.Run(pod_command, "--version", pathToBuiltProject);
            if (result.exitCode != 0 || result.stdout[0] == '0')
            {
                Log("Error running cocoapods. Please ensure you have at least " +
                    "version  1.0.0.  " + COCOAPOD_INSTALL_INSTRUCTIONS,
                    level: LogLevel.Error);
                return;
            }

            result = CommandLine.Run(
                pod_command, "install", pathToBuiltProject,
                // cocoapods seems to require this, or it spits out a warning.
                envVars: new Dictionary <string, string>()
            {
                { "LANG", (System.Environment.GetEnvironmentVariable("LANG") ??
                           "en_US.UTF-8").Split('.')[0] + ".UTF-8" }
            });
            if (result.exitCode != 0)
            {
                Log("Pod install failed. See the output below for " +
                    "details.\n\n" + result.stdout + "\n\n" +
                    result.stderr, level: LogLevel.Error);
                return;
            }
        }
        private static Dictionary <string, string> ReadProjectFields(string googleServicesFile)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            CommandLine.Result result = GenerateXmlFromGoogleServicesJson.RunResourceGenerator("-i \"" + googleServicesFile + "\" -f", googleServicesFile, false);
            if (result.exitCode == 0)
            {
                string[] array = result.stdout.Split(GenerateXmlFromGoogleServicesJson.newline_chars);
                for (int i = 0; i < array.Length; i++)
                {
                    string   text   = array[i];
                    string[] array2 = text.Split(GenerateXmlFromGoogleServicesJson.field_delimiter);
                    if (array2.Length == 2)
                    {
                        dictionary[array2[0]] = array2[1];
                    }
                }
            }
            return(dictionary);
        }
        private static List <string> ReadBundleIds(string googleServicesFile)
        {
            string str = (!GenerateXmlFromGoogleServicesJson.IsFileOfType(googleServicesFile, GenerateXmlFromGoogleServicesJson.ConfigFileType.Plist)) ? string.Empty : " --plist";
            SortedDictionary <string, string> sortedDictionary = new SortedDictionary <string, string>();

            CommandLine.Result result = GenerateXmlFromGoogleServicesJson.RunResourceGenerator("-i \"" + googleServicesFile + "\" -l" + str, googleServicesFile, false);
            if (result.exitCode == 0)
            {
                string[] array = result.stdout.Split(GenerateXmlFromGoogleServicesJson.newline_chars);
                for (int i = 0; i < array.Length; i++)
                {
                    string text = array[i];
                    if (!string.IsNullOrEmpty(text))
                    {
                        sortedDictionary[text] = text;
                    }
                }
            }
            return(new List <string>(sortedDictionary.Keys));
        }
示例#5
0
        /// <summary>
        /// Finds and executes the pod command on the command line, using the
        /// correct environment.
        /// </summary>
        /// <param name="podArgs">Arguments passed to the pod command.</param>
        /// <param name="pathToBuiltProject">The path to the unity project, given
        /// from the unity [PostProcessBuildAttribute()] function.</param>
        /// <returns>The CommandLine.Result from running the command.</returns>
        private static CommandLine.Result RunPodCommand(string podArgs,
                                                        string pathToBuiltProject)
        {
            string pod_command = FindPodTool();

            if (String.IsNullOrEmpty(pod_command))
            {
                CommandLine.Result r = new CommandLine.Result();
                r.exitCode = 1;
                r.stderr   = "'pod' command not found; unable to generate a usable" +
                             " Xcode project. " + COCOAPOD_INSTALL_INSTRUCTIONS;
                Log(r.stderr, level: LogLevel.Error);
                return(r);
            }

            return(CommandLine.Run(
                       pod_command, podArgs, pathToBuiltProject,
                       // cocoapods seems to require this, or it spits out a warning.
                       envVars: new Dictionary <string, string>()
            {
                { "LANG", (System.Environment.GetEnvironmentVariable("LANG") ??
                           "en_US.UTF-8").Split('.')[0] + ".UTF-8" }
            }));
        }
        private static CommandLine.Result RunResourceGenerator(string arguments, string inputPath, bool showCommandLine = true)
        {
            bool   flag = Application.platform == RuntimePlatform.WindowsEditor;
            string text = Path.Combine(Path.Combine(GenerateXmlFromGoogleServicesJson.GetProjectDir(), GenerateXmlFromGoogleServicesJson.executable_Location), (!flag) ? GenerateXmlFromGoogleServicesJson.executable_Name_Generic : GenerateXmlFromGoogleServicesJson.executable_Name_Windows);
            string text2;
            string text3;

            if (flag)
            {
                text2 = text;
                text3 = arguments;
            }
            else
            {
                text2 = "python";
                text3 = "\"" + text + "\" " + arguments;
            }
            string text4 = string.Concat(new string[]
            {
                "`",
                text2,
                " ",
                text3,
                "`."
            });

            CommandLine.Result result = new CommandLine.Result {
                exitCode = 1
            };
            try {
                result = CommandLine.Run(text2, text3, null, null, null);
            } catch (Win32Exception ex) {
                Debug.LogError(DocStrings.DocRef.GoogleServicesToolMissing.Format(new object[]
                {
                    text2,
                    GenerateXmlFromGoogleServicesJson.google_services_output_file,
                    inputPath,
                    ex.ToString()
                }));
                return(result);
            }
            if (result.exitCode == 0)
            {
                if (showCommandLine)
                {
                    Debug.Log(DocStrings.DocRef.GoogleServicesAndroidGenerateXml.Format(new object[]
                    {
                        GenerateXmlFromGoogleServicesJson.google_services_output_path,
                        inputPath,
                        text4
                    }));
                }
            }
            else
            {
                Debug.LogError(DocStrings.DocRef.GoogleServicesAndroidGenerationFailed.Format(new object[]
                {
                    GenerateXmlFromGoogleServicesJson.google_services_output_file,
                    inputPath,
                    text4,
                    result.stdout + "\n" + result.stderr + "\n"
                }));
            }
            return(result);
        }