protected int Compile(ITaskItem[] items, string output, ITaskItem manifest) { var environment = new Dictionary <string, string> (); var args = new CommandLineArgumentBuilder(); if (!string.IsNullOrEmpty(SdkBinPath)) { environment.Add("PATH", SdkBinPath); } if (!string.IsNullOrEmpty(SdkUsrPath)) { environment.Add("XCODE_DEVELOPER_USR_PATH", SdkUsrPath); } if (!string.IsNullOrEmpty(SdkDevPath)) { environment.Add("DEVELOPER_DIR", SdkDevPath); } // workaround for ibtool[d] bug / asserts if Intel version is loaded string tool; if (IsTranslated()) { // we force the Intel (translated) msbuild process to launch ibtool as "Apple" tool = "arch"; args.Add("-arch", "arm64e"); args.Add("/usr/bin/xcrun"); } else { tool = "/usr/bin/xcrun"; } args.Add(ToolName); args.Add("--errors", "--warnings", "--notices"); args.Add("--output-format", "xml1"); AppendCommandLineArguments(environment, args, items); if (Link) { args.Add("--link"); } else if (UseCompilationDirectory) { args.Add("--compilation-directory"); } else { args.Add("--compile"); } args.AddQuoted(Path.GetFullPath(output)); foreach (var item in items) { args.AddQuoted(item.GetMetadata("FullPath")); } var arguments = args.ToList(); var rv = ExecuteAsync(tool, arguments, sdkDevPath, environment: environment, mergeOutput: false).Result; var exitCode = rv.ExitCode; var messages = rv.StandardOutput.ToString(); File.WriteAllText(manifest.ItemSpec, messages); if (exitCode != 0) { // Note: ibtool or actool exited with an error. Dump everything we can to help the user // diagnose the issue and then delete the manifest log file so that rebuilding tries // again (in case of ibtool's infamous spurious errors). var errors = rv.StandardError.ToString(); if (errors.Length > 0) { Log.LogError(null, null, null, items[0].ItemSpec, 0, 0, 0, 0, "{0}", errors); } Log.LogError(MSBStrings.E0117, ToolName, exitCode); // Note: If the log file exists and is parseable, log those warnings/errors as well... if (File.Exists(manifest.ItemSpec)) { try { var plist = PDictionary.FromFile(manifest.ItemSpec); LogWarningsAndErrors(plist, items[0]); } catch (Exception ex) { Log.LogError(MSBStrings.E0094, ToolName, manifest.ItemSpec, ex.Message); } File.Delete(manifest.ItemSpec); } } return(exitCode); }