private static PListDocument CompileInternal(String xibFile, String destination) { if (FileExtensions.UpToDate(xibFile, destination)) { return(null); } String arguments = String.Format(CultureInfo.InvariantCulture, "--errors --warnings --notices --compile \"{0}\" \"{1}\"", destination, xibFile); ProcessHelper helper = new ProcessHelper(Executable, arguments); String output = helper.ExecuteAndReturnOutput(); try { output = output.Trim(); PListDocument document = PListDocument.LoadFromXml(output); return(document); } catch (Exception) { Console.WriteLine("XibTool cannot parse output:"); Console.WriteLine("-----"); Console.WriteLine(output); Console.WriteLine("-----"); return(null); } }
public void TestPListReading010() { String content = ReadResource(Resources.Info_010); PListDocument document = PListDocument.LoadFromXml(content); CheckDocument(document); Assert.AreEqual(String.Empty, (String)(PListString)document.Root.Dict["CFBundleIconFile"]); Assert.AreEqual("net.monobjc.${PRODUCT_NAME:rfc1034identifier}", (String)(PListString)document.Root.Dict["CFBundleIdentifier"]); }
public void TestPListReading005() { String content = ReadResource(Resources.Info_005); PListDocument document = PListDocument.LoadFromXml(content); CheckDocument(document); Assert.IsTrue(document.Root.Dict.ContainsKey("CFBundleDocumentTypes")); PListItemBase item = document.Root.Dict["CFBundleDocumentTypes"]; Assert.IsTrue(item is PListArray); PListArray array = (PListArray)item; Assert.AreEqual(1, array.Count); }
/// <summary> /// Generates the Info.plist content. /// </summary> public void WriteTo(string path) { if (this.Content == null) { this.Logger.LogDebug("Using default template"); // Load template this.Content = Resources.InfoPlist; } // Parse the template content PListDocument document = PListDocument.LoadFromXml(this.Content); PList list = document.Root; PListDict dict = list.Dict; // Set default values this.Identifier = this.Identifier ?? "net.monobjc.app"; this.Version = this.Version ?? "1.0"; this.MainNibFile = (this.MainNibFile != null) ? Path.GetFileNameWithoutExtension(this.MainNibFile) : "MainMenu"; this.PrincipalClass = this.PrincipalClass ?? "NSApplication"; // Replace template values Replace(dict, "CFBundleDevelopmentRegion", this.DevelopmentRegion); Replace(dict, "CFBundleExecutable", this.ApplicationName); Replace(dict, "CFBundleIconFile", this.Icon); Replace(dict, "CFBundleIdentifier", this.Identifier); Replace(dict, "CFBundleName", this.ApplicationName); Replace(dict, "CFBundleShortVersionString", this.Version); switch (this.TargetOSVersion) { case MacOSVersion.MacOS105: Replace(dict, "LSMinimumSystemVersion", "10.5"); break; case MacOSVersion.MacOS106: Replace(dict, "LSMinimumSystemVersion", "10.6"); break; case MacOSVersion.MacOS107: Replace(dict, "LSMinimumSystemVersion", "10.7"); break; case MacOSVersion.MacOS108: Replace(dict, "LSMinimumSystemVersion", "10.8"); break; case MacOSVersion.MacOS109: Replace(dict, "LSMinimumSystemVersion", "10.9"); break; default: throw new ArgumentOutOfRangeException(); } Replace(dict, "NSMainNibFile", this.MainNibFile); Replace(dict, "NSPrincipalClass", this.PrincipalClass); // Resassign content this.Content = document.ToString(); File.WriteAllText(path, this.Content, Encoding.UTF8); }