static PDictionary CreateIndex() { var plist = new PDictionary(); var profiles = new PArray(); foreach (var fileName in Directory.EnumerateFiles(MobileProvision.ProfileDirectory)) { if (!fileName.EndsWith(".mobileprovision", StringComparison.Ordinal) && !fileName.EndsWith(".provisionprofile", StringComparison.Ordinal)) { continue; } try { var profile = CreateIndexRecord(fileName); profiles.Add(profile); } catch (Exception ex) { LoggingService.LogWarning("Error reading provisioning profile '{0}': {1}", fileName, ex); } } plist.Add("Version", new PNumber(IndexVersion)); plist.Add("LastModified", new PDate(Directory.GetLastWriteTimeUtc(MobileProvision.ProfileDirectory))); plist.Add("ProvisioningProfiles", profiles); Save(plist); return(plist); }
public void TestDeleteNestedProperty() { var plist = new PDictionary(); var primary = new PDictionary(); var icons = new PDictionary(); var files = new PArray(); plist.Add("CFBundleIdentifier", "com.microsoft.delete-nested-property"); plist.Add("CFBundleIcons", icons); icons.Add("CFBundlePrimaryIcon", primary); primary.Add("CFBundleIconFiles", files); files.Add("icon0"); files.Add("icon1"); var expected = (PDictionary)plist.Clone(); files.Add("icon2"); TestExecuteTask(plist, PropertyListEditorAction.Delete, ":CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles:2", null, null, expected); var plist2 = (PDictionary)expected.Clone(); files.Remove(); var expected2 = (PDictionary)plist.Clone(); TestExecuteTask(plist2, PropertyListEditorAction.Delete, ":CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles", null, null, expected2); }
public void TestAddNestedProperty() { var plist = new PDictionary(); plist.Add("CFBundleIdentifier", "com.microsoft.add-nested-property"); var expected = (PDictionary)plist.Clone(); var primary = new PDictionary(); var icons = new PDictionary(); primary.Add("UIPrerenderedIcon", new PBoolean(true)); icons.Add("CFBundlePrimaryIcon", primary); expected.Add("CFBundleIcons", icons); TestExecuteTask(plist, PropertyListEditorAction.Add, ":CFBundleIcons:CFBundlePrimaryIcon:UIPrerenderedIcon", "bool", "true", expected); plist = (PDictionary)expected.Clone(); var files = new PArray(); primary.Add("CFBundleIconFiles", files); TestExecuteTask(plist, PropertyListEditorAction.Add, ":CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles", "array", null, expected); plist = (PDictionary)expected.Clone(); files.Add("icon0"); TestExecuteTask(plist, PropertyListEditorAction.Add, ":CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles:", "string", "icon0", expected); }
public void TestMergeRoot() { var expected = new PDictionary(); var primary = new PDictionary(); var icons = new PDictionary(); var files = new PArray(); expected.Add("CFBundleIdentifier", "com.microsoft.merge-root"); expected.Add("CFBundleIcons", icons); icons.Add("CFBundlePrimaryIcon", primary); primary.Add("UIPrerenderedIcon", new PBoolean(true)); primary.Add("CFBundleIconFiles", files); files.Add("icon0"); files.Add("icon1"); files.Add("icon2"); var plist = (PDictionary)expected.Clone(); plist.Remove("CFBundleIcons"); var merge = (PDictionary)expected.Clone(); merge.Remove("CFBundleIdentifier"); var tmp = Path.Combine(Cache.CreateTemporaryDirectory(), "tmpfile"); merge.Save(tmp); TestExecuteTask(plist, PropertyListEditorAction.Merge, null, null, tmp, expected); }
public void TestMergeArrays() { var plist = new PDictionary(); var array0 = new PArray(); array0.Add("item0"); array0.Add("item1"); array0.Add("item2"); array0.Add("item3"); plist.Add("CFBundleIdentifier", "com.microsoft.merge-arrays"); plist.Add("CFArrayItems", array0); var array1 = new PArray(); array1.Add("item2"); array1.Add("item3"); var expected = (PDictionary)plist.Clone(); array0.RemoveAt(3); array0.RemoveAt(2); var tmp = Path.Combine(Cache.CreateTemporaryDirectory(), "tmpfile"); array1.Save(tmp); TestExecuteTask(plist, PropertyListEditorAction.Merge, ":CFArrayItems", null, tmp, expected); }
public void TestMergeArrays() { var plist = new PDictionary(); var array0 = new PArray(); array0.Add("item0"); array0.Add("item1"); array0.Add("item2"); array0.Add("item3"); plist.Add("CFBundleIdentifier", "com.microsoft.merge-arrays"); plist.Add("CFArrayItems", array0); var array1 = new PArray(); array1.Add("item2"); array1.Add("item3"); var expected = (PDictionary)plist.Clone(); array0.RemoveAt(3); array0.RemoveAt(2); var tmp = Path.GetTempFileName(); array1.Save(tmp); try { TestExecuteTask(plist, PropertyListEditorAction.Merge, ":CFArrayItems", null, tmp, expected); } finally { File.Delete(tmp); } }
public override bool Execute() { PDictionary metadata; Log.LogTaskName ("CompileITunesMetadata"); Log.LogTaskProperty ("AppBundleDir", AppBundleDir); Log.LogTaskProperty ("ITunesMetadata", ITunesMetadata); Log.LogTaskProperty ("OutputPath", OutputPath); if (ITunesMetadata != null) { if (ITunesMetadata.Length > 1) { Log.LogError ("Cannot have more than 1 iTunesMetadata.plist."); return false; } var path = ITunesMetadata[0].GetMetadata ("FullPath"); try { metadata = PDictionary.FromFile (path); } catch (Exception ex) { Log.LogError (null, null, null, path, 0, 0, 0, 0, "Error loading '{0}': {1}", path, ex.Message); return false; } } else { var manifest = Path.Combine (AppBundleDir, "Info.plist"); PDictionary plist; try { plist = PDictionary.FromFile (manifest); } catch (Exception ex) { Log.LogError (null, null, null, manifest, 0, 0, 0, 0, "Error loading '{0}': {1}", manifest, ex.Message); return false; } var displayName = plist.GetCFBundleDisplayName (); var bundleVersion = plist.GetCFBundleVersion (); metadata = new PDictionary (); metadata.Add ("genre", new PString ("Application")); if (bundleVersion != null) metadata.Add ("bundleVersion", (PString) bundleVersion); if (displayName != null) metadata.Add ("itemName", (PString) displayName); metadata.Add ("kind", (PString) "software"); if (displayName != null) metadata.Add ("playlistName", (PString) displayName); metadata.Add ("softwareIconNeedsShine", (PBoolean) true); metadata.Add ("softwareVersionBundleId", (PString) plist.GetCFBundleIdentifier ()); } Directory.CreateDirectory (Path.GetDirectoryName (OutputPath.ItemSpec)); metadata.Save (OutputPath.ItemSpec, true); return !Log.HasLoggedErrors; }
static PDictionary CreateKnownVersions() { var knownVersions = new PDictionary(); knownVersions.Add("iOS", CreateKnownSdkVersionsArray(iOSSdkVersions)); knownVersions.Add("tvOS", CreateKnownSdkVersionsArray(tvOSSdkVersions)); knownVersions.Add("watchOS", CreateKnownSdkVersionsArray(watchOSSdkVersions)); return(knownVersions); }
static PDictionary CreateDefaultVersionsPlist() { var versions = new PDictionary(); versions.Add("KnownVersions", CreateKnownVersions()); versions.Add("RecommendedXcodeVersion", new PString("8.0")); versions.Add("MinExtensionVersion", CreateMinExtensionVersions()); return(versions); }
static PDictionary CreateIndexRecord(string fileName) { var provision = MobileProvision.LoadFromFile(fileName); var certificates = new PArray(); var record = new PDictionary(); PString identifier; record.Add("FileName", new PString(Path.GetFileName(fileName))); record.Add("LastModified", new PDate(File.GetLastWriteTimeUtc(fileName))); record.Add("Name", new PString(provision.Name)); record.Add("Uuid", new PString(provision.Uuid)); record.Add("Distribution", new PString(provision.DistributionType.ToString())); record.Add("CreationDate", new PDate(provision.CreationDate.ToUniversalTime())); record.Add("ExpirationDate", new PDate(provision.ExpirationDate.ToUniversalTime())); var platforms = new PArray(); if (provision.Platforms != null) { for (int i = 0; i < provision.Platforms.Length; i++) { platforms.Add(new PString(provision.Platforms[i].ToString())); } } record.Add("Platforms", platforms); if (provision.Entitlements.TryGetValue("com.apple.application-identifier", out identifier)) { record.Add("ApplicationIdentifier", new PString(identifier.Value)); } else if (provision.Entitlements.TryGetValue("application-identifier", out identifier)) { record.Add("ApplicationIdentifier", new PString(identifier.Value)); } else { record.Add("ApplicationIdentifier", new PString(string.Empty)); } foreach (var certificate in provision.DeveloperCertificates) { var info = new PDictionary(); info.Add("Name", new PString(Keychain.GetCertificateCommonName(certificate))); info.Add("Thumbprint", new PString(certificate.Thumbprint)); certificates.Add(info); } record.Add("DeveloperCertificates", certificates); return(record); }
void SaveMetaFile(int count, long size) { var meta = new PDictionary(); meta.Add("RecordCount", new PNumber(count)); meta.Add("StandardDirectoryPerms", new PNumber(16877)); meta.Add("StandardFilePerms", new PNumber(-32348)); meta.Add("TotalUncompressedBytes", new PNumber((int)size)); meta.Add("Version", new PNumber(2)); Directory.CreateDirectory(Path.Combine(Source.ItemSpec, "META-INF")); meta.Save(Path.Combine(Source.ItemSpec, "META-INF", "com.apple.ZipMetadata.plist"), true, true); }
static PDictionary CreateMinExtensionVersions() { var minExtensionVersions = new PDictionary(); var mac = new PDictionary(); mac.Add("com.apple.FinderSync", new PString("10.10")); mac.Add("com.apple.share-services", new PString("10.10")); mac.Add("com.apple.widget-extension", new PString("10.10")); mac.Add("com.apple.networkextension.packet-tunnel", new PString("10.11")); minExtensionVersions.Add("macOS", mac); return(minExtensionVersions); }
public void TestDeleteProperty() { var plist = new PDictionary(); plist.Add("CFBundleIdentifier", "com.microsoft.delete-property"); plist.Add("CFBundleShortVersionString", "1.0"); var expected = (PDictionary)plist.Clone(); plist.Add("CFBundleVersion", "1"); TestExecuteTask(plist, PropertyListEditorAction.Delete, ":CFBundleVersion", null, null, expected); TestExecuteTask(plist, PropertyListEditorAction.Delete, ":CFDoesNotExist", null, null, null); }
public void WalkScheme_PDictionaryKey_RequiredValues() { var scheme = Load(@" <PListScheme> <Key name = ""key1"" type = ""Dictionary""> <Value name = ""val1"" type = ""Number"" required = ""True"" /> <Value name = ""val2"" type = ""Array"" arrayType = ""Number"" required = ""True"" /> </Key> </PListScheme>"); var key = scheme.Keys [0]; var root = new PDictionary(); var tree = (PDictionary)key.Create(); root.Add("key1", tree); var result = PListScheme.Match(root, scheme); Assert.AreEqual(4, result.Count); Assert.AreSame(result [tree], key, "#2"); var val1 = tree ["val1"]; Assert.AreSame(result [val1], key.Values [0], "#3"); var val2 = tree ["val2"]; Assert.AreSame(result [val2], key.Values [1], "#4"); IsInstanceOf <PNumber> (((PArray)val2) [0], "#5"); }
public void AvailableValues_Number_InDictionary() { var scheme = Load(@" <PListScheme> <Key name = ""keyname"" type = ""Dictionary""> <Value name = ""num"" type = ""Number"" required = ""True""> <Value name = ""1"" /> <Value name = ""2"" /> <Value name = ""3"" /> </Value> </Key> </PListScheme>"); var value = new PDictionary(); var num = new PNumber(1); var root = new PDictionary(); root.Add("keyname", value); value.Add("num", num); var available = PListScheme.AvailableValues(num, PListScheme.Match(root, scheme)); Assert.AreEqual(3, available.Count, "#1"); }
void AddXamarinVersionNumber(PDictionary plist) { // Add our own version number if (IsWatchApp) { return; } string name; string value; // This key is our supported way of determining if an app // was built with Xamarin, so it needs to be present in all apps. if (TargetFramework.IsDotNet) { value = DotNetVersion; name = "com.microsoft." + Platform.AsString().ToLowerInvariant(); } else if (Platform != ApplePlatform.MacOSX) { var version = Sdks.XamIOS.ExtendedVersion; value = string.Format("{0} ({1}: {2})", version.Version, version.Branch, version.Hash); name = "com.xamarin.ios"; } else { return; } var dict = new PDictionary(); dict.Add("Version", new PString(value)); plist.Add(name, dict); }
PDictionary MergeEntitlementDictionary(PDictionary dict, MobileProvision profile) { var result = new PDictionary(); foreach (var item in dict) { PObject value = item.Value; if (value is PDictionary) { value = MergeEntitlementDictionary((PDictionary)value, profile); } else if (value is PString) { value = MergeEntitlementString((PString)value, profile, false); } else if (value is PArray) { value = MergeEntitlementArray((PArray)value, profile); } else { value = value.Clone(); } if (value != null) { result.Add(item.Key, value); } } return(result); }
public void WalkScheme_Dictionary_NotPartOfScheme() { var scheme = Load(@" <PListScheme> <Key name = ""key1"" type = ""Array"" arrayType = ""Dictionary"" /> </PListScheme>"); var dict = new PDictionary(); dict.Add("foo", new PNumber(1)); var tree = new PArray(); tree.Add(dict); tree.Add(new PNumber(1)); var root = new PDictionary(); root.Add("foo", tree); var result = PListScheme.Match(root, scheme); var keys = result.Keys.ToArray(); for (int i = 0; i < keys.Length; i++) { Assert.IsNull(result [keys [i]], "#1." + i); } }
static PDictionary CreateKnownVersions() { var knownVersions = new PDictionary(); knownVersions.Add("macOS", CreateKnownSdkVersionsArray(MacOSXSdkVersions)); return(knownVersions); }
public void TestClear() { var plist = new PDictionary(); plist.Add("CFBundleIdentifier", "com.microsoft.clear"); plist.Add("CFBundleShortVersionString", "1.0"); plist.Add("CFBundleVersion", "1"); TestExecuteTask(plist, PropertyListEditorAction.Clear, null, null, null, new PDictionary()); TestExecuteTask(plist, PropertyListEditorAction.Clear, null, "dict", null, new PDictionary()); TestExecuteTask(plist, PropertyListEditorAction.Clear, null, "array", null, new PArray()); TestExecuteTask(plist, PropertyListEditorAction.Clear, null, "bool", null, new PBoolean(false)); TestExecuteTask(plist, PropertyListEditorAction.Clear, null, "integer", null, new PNumber(0)); TestExecuteTask(plist, PropertyListEditorAction.Clear, null, "real", null, new PReal(0)); TestExecuteTask(plist, PropertyListEditorAction.Clear, null, "string", null, new PString(string.Empty)); TestExecuteTask(plist, PropertyListEditorAction.Clear, null, "data", null, new PData(new byte[0])); }
public PObject Create () { if (Type == PDictionary.Type) { var dictionary = new PDictionary (); foreach (var v in Values) { if (v.Required) dictionary.Add (v.Identifier, v.Create ()); } // If nothing was required, create an initial one anyway if (dictionary.Count == 0) { var first = Values.FirstOrDefault (); if (first == null) { dictionary.Add ("newNode", PObject.Create (PString.Type)); } else { dictionary.Add (first.Identifier ?? "newNode", first.Create ()); } } return dictionary; } else if (Type == PArray.Type) { var array = new PArray (); foreach (var v in Values) { if (v.Required) array.Add (v.Create ()); } // If nothing was required, create an initial one anyway if (array.Count == 0) { var first = Values.FirstOrDefault (); if (first == null) { array.Add (PObject.Create (ArrayType)); } else { array.Add (first.Create ()); } } return array; } else if (Values.Any ()){ return Values.First ().Create (); } else { var obj = PObject.Create (Type); if (!string.IsNullOrEmpty (Identifier) && !(this is Key)) obj.SetValue (Identifier); return obj; } }
public void TestSetNestedProperty() { var plist = new PDictionary(); plist.Add("CFBundleIdentifier", "com.microsoft.set-nested-property"); // Note: Set will fail if the property doesn't already exist TestExecuteTask(plist, PropertyListEditorAction.Set, ":CFBundleIcons:CFBundlePrimaryIcon:UIPrerenderedIcon", "bool", "true", null); }
public void AvailableKeys_Array_NotInScheme() { var root = new PDictionary(); root.Add("foo", new PArray()); var available = PListScheme.AvailableKeys(root["foo"], PListScheme.Match(root, PListScheme.Empty)); Assert.IsNull(available, "#1"); }
public void AvailableValues_String_NotInScheme() { var root = new PDictionary(); root.Add("foo", new PString("bar")); var available = PListScheme.AvailableValues(root["foo"], PListScheme.Match(root, PListScheme.Empty)); Assert.IsNull(available, "#1"); }
public void TestAddExistingProperty() { const string property = "CFBundleIdentifier"; const string value = "com.microsoft.add-property"; var plist = new PDictionary(); plist.Add(property, value); // Note: Add will fail if the property already exists TestExecuteTask(plist, PropertyListEditorAction.Add, ":" + property, "string", value, null); }
public void AvailableValues_Boolean_NotInScheme() { var value = new PBoolean(true); var root = new PDictionary(); root.Add("foo", value); var available = PListScheme.AvailableValues(value, PListScheme.Match(root, PListScheme.Empty)); Assert.AreEqual(2, available.Count, "#1"); }
public void TestAddNewProperty() { const string property = "CFBundleIdentifier"; const string value = "com.microsoft.add-property"; var expected = new PDictionary(); var plist = new PDictionary(); expected.Add(property, value); TestExecuteTask(plist, PropertyListEditorAction.Add, ":" + property, "string", value, expected); }
public void TestAddArrayValue() { var plist = new PDictionary(); var primary = new PDictionary(); var icons = new PDictionary(); var files = new PArray(); plist.Add("CFBundleIdentifier", "com.microsoft.add-array-value"); plist.Add("CFBundleIcons", icons); icons.Add("CFBundlePrimaryIcon", primary); primary.Add("CFBundleIconFiles", files); files.Add("icon0"); files.Add("icon1"); files.Add("icon2"); var expected = (PDictionary)plist.Clone(); files.RemoveAt(0); TestExecuteTask(plist, PropertyListEditorAction.Add, ":CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles:0", "string", "icon0", expected); }
public void TestSetExistingProperty() { const string property = "CFBundleIdentifier"; const string value = "com.microsoft.set-property"; var expected = new PDictionary(); var plist = new PDictionary(); plist.Add(property, "com.microsoft.initial-value"); expected.Add(property, value); TestExecuteTask(plist, PropertyListEditorAction.Set, ":" + property, "string", value, expected); }
static PObject Convert(XElement f) { var type = f.Attribute("type").Value; switch (type) { case "string": return(new PString(f.Value)); case "boolean": return(new PBoolean(string.Equals("true", f.Value, StringComparison.OrdinalIgnoreCase))); case "array": return(new PArray(new List <PObject> (f.Elements().Select(Convert)))); case "object": var val = new PDictionary(); foreach (var subElement in f.Elements()) { var name = subElement.Name.LocalName; if (string.IsNullOrEmpty(name)) { continue; } if (name == "item") { name = subElement.Attribute("item").Value; } if (!val.ContainsKey(name)) { var converted = Convert(subElement); if (converted != null) { val.Add(name, converted); } } else { LoggingService.LogWarning("Warning while converting json highlighting to textmate 'key' " + name + " is duplicated in : " + f); } } return(val); case "number": return(new PNumber(int.Parse(f.Value))); default: LoggingService.LogWarning("Can't convert element of type: " + type + "/" + f); break; } return(null); }
public void TestSetArrayValue() { var plist = new PDictionary(); var primary = new PDictionary(); var icons = new PDictionary(); var files = new PArray(); plist.Add("CFBundleIdentifier", "com.microsoft.set-array-value"); plist.Add("CFBundleIcons", icons); icons.Add("CFBundlePrimaryIcon", primary); primary.Add("CFBundleIconFiles", files); files.Add("icon0"); files.Add("icon1"); files.Add("icon2"); var expected = (PDictionary)plist.Clone(); files[0] = new PString("icon"); TestExecuteTask(plist, PropertyListEditorAction.Set, ":CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles:0", "string", "icon0", expected); // Note: this will fail due to the index being out of range TestExecuteTask(plist, PropertyListEditorAction.Set, ":CFBundleIcons:CFBundlePrimaryIcon:CFBundleIconFiles:3", "string", "icon3", null); }
static PDictionary CreateMinExtensionVersions() { var minExtensionVersions = new PDictionary(); var watchos = new PDictionary(); var tvos = new PDictionary(); var ios = new PDictionary(); ios.Add("com.apple.ui-services", new PString("8.0")); ios.Add("com.apple.services", new PString("8.0")); ios.Add("com.apple.keyboard-service", new PString("8.0")); ios.Add("com.apple.fileprovider-ui", new PString("8.0")); ios.Add("com.apple.fileprovider-nonui", new PString("8.0")); ios.Add("com.apple.photo-editing", new PString("8.0")); ios.Add("com.apple.share-services", new PString("8.0")); ios.Add("com.apple.widget-extension", new PString("8.0")); ios.Add("com.apple.watchkit", new PString("8.0")); ios.Add("com.apple.AudioUnit-UI", new PString("8.0")); ios.Add("com.apple.Safari.content-blocker", new PString("9.0")); ios.Add("com.apple.Safari.sharedlinks-service", new PString("9.0")); ios.Add("com.apple.spotlight.index", new PString("9.0")); ios.Add("com.apple.callkit.call-directory", new PString("10.0")); ios.Add("com.apple.intents-service", new PString("10.0")); ios.Add("com.apple.intents-ui-service", new PString("10.0")); ios.Add("com.apple.message-payload-provider", new PString("10.0")); ios.Add("com.apple.usernotifications.content-extension", new PString("10.0")); ios.Add("com.apple.usernotifications.service", new PString("10.0")); tvos.Add("com.apple.broadcast-services", new PString("10.0")); tvos.Add("com.apple.tv-services", new PString("9.0")); minExtensionVersions.Add("iOS", ios); minExtensionVersions.Add("tvOS", tvos); minExtensionVersions.Add("watchOS", watchos); return(minExtensionVersions); }
protected virtual PDictionary GetCompiledEntitlements(MobileProvision profile, PDictionary template) { var entitlements = new PDictionary (); if (profile != null && MergeProfileEntitlements) { // start off with the settings from the provisioning profile foreach (var item in profile.Entitlements) { if (!AllowedProvisioningKeys.Contains (item.Key)) continue; var value = item.Value; if (item.Key == "com.apple.developer.icloud-container-environment") value = new PString ("Development"); else if (value is PDictionary) value = MergeEntitlementDictionary ((PDictionary) value, profile); else if (value is PString) value = MergeEntitlementString ((PString) value, profile); else if (value is PArray) value = MergeEntitlementArray ((PArray) value, profile); else value = value.Clone (); if (value != null) entitlements.Add (item.Key, value); } } // merge in the user's values foreach (var item in template) { var value = item.Value; if (item.Key == "com.apple.developer.ubiquity-container-identifiers" || item.Key == "com.apple.developer.icloud-container-identifiers" || item.Key == "com.apple.developer.icloud-container-environment" || item.Key == "com.apple.developer.icloud-services") { if (profile == null) Log.LogWarning (null, null, null, Entitlements, 0, 0, 0, 0, "iCloud entitlements such as '" + item.Key + "' require a Provisioning Profile."); else if (!profile.Entitlements.ContainsKey (item.Key)) Log.LogWarning (null, null, null, Entitlements, 0, 0, 0, 0, "The iCloud entitlement '" + item.Key + "' is not supported by the Provisioning Profile."); } else if (item.Key == ApplicationIdentifierKey) { var str = value as PString; // Ignore ONLY if it is empty, otherwise take the user's value if (str == null || string.IsNullOrEmpty (str.Value)) continue; } if (value is PDictionary) value = MergeEntitlementDictionary ((PDictionary) value, profile); else if (value is PString) value = MergeEntitlementString ((PString) value, profile); else if (value is PArray) value = MergeEntitlementArray ((PArray) value, profile); else value = value.Clone (); if (value != null) entitlements[item.Key] = value; } return entitlements; }
public override bool Execute() { Log.LogTaskName ("ComputeBundleResourceOutputPaths"); Log.LogTaskProperty ("AppBundleDir", AppBundleDir); Log.LogTaskProperty ("BundleIdentifier", BundleIdentifier); Log.LogTaskProperty ("BundleResources", BundleResources); Log.LogTaskProperty ("IntermediateOutputPath", IntermediateOutputPath); Log.LogTaskProperty ("OutputPath", OutputPath); var intermediate = Path.Combine (IntermediateOutputPath, "assetpacks"); var bundleResources = new List<ITaskItem> (); var packs = new HashSet<string> (); if (BundleResources != null) { foreach (var item in BundleResources) { var logicalName = item.GetMetadata ("LogicalName"); var outputPath = item.GetMetadata ("OutputPath"); var tags = AssetPackUtils.GetResourceTags (item); string hash; if (tags != null) { var assetpack = AssetPackUtils.GetAssetPackDirectory (OutputPath, BundleIdentifier, tags, out hash); if (packs.Add (hash)) { var path = Path.Combine (intermediate, hash + ".plist"); if (!File.Exists (path)) { var plist = new PDictionary (); var array = new PArray (); for (int i = 0; i < tags.Count; i++) array.Add (new PString (tags[i])); plist.SetCFBundleIdentifier (BundleIdentifier + ".asset-pack-" + hash); plist.Add ("Tags", array); Directory.CreateDirectory (intermediate); plist.Save (path, true, true); } var manifest = new TaskItem (path); manifest.SetMetadata ("OutputPath", Path.Combine (assetpack, "Info.plist")); bundleResources.Add (manifest); } outputPath = Path.Combine (assetpack, logicalName); } else if (string.IsNullOrEmpty (outputPath)) { outputPath = Path.Combine (AppBundleDir.ItemSpec, logicalName); } var bundleResource = new TaskItem (item); bundleResource.SetMetadata ("OutputPath", outputPath); bundleResources.Add (bundleResource); } } BundleResourcesWithOutputPaths = bundleResources.ToArray (); return !Log.HasLoggedErrors; }
public override bool Execute() { var intermediate = Path.Combine (IntermediateOutputPath, ToolName); var intermediateBundleDir = Path.Combine (intermediate, "bundle"); var manifest = new TaskItem (Path.Combine (intermediate, "asset-manifest.plist")); var bundleResources = new List<ITaskItem> (); var outputManifests = new List<ITaskItem> (); var catalogs = new List<ITaskItem> (); var unique = new HashSet<string> (); string bundleIdentifier = null; var knownSpecs = new HashSet<string> (); var specs = new PArray (); int rc; Log.LogTaskName ("ACTool"); Log.LogTaskProperty ("AppManifest", AppManifest); Log.LogTaskProperty ("DeviceModel", DeviceModel); Log.LogTaskProperty ("DeviceOSVersion", DeviceOSVersion); Log.LogTaskProperty ("ImageAssets", ImageAssets); Log.LogTaskProperty ("IntermediateOutputPath", IntermediateOutputPath); Log.LogTaskProperty ("IsWatchApp", IsWatchApp); Log.LogTaskProperty ("OptimizePNGs", OptimizePNGs); Log.LogTaskProperty ("OutputPath", OutputPath); Log.LogTaskProperty ("ProjectDir", ProjectDir); Log.LogTaskProperty ("ResourcePrefix", ResourcePrefix); Log.LogTaskProperty ("SdkBinPath", SdkBinPath); Log.LogTaskProperty ("SdkPlatform", SdkPlatform); Log.LogTaskProperty ("SdkVersion", SdkVersion); switch (SdkPlatform) { case "iPhoneSimulator": case "iPhoneOS": case "MacOSX": case "WatchSimulator": case "WatchOS": case "AppleTVSimulator": case "AppleTVOS": break; default: Log.LogError ("Unrecognized platform: {0}", SdkPlatform); return false; } if (AppManifest != null) { try { plist = PDictionary.FromFile (AppManifest.ItemSpec); } catch (Exception ex) { Log.LogError (null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, "{0}", ex.Message); return false; } bundleIdentifier = plist.GetCFBundleIdentifier (); } foreach (var asset in ImageAssets) { var vpath = BundleResource.GetVirtualProjectPath (ProjectDir, asset); if (Path.GetFileName (vpath) != "Contents.json") continue; // get the parent (which will typically be .appiconset, .launchimage, .imageset, .iconset, etc) var catalog = Path.GetDirectoryName (vpath); // keep walking up the directory structure until we get to the .xcassets directory while (!string.IsNullOrEmpty (catalog) && Path.GetExtension (catalog) != ".xcassets") catalog = Path.GetDirectoryName (catalog); if (string.IsNullOrEmpty (catalog)) { Log.LogWarning (null, null, null, asset.ItemSpec, 0, 0, 0, 0, "Asset not part of an asset catalog: {0}", asset.ItemSpec); continue; } if (unique.Add (catalog)) catalogs.Add (new TaskItem (catalog)); if (AppleSdkSettings.XcodeVersion.Major >= 7 && !string.IsNullOrEmpty (bundleIdentifier) && SdkPlatform != "WatchSimulator") { var text = File.ReadAllText (asset.ItemSpec); if (string.IsNullOrEmpty (text)) continue; var json = JsonConvert.DeserializeObject (text) as JObject; if (json == null) continue; var properties = json.Property ("properties"); if (properties == null) continue; var resourceTags = properties.Value.ToObject<JObject> ().Property ("on-demand-resource-tags"); if (resourceTags == null || resourceTags.Value.Type != JTokenType.Array) continue; var tagArray = resourceTags.Value.ToObject<JArray> (); var tags = new HashSet<string> (); string hash; foreach (var tag in tagArray.Select (token => token.ToObject<string> ())) tags.Add (tag); var tagList = tags.ToList (); tagList.Sort (); var path = AssetPackUtils.GetAssetPackDirectory (intermediate, bundleIdentifier, tagList, out hash); if (knownSpecs.Add (hash)) { var assetpack = new PDictionary (); var ptags = new PArray (); Directory.CreateDirectory (path); for (int i = 0; i < tags.Count; i++) ptags.Add (new PString (tagList[i])); assetpack.Add ("bundle-id", new PString (string.Format ("{0}.asset-pack-{1}", bundleIdentifier, hash))); assetpack.Add ("bundle-path", new PString (Path.GetFullPath (path))); assetpack.Add ("tags", ptags); specs.Add (assetpack); } } } if (catalogs.Count == 0) { // There are no (supported?) asset catalogs return true; } partialAppManifest = new TaskItem (Path.Combine (intermediate, "partial-info.plist")); if (specs.Count > 0) { outputSpecs = Path.Combine (intermediate, "output-specifications.plist"); specs.Save (outputSpecs, true); } var output = new TaskItem (intermediateBundleDir); Directory.CreateDirectory (intermediateBundleDir); // Note: Compile() will set the PartialAppManifest property if it is used... if ((rc = Compile (catalogs.ToArray (), output, manifest)) != 0) { if (File.Exists (manifest.ItemSpec)) { try { var log = PDictionary.FromFile (manifest.ItemSpec); LogWarningsAndErrors (log, catalogs[0]); } catch (FormatException) { Log.LogError ("actool exited with code {0}", rc); } File.Delete (manifest.ItemSpec); } return false; } if (PartialAppManifest != null && !File.Exists (PartialAppManifest.GetMetadata ("FullPath"))) Log.LogError ("Partial Info.plist file was not generated: {0}", PartialAppManifest.GetMetadata ("FullPath")); try { var manifestOutput = PDictionary.FromFile (manifest.ItemSpec); LogWarningsAndErrors (manifestOutput, catalogs[0]); bundleResources.AddRange (GetCompiledBundleResources (manifestOutput, intermediateBundleDir)); outputManifests.Add (manifest); } catch (Exception ex) { Log.LogError ("Failed to load output manifest for {0} for the file {2}: {1}", ToolName, ex.Message, manifest.ItemSpec); } foreach (var assetpack in specs.OfType<PDictionary> ()) { var path = Path.Combine (assetpack.GetString ("bundle-path").Value, "Info.plist"); var bundlePath = PathUtils.AbsoluteToRelative (intermediate, path); var outputPath = Path.Combine (OutputPath, bundlePath); var rpath = Path.Combine (intermediate, bundlePath); var dict = new PDictionary (); dict.SetCFBundleIdentifier (assetpack.GetString ("bundle-id").Value); dict.Add ("Tags", assetpack.GetArray ("tags").Clone ()); dict.Save (path, true, true); var item = new TaskItem (rpath); item.SetMetadata ("LogicalName", bundlePath); item.SetMetadata ("OutputPath", outputPath); item.SetMetadata ("Optimize", "false"); bundleResources.Add (item); } BundleResources = bundleResources.ToArray (); OutputManifests = outputManifests.ToArray (); return !Log.HasLoggedErrors; }
public override bool Execute() { var manifestPath = Path.Combine (AppBundleDir.ItemSpec, "AssetPackManifestTemplate.plist"); var onDemandResourcesPath = Path.Combine (AppBundleDir.ItemSpec, "OnDemandResources.plist"); var onDemandResourcesDir = Path.Combine (OutputPath, "OnDemandResources"); var onDemandResourcesStamp = File.GetLastWriteTime (onDemandResourcesPath); var initialInstallTags = new HashSet<string> (AssetPackUtils.ParseTags (InitialInstallTags)); var prefetchOrder = AssetPackUtils.ParseTags (PrefetchOrder); var manifestStamp = File.GetLastWriteTime (manifestPath); var onDemandResources = new PDictionary (); var requestTags = new PDictionary (); bool updateOnDemandResources = false; var assetPacks = new PDictionary (); var manifest = new PDictionary (); var resources = new PArray (); bool updateManifest = false; Log.LogTaskName ("CreateAssetPackManifest"); Log.LogTaskProperty ("AppBundleDir", AppBundleDir); Log.LogTaskProperty ("InitialInstallTags", InitialInstallTags); Log.LogTaskProperty ("OutputPath", OutputPath); Log.LogTaskProperty ("PrefetchOrder", PrefetchOrder); if (!Directory.Exists (onDemandResourcesDir)) return !Log.HasLoggedErrors; onDemandResources.Add ("NSBundleResourceRequestAssetPacks", assetPacks); onDemandResources.Add ("NSBundleResourceRequestTags", requestTags); manifest.Add ("resources", resources); foreach (var dir in Directory.EnumerateDirectories (onDemandResourcesDir)) { var path = Path.Combine (dir, "Info.plist"); PDictionary info; if (!File.Exists (path)) continue; var mtime = File.GetLastWriteTime (path); updateOnDemandResources = updateOnDemandResources || mtime > onDemandResourcesStamp; updateManifest = updateManifest || mtime > manifestStamp; try { info = PDictionary.FromFile (path); } catch { continue; } var bundleIdentifier = info.GetCFBundleIdentifier (); var primaryContentHash = new PDictionary (); var resource = new PDictionary (); var items = new PArray (); long size = 0; // update OnDemandResources.plist:NSBundleResourceRequestAssetPacks foreach (var file in Directory.EnumerateFiles (dir)) { var name = Path.GetFileName (file); if (name != "Info.plist") items.Add (new PString (name)); size += new FileInfo (file).Length; } assetPacks.Add (bundleIdentifier, items); // update OnDemandResources.plist:NSBundleResourceRequestTags var tags = info.GetArray ("Tags").OfType<PString> ().Select (x => x.Value); var priority = double.NaN; foreach (var tag in tags) { PDictionary dict; PArray packs; if (initialInstallTags.Contains (tag)) { priority = 1.0f; } else { for (int i = 0; i < prefetchOrder.Length; i++) { if (tag == prefetchOrder[i]) { var value = GetDownloadPriority (i, prefetchOrder.Length); priority = double.IsNaN (priority) ? value : Math.Max (priority, value); break; } } } if (!requestTags.TryGetValue (tag, out dict)) { dict = new PDictionary (); dict.Add ("NSAssetPacks", new PArray ()); requestTags.Add (tag, dict); } packs = dict.GetArray ("NSAssetPacks"); packs.Add (new PString (bundleIdentifier)); } // update AssetPackManifestTemplate.plist resource.Add ("URL", new PString ("http://127.0.0.1" + Path.GetFullPath (dir))); resource.Add ("bundleKey", new PString (bundleIdentifier)); if (!double.IsNaN (priority)) resource.Add ("downloadPriority", new PReal (priority)); resource.Add ("isStreamable", new PBoolean (true)); primaryContentHash.Add ("hash", mtime.ToString ("yyyy-MM-dd HH:mm:ss.000")); primaryContentHash.Add ("strategy", "modtime"); resource.Add ("primaryContentHash", primaryContentHash); resource.Add ("uncompressedSize", new PNumber ((int) ((size + 8191) & ~8191))); resources.Add (resource); } if (updateOnDemandResources) { try { onDemandResources.Save (onDemandResourcesPath, true, true); } catch (Exception ex) { Log.LogError ("Error saving `{0}': {1}", onDemandResourcesPath, ex.Message); } } if (updateManifest) { try { manifest.Save (manifestPath, true, true); } catch (Exception ex) { Log.LogError ("Error saving `{0}': {1}", manifestPath, ex.Message); } } return !Log.HasLoggedErrors; }
//------------------------------------------------------------------------------------- private void AddSortColumn(DataGridViewColumn col, ListSortDirection direction = ListSortDirection.Ascending) { if(this.DataSource == null)// || props.ContainsKey(col.DataPropertyName) == false) return; try { if(AllowMultipleSort == false) { if((this.DataSource as IBindingList) == null) throw new Exception(String.Format("»сточник данных [{0}] не поддерживает интерфейс IBindingList!", DataSource.GetType().FullName)); IBindingList ibl = (IBindingList)this.DataSource; if(ibl.SupportsSorting == false) return; PropertyDescriptor pd = null; if(props.ContainsKey(col.DataPropertyName)) pd = props[col.DataPropertyName]; else pd = new UnboundColumnPropertyDescriptor(col); ListSortDirection lsd = direction; if(ibl.SortProperty != null && Object.Equals(ibl.SortProperty, pd)) if(ibl.SortDirection == ListSortDirection.Ascending) lsd = ListSortDirection.Descending; else lsd = ListSortDirection.Ascending; ibl.ApplySort(pd, lsd); foreach(DataGridViewColumn c in Columns) c.HeaderCell.SortGlyphDirection = SortOrder.None; if(lsd == ListSortDirection.Ascending) col.HeaderCell.SortGlyphDirection = SortOrder.Ascending; else col.HeaderCell.SortGlyphDirection = SortOrder.Descending; SortedColumn = col; SortOrder = lsd == ListSortDirection.Ascending ? SortOrder.Ascending : SortOrder.Descending; } else { if((this.DataSource as IBindingListView) == null) throw new Exception(String.Format("»сточник данных [{0}] не поддерживает интерфейс IBindingListView!", DataSource.GetType().FullName)); if((this.DataSource as ITypedList) == null) throw new Exception(String.Format("»сточник данных [{0}] не поддерживает интерфейс ITypedList !", DataSource.GetType().FullName)); if(((IBindingListView)DataSource).SupportsAdvancedSorting == false) throw new Exception(String.Format("»сточник данных [{0}] не поддерживает сортировку по нескольким столбцам!", DataSource.GetType().FullName)); PDictionary<string, ListSortDescription> sl = new PDictionary<string, ListSortDescription>(); if(((IBindingListView)DataSource).SortDescriptions != null) foreach(ListSortDescription lsd in ((IBindingListView)DataSource).SortDescriptions) sl.Add(lsd.PropertyDescriptor.Name, lsd); List<string> toDel = new List<string>(); if(ModifierKeys != Keys.Control) foreach(string s in sl.Keys) if(s != (String.IsNullOrEmpty(col.DataPropertyName) ? col.Name : col.DataPropertyName)) toDel.Add(s); foreach(string s in toDel) sl.Remove(s); PropertyDescriptor pd = null; if(props.ContainsKey(col.DataPropertyName)) pd = props[col.DataPropertyName]; else pd = new UnboundColumnPropertyDescriptor(col); if(sl.ContainsKey(pd.Name)) { if(sl[pd.Name].SortDirection == ListSortDirection.Ascending) sl[pd.Name].SortDirection = ListSortDirection.Descending; else sl[pd.Name].SortDirection = ListSortDirection.Ascending; } else sl.Add(pd.Name, new ListSortDescription(pd, direction)); SortedColumn = col; SortOrder = sl[pd.Name].SortDirection == ListSortDirection.Ascending ? SortOrder.Ascending : SortOrder.Descending; ListSortDescription[] sd = new ListSortDescription[sl.Count]; int c = 0; foreach(var i in sl.Values) sd[c++] = i; ((IBindingListView)DataSource).ApplySort(new ListSortDescriptionCollection(sd)); DrawMultiSort(); } this.Refresh(); } catch(Exception Err) { ErrorBox.Show(Err); } }
//------------------------------------------------------------------------------------- private void DrawMultiSort() { try { if(this.DataSource == null) return; if((this.DataSource as IBindingListView) == null) return; if(((IBindingListView)DataSource).SupportsAdvancedSorting == false) return; PDictionary<string, ListSortDescription> sl = new PDictionary<string, ListSortDescription>(); if(((IBindingListView)DataSource).SortDescriptions != null) foreach(ListSortDescription lsd in ((IBindingListView)DataSource).SortDescriptions) sl.Add(lsd.PropertyDescriptor.Name, lsd); foreach(DataGridViewColumn col in this.Columns) if(sl.ContainsKey(col.Name)) { if(sl[col.Name].SortDirection == ListSortDirection.Ascending) col.HeaderCell.SortGlyphDirection = SortOrder.Ascending; else col.HeaderCell.SortGlyphDirection = SortOrder.Descending; } else if(sl.ContainsKey(col.DataPropertyName)) { if(sl[col.DataPropertyName].SortDirection == ListSortDirection.Ascending) col.HeaderCell.SortGlyphDirection = SortOrder.Ascending; else col.HeaderCell.SortGlyphDirection = SortOrder.Descending; } else if(col.HeaderCell.SortGlyphDirection != SortOrder.None) col.HeaderCell.SortGlyphDirection = SortOrder.None; } catch { } }
void AddNewDictionaryElement (PDictionary dict) { var values = PListScheme.AvailableKeys (dict, CurrentTree); if (values == null) { string name = "newProperty"; while (dict.ContainsKey (name)) name += "_"; dict.Add (name, PObject.Create (DefaultNewObjectType)); } else if (values.Any ()) { var value = values.FirstOrDefault (); dict.Add (value.Identifier, value.Create ()); } }
static PDictionary GetArchivedExpandedEntitlements(PDictionary template, PDictionary compiled) { var allowed = new HashSet<string> (); // the template (user-supplied Entitlements.plist file) is used to create a whitelist of keys allowed.Add ("com.apple.developer.icloud-container-environment"); foreach (var item in template) allowed.Add (item.Key); // now we duplicate the allowed keys from the compiled xcent file var archived = new PDictionary (); foreach (var item in compiled) { if (allowed.Contains (item.Key)) archived.Add (item.Key, item.Value.Clone ()); } return archived; }
public override bool Execute() { Log.LogTaskName ("Archive"); Log.LogTaskProperty ("AppBundleDir", AppBundleDir); Log.LogTaskProperty ("AppExtensionReferences", AppExtensionReferences); Log.LogTaskProperty ("ITunesSourceFiles", ITunesSourceFiles); Log.LogTaskProperty ("OutputPath", OutputPath); Log.LogTaskProperty ("ProjectName", ProjectName); Log.LogTaskProperty ("SigningKey", SigningKey); Log.LogTaskProperty ("SolutionPath", SolutionPath); var archiveDir = CreateArchiveDirectory (); try { var plist = PDictionary.FromFile (Path.Combine (AppBundleDir.ItemSpec, "Info.plist")); var productsDir = Path.Combine (archiveDir, "Products"); // Archive the OnDemandResources... var resourcesDestDir = Path.Combine (productsDir, "OnDemandResources"); var resourcesSrcDir = Path.Combine (OutputPath, "OnDemandResources"); if (Directory.Exists (resourcesSrcDir)) Ditto (resourcesSrcDir, resourcesDestDir); // Archive the Applications... var appDestDir = Path.Combine (productsDir, "Applications", Path.GetFileName (AppBundleDir.ItemSpec)); Ditto (AppBundleDir.ItemSpec, appDestDir); // Archive the dSYMs... var dsymsDestDir = Path.Combine (archiveDir, "dSYMs", Path.GetFileName (DSYMDir)); Ditto (DSYMDir, dsymsDestDir); // Archive the Bitcode symbol maps var bcSymbolMaps = Directory.GetFiles (Path.GetDirectoryName (DSYMDir), "*.bcsymbolmap"); if (bcSymbolMaps.Length > 0) { var bcSymbolMapsDir = Path.Combine (archiveDir, "BCSymbolMaps"); Directory.CreateDirectory (bcSymbolMapsDir); for (int i = 0; i < bcSymbolMaps.Length; i++) File.Copy (bcSymbolMaps[i], Path.Combine (bcSymbolMapsDir, Path.GetFileName (bcSymbolMaps[i]))); } if (AppExtensionReferences != null) { // Archive the dSYMs for each of the referenced App Extensions as well... for (int i = 0; i < AppExtensionReferences.Length; i++) ArchiveAppExtension (AppExtensionReferences[i], archiveDir); } if (ITunesSourceFiles != null) { // Archive the iTunesMetadata.plist and iTunesArtwork files... var iTunesMetadataDir = Path.Combine (archiveDir, "iTunesMetadata", Path.GetFileName (AppBundleDir.ItemSpec)); for (int i = 0; i < ITunesSourceFiles.Length; i++) { var archivedMetaFile = Path.Combine (iTunesMetadataDir, Path.GetFileName (ITunesSourceFiles[i].ItemSpec)); Directory.CreateDirectory (iTunesMetadataDir); File.Copy (ITunesSourceFiles[i].ItemSpec, archivedMetaFile, true); } } // Generate an archive Info.plist var arInfo = new PDictionary (); // FIXME: figure out this value //arInfo.Add ("AppStoreFileSize", new PNumber (65535)); var props = new PDictionary (); props.Add ("ApplicationPath", new PString (string.Format ("Applications/{0}", Path.GetFileName (AppBundleDir.ItemSpec)))); props.Add ("CFBundleIdentifier", new PString (plist.GetCFBundleIdentifier ())); if (plist.GetCFBundleShortVersionString () != null) props.Add ("CFBundleShortVersionString", new PString (plist.GetCFBundleShortVersionString ())); else if (plist.GetCFBundleVersion () != null) props.Add ("CFBundleShortVersionString", new PString (plist.GetCFBundleVersion ())); var iconFiles = plist.GetCFBundleIconFiles (); var iconDict = plist.GetCFBundleIcons (); var icons = new PArray (); if (iconFiles != null) AddIconPaths (icons, iconFiles, Path.Combine (archiveDir, "Products")); if (iconDict != null) { var primary = iconDict.Get<PDictionary> (ManifestKeys.CFBundlePrimaryIcon); if (primary != null && (iconFiles = primary.GetCFBundleIconFiles ()) != null) AddIconPaths (icons, iconFiles, Path.Combine (archiveDir, "Products")); } if (icons.Count > 0) props.Add ("IconPaths", icons); props.Add ("SigningIdentity", new PString (SigningKey)); arInfo.Add ("ApplicationProperties", props); arInfo.Add ("ArchiveVersion", new PNumber (2)); arInfo.Add ("CreationDate", new PDate (Now.ToUniversalTime ())); arInfo.Add ("Name", new PString (plist.GetCFBundleName () ?? plist.GetCFBundleDisplayName ())); arInfo.Add ("SchemeName", new PString (ProjectName)); if (!string.IsNullOrEmpty (SolutionPath)) { arInfo.Add ("SolutionName", new PString (Path.GetFileNameWithoutExtension (SolutionPath))); arInfo.Add ("SolutionPath", new PString (SolutionPath)); } arInfo.Save (Path.Combine (archiveDir, "Info.plist")); ArchiveDir = archiveDir; } catch (Exception ex) { Log.LogErrorFromException (ex); Directory.Delete (archiveDir, true); } return !Log.HasLoggedErrors; }
bool Compile(PDictionary plist) { var currentSDK = IPhoneSdks.GetSdk (Framework); if (!currentSDK.SdkIsInstalled (sdkVersion, SdkIsSimulator)) { Log.LogError (null, null, null, null, 0, 0, 0, 0, "The {0} SDK for '{1}' is not installed.", Framework, sdkVersion); return false; } supportedDevices = plist.GetUIDeviceFamily (); if (!IsWatchApp) { var version = IPhoneSdks.MonoTouch.ExtendedVersion; // This key is our supported way of determining if an app // was built with Xamarin, so it needs to be present in all apps. var dict = new PDictionary (); dict.Add ("Version", new PString (string.Format ("{0} ({1}: {2})", version.Version, version.Branch, version.Hash))); plist.Add ("com.xamarin.ios", dict); } var sdkSettings = currentSDK.GetSdkSettings (sdkVersion, SdkIsSimulator); var dtSettings = currentSDK.GetDTSettings (); SetValue (plist, ManifestKeys.BuildMachineOSBuild, dtSettings.BuildMachineOSBuild); plist.SetIfNotPresent (ManifestKeys.CFBundleDevelopmentRegion, "en"); plist.SetIfNotPresent (ManifestKeys.CFBundleExecutable, AssemblyName); if (IsIOS) { var executable = plist.GetCFBundleExecutable (); if (executable.EndsWith (".app", StringComparison.Ordinal)) LogAppManifestError ("The executable (CFBundleExecutable) name ({0}) cannot end with '.app', because iOS may fail to launch the app.", executable); } if (IsIOS) { if (minimumOSVersion < IPhoneSdkVersion.V5_0 && plist.GetUIMainStoryboardFile (true) != null) LogAppManifestError ("Applications using a storyboard as the Main Interface must have a deployment target greater than 5.0"); if (!plist.ContainsKey (ManifestKeys.CFBundleName)) plist [ManifestKeys.CFBundleName] = plist.ContainsKey (ManifestKeys.CFBundleDisplayName) ? plist.GetString (ManifestKeys.CFBundleDisplayName).Clone () : new PString (AppBundleName); } else { plist.SetIfNotPresent (ManifestKeys.CFBundleName, AppBundleName); } plist.SetIfNotPresent (ManifestKeys.CFBundleIdentifier, BundleIdentifier); plist.SetIfNotPresent (ManifestKeys.CFBundleInfoDictionaryVersion, "6.0"); plist.SetIfNotPresent (ManifestKeys.CFBundlePackageType, IsAppExtension ? "XPC!" : "APPL"); if (!string.IsNullOrEmpty (ResourceRules)) plist.SetIfNotPresent (ManifestKeys.CFBundleResourceSpecification, Path.GetFileName (ResourceRules)); plist.SetIfNotPresent (ManifestKeys.CFBundleSignature, "????"); if (!plist.ContainsKey (ManifestKeys.CFBundleSupportedPlatforms)) plist[ManifestKeys.CFBundleSupportedPlatforms] = new PArray { SdkPlatform }; plist.SetIfNotPresent (ManifestKeys.CFBundleVersion, "1.0"); if (!SdkIsSimulator) { SetValue (plist, "DTCompiler", sdkSettings.DTCompiler); SetValue (plist, "DTPlatformBuild", dtSettings.DTPlatformBuild); SetValue (plist, "DTSDKBuild", sdkSettings.DTSDKBuild); } plist.SetIfNotPresent ("DTPlatformName", SdkPlatform.ToLowerInvariant ()); if (!SdkIsSimulator) SetValue (plist, "DTPlatformVersion", dtSettings.DTPlatformVersion); var sdkName = sdkSettings.CanonicalName; // older sdksettings didn't have a canonicalname for sim if (SdkIsSimulator && string.IsNullOrEmpty (sdkName)) { var deviceSdkSettings = currentSDK.GetSdkSettings (sdkVersion, false); sdkName = deviceSdkSettings.AlternateSDK; } SetValue (plist, "DTSDKName", sdkName); if (!SdkIsSimulator) { SetValue (plist, "DTXcode", AppleSdkSettings.DTXcode); SetValue (plist, "DTXcodeBuild", dtSettings.DTXcodeBuild); } SetDeviceFamily (plist); if (IsWatchExtension) { PObject capabilities; if (!plist.TryGetValue (ManifestKeys.UIRequiredDeviceCapabilities, out capabilities)) plist[ManifestKeys.UIRequiredDeviceCapabilities] = capabilities = new PArray (); } plist.SetIfNotPresent (ManifestKeys.MinimumOSVersion, minimumOSVersion.ToString ()); // Remove any Xamarin Studio specific keys plist.Remove (ManifestKeys.XSLaunchImageAssets); plist.Remove (ManifestKeys.XSAppIconAssets); // Merge with any partial plists generated by the Asset Catalog compiler... MergePartialPlistTemplates (plist); if (IsIOS) Validation (plist); CompiledAppManifest = new TaskItem (Path.Combine (AppBundleDir, "Info.plist")); plist.Save (CompiledAppManifest.ItemSpec, true, true); return !Log.HasLoggedErrors; }
PDictionary MergeEntitlementDictionary(PDictionary dict, MobileProvision profile) { var result = new PDictionary (); foreach (var item in dict) { PObject value = item.Value; if (value is PDictionary) value = MergeEntitlementDictionary ((PDictionary) value, profile); else if (value is PString) value = MergeEntitlementString ((PString) value, profile); else if (value is PArray) value = MergeEntitlementArray ((PArray) value, profile); else value = value.Clone (); if (value != null) result.Add (item.Key, value); } return result; }
void SaveMetaFile(int count, long size) { var meta = new PDictionary (); meta.Add ("RecordCount", new PNumber (count)); meta.Add ("StandardDirectoryPerms", new PNumber (16877)); meta.Add ("StandardFilePerms", new PNumber (-32348)); meta.Add ("TotalUncompressedBytes", new PNumber ((int) size)); meta.Add ("Version", new PNumber (2)); Directory.CreateDirectory (Path.Combine (Source.ItemSpec, "META-INF")); meta.Save (Path.Combine (Source.ItemSpec, "META-INF", "com.apple.ZipMetadata.plist"), true, true); }