public override void Load (string fileName)
		{
			ContentName = fileName;

			if (pobject == null) {
				var dict = new PDictionary ();
				if (dict.Reload (fileName)) {
					pobject = dict;
				} else {
					var arr = new PArray ();
					if (!arr.Reload (fileName)) {
						MessageService.ShowError (GettextCatalog.GetString ("Can't load plist file {0}.", fileName));
						return;
					}
					pobject = arr;
				}
				
				Buffer = null;
				widget.SetPListContainer (pobject);
				pobject.Changed += (sender, e) => {
					Buffer = null;
					IsDirty = true;
				};
			}
			this.IsDirty = false;
		}
Example #2
0
        protected override IEnumerable<string> GetTargetDevices(PDictionary plist)
        {
            var devices = IPhoneDeviceType.NotSet;
            bool watch = false;

            if (plist != null) {
                if (!(watch = plist.GetWKWatchKitApp ())) {
                    // the project is either a normal iOS project or an extension
                    if ((devices = plist.GetUIDeviceFamily ()) == IPhoneDeviceType.NotSet) {
                        // library projects and extension projects will not have this key, but
                        // we'll want them to work for both iPhones and iPads if the
                        // xib or storyboard supports them
                        devices = IPhoneDeviceType.IPhoneAndIPad;
                    }

                    // if the project is a watch extension, we'll also want to incldue watch support
                    watch = IsWatchExtension (plist);
                } else {
                    // the project is a WatchApp, only include watch support
                }
            } else {
                devices = IPhoneDeviceType.IPhoneAndIPad;
            }

            if ((devices & IPhoneDeviceType.IPhone) != 0)
                yield return "iphone";

            if ((devices & IPhoneDeviceType.IPad) != 0)
                yield return "ipad";

            if (watch)
                yield return "watch";

            yield break;
        }
		public PListEditorWidget (IPlistEditingHandler handler, Project proj, PDictionary plist)
		{
			var summaryScrolledWindow = new PListEditorSection ();
			AppendPage (summaryScrolledWindow, new Label (GettextCatalog.GetString ("Summary")));
			
			var advancedScrolledWindow = new PListEditorSection ();
			AppendPage (advancedScrolledWindow, new Label (GettextCatalog.GetString ("Advanced")));
			
			foreach (var section in handler.GetSections (proj, plist)) {
				var expander = new MacExpander () {
					ContentLabel = section.Name,
					Expandable = true,
				};
				expander.SetWidget (section.Widget);
				
				if (section.IsAdvanced) {
					advancedScrolledWindow.AddExpander (expander);
				} else {
					summaryScrolledWindow.AddExpander (expander);
				}
				
				if (section.CheckVisible != null) {
					expander.Visible = section.CheckVisible (plist);
					//capture section for closure
					var s = section;
					plist.Changed += delegate {
						expander.Visible = s.CheckVisible (plist);
					};
				}
			}
			Show ();
		}
Example #4
0
        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;
        }
Example #5
0
        protected override PDictionary GetCompiledEntitlements(MobileProvision profile, PDictionary template)
        {
            var entitlements = base.GetCompiledEntitlements (profile, template);
            PBoolean sandbox;

            if (Debug && entitlements.TryGetValue ("com.apple.security.app-sandbox", out sandbox) && sandbox.Value)
                entitlements["com.apple.security.network.client"] = new PBoolean (true);

            return entitlements;
        }
Example #6
0
        static bool IsWatchExtension(PDictionary plist)
        {
            PDictionary extension;
            PString id;

            if (!plist.TryGetValue ("NSExtension", out extension))
                return false;

            if (!extension.TryGetValue ("NSExtensionPointIdentifier", out id))
                return false;

            return id.Value == "com.apple.watchkit";
        }
Example #7
0
        protected void MergePartialPlistDictionary(PDictionary plist, PDictionary partial)
        {
            foreach (var property in partial) {
                if (plist.ContainsKey (property.Key)) {
                    var value = plist[property.Key];

                    if (value is PDictionary && property.Value is PDictionary) {
                        MergePartialPlistDictionary ((PDictionary) value, (PDictionary) property.Value);
                    } else {
                        plist[property.Key] = property.Value.Clone ();
                    }
                } else {
                    plist[property.Key] = property.Value.Clone ();
                }
            }
        }
Example #8
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;
				}
			}
Example #9
0
        public override void Setup()
        {
            base.Setup ();

            var extensionName = "MyActionExtension";
            BuildExtension ("MyTabbedApplication", extensionName, "iPhoneSimulator");

            task = CreateTask<ValidateAppBundleTask> ();
            task.AppBundlePath = AppBundlePath;
            task.SdkIsSimulator = true;
            task.TargetFrameworkIdentifier = "Xamarin.iOS";

            extensionBundlePath = Path.Combine (AppBundlePath, "PlugIns", extensionName + ".appex");

            mainAppPlistPath = Path.Combine (AppBundlePath, "Info.plist");
            extensionPlistPath = Path.Combine (extensionBundlePath, "Info.plist");

            sourcePlist = PDictionary.FromFile (mainAppPlistPath);
        }
Example #10
0
        void SetIOSDeviceFamily(PDictionary plist)
        {
            if (IsWatchApp) {
                if (SdkIsSimulator) {
                    plist.SetUIDeviceFamily (IPhoneDeviceType.IPhone | IPhoneDeviceType.Watch);
                } else {
                    plist.SetUIDeviceFamily (IPhoneDeviceType.Watch);
                }
            } else {
                if (!IsAppExtension)
                    plist.SetIfNotPresent (ManifestKeys.LSRequiresIPhoneOS, true);

                if (minimumOSVersion >= IPhoneSdkVersion.V3_2 && supportedDevices == IPhoneDeviceType.NotSet)
                    plist.SetUIDeviceFamily (IPhoneDeviceType.IPhone);
            }
        }
Example #11
0
        void Validation(PDictionary plist)
        {
            var supportsIPhone = (supportedDevices & IPhoneDeviceType.IPhone) != 0
                                 || supportedDevices == IPhoneDeviceType.NotSet;
            var supportsIPad = (supportedDevices & IPhoneDeviceType.IPad) != 0;

            // Validation...
            if (!IsAppExtension && sdkVersion >= IPhoneSdkVersion.V3_2) {
                IPhoneOrientation orientation;

                if (supportsIPhone) {
                    orientation = plist.GetUISupportedInterfaceOrientations (false);
                    if (orientation == IPhoneOrientation.None) {
                        LogAppManifestWarning ("Supported iPhone orientations have not been set");
                    } else if (!orientation.IsValidPair ()) {
                        LogAppManifestWarning ("Supported iPhone orientations are not matched pairs");
                    }
                }

                if (supportsIPad) {
                    orientation = plist.GetUISupportedInterfaceOrientations (true);
                    if (orientation == IPhoneOrientation.None) {
                        LogAppManifestWarning ("Supported iPad orientations have not been set");
                    } else if (!orientation.IsValidPair ()) {
                        LogAppManifestWarning ("Supported iPad orientations are not matched pairs");
                    }
                }
            }
        }
Example #12
0
        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;
        }
Example #13
0
 void SetDeviceFamily(PDictionary plist)
 {
     switch (Framework) {
     case PlatformFramework.iOS:
         SetIOSDeviceFamily (plist);
         break;
     case PlatformFramework.WatchOS:
         plist.SetUIDeviceFamily (IPhoneDeviceType.Watch);
         break;
     case PlatformFramework.TVOS:
         plist.SetUIDeviceFamily (IPhoneDeviceType.TV);
         break;
     }
 }
Example #14
0
        protected void SetValue(PDictionary dict, string key, string value)
        {
            if (dict.ContainsKey (key))
                return;

            if (string.IsNullOrEmpty (value))
                LogAppManifestWarning ("Could not determine value for manifest key '{0}'", key);
            else
                dict[key] = value;
        }
Example #15
0
        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;
        }
		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 ());
			}
		}
		void AddToTree (Gtk.TreeStore treeStore, Gtk.TreeIter iter, PDictionary dict)
		{
			iterTable[dict] = iter;
			foreach (var item in dict) {
				var key = item.Key.ToString ();
				var subIter = iter.Equals (TreeIter.Zero) ? treeStore.AppendValues (key, item.Value) : treeStore.AppendValues (iter, key, item.Value);
				if (item.Value is PArray)
					AddToTree (treeStore, subIter, (PArray)item.Value);
				if (item.Value is PDictionary)
					AddToTree (treeStore, subIter, (PDictionary)item.Value);
				if (expandedObjects.Contains (item.Value))
					treeview.ExpandRow (treeStore.GetPath (subIter), true);
			}
			AddCreateNewEntry (iter);
			
			if (!rebuildArrays.Contains (dict)) {
				rebuildArrays.Add (dict);
				dict.Changed += HandleDictRebuild;
			}
		}
Example #18
0
        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;
        }
Example #19
0
        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;
        }
Example #20
0
        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;
        }
Example #21
0
		//-------------------------------------------------------------------------------------
		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
			{
			}
		}
Example #22
0
		//-------------------------------------------------------------------------------------
		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);
			}
		}
Example #23
0
 protected virtual IEnumerable<string> GetTargetDevices(PDictionary plist)
 {
     yield break;
 }
Example #24
0
        protected void LogWarningsAndErrors(PDictionary plist, ITaskItem file)
        {
            PDictionary dictionary;
            PString message;
            PArray array;

            if (plist.TryGetValue (string.Format ("com.apple.{0}.document.notices", ToolName), out array)) {
                foreach (var item in array.OfType<PDictionary> ()) {
                    if (item.TryGetValue ("message", out message))
                        Log.LogMessage (MessageImportance.Low, "{0}", message.Value);
                }
            }

            if (plist.TryGetValue (string.Format ("com.apple.{0}.document.warnings", ToolName), out array)) {
                foreach (var item in array.OfType<PDictionary> ()) {
                    if (item.TryGetValue ("message", out message))
                        Log.LogWarning (ToolName, null, null, file.ItemSpec, 0, 0, 0, 0, "{0}", message.Value);
                }
            }

            if (plist.TryGetValue (string.Format ("com.apple.{0}.document.errors", ToolName), out array)) {
                foreach (var item in array.OfType<PDictionary> ()) {
                    if (item.TryGetValue ("message", out message))
                        Log.LogError (ToolName, null, null, file.ItemSpec, 0, 0, 0, 0, "{0}", message.Value);
                }
            }

            //Trying to parse document warnings and erros using a PDictionary first since it's what ibtool is returning when building a storyboard.
            if (plist.TryGetValue (string.Format ("com.apple.{0}.document.notices", ToolName), out dictionary)) {
                foreach (var valuePair in dictionary) {
                    array = valuePair.Value as PArray;
                    foreach (var item in array.OfType<PDictionary> ()) {
                        if (item.TryGetValue ("message", out message))
                            Log.LogMessage (MessageImportance.Low, "{0}", message.Value);
                    }
                }
            }

            if (plist.TryGetValue (string.Format ("com.apple.{0}.document.warnings", ToolName), out dictionary)) {
                foreach (var valuePair in dictionary) {
                    array = valuePair.Value as PArray;
                    foreach (var item in array.OfType<PDictionary> ()) {
                        if (item.TryGetValue ("message", out message))
                            Log.LogWarning (ToolName, null, null, file.ItemSpec, 0, 0, 0, 0, "{0}", message.Value);
                    }
                }
            }

            if (plist.TryGetValue (string.Format ("com.apple.{0}.document.errors", ToolName), out dictionary)) {
                foreach (var valuePair in dictionary) {
                    array = valuePair.Value as PArray;
                    foreach (var item in array.OfType<PDictionary> ()) {
                        if (item.TryGetValue ("message", out message))
                            Log.LogError (ToolName, null, null, file.ItemSpec, 0, 0, 0, 0, "{0}", message.Value);
                    }
                }
            }

            if (plist.TryGetValue (string.Format ("com.apple.{0}.errors", ToolName), out array)) {
                foreach (var item in array.OfType<PDictionary> ()) {
                    if (item.TryGetValue ("description", out message))
                        Log.LogError (ToolName, null, null, file.ItemSpec, 0, 0, 0, 0, "{0}", message.Value);
                }
            }

            if (plist.TryGetValue (string.Format ("com.apple.{0}.notices", ToolName), out array)) {
                foreach (var item in array.OfType<PDictionary> ()) {
                    if (item.TryGetValue ("description", out message))
                        Log.LogError (ToolName, null, null, file.ItemSpec, 0, 0, 0, 0, "{0}", message.Value);
                }
            }
        }
Example #25
0
        public virtual void ConfigureTask()
        {
            Task = CreateTask<CompileAppManifest> ();

            Task.AppBundleName = appBundleName;
            Task.AppBundleDir = "AppBundlePath";
            Task.AssemblyName = assemblyName;
            Task.AppManifest = CreateTempFile ("foo.plist");
            Task.BundleIdentifier = bundleIdentifier;
            Task.SdkPlatform = "iPhoneSimulator";

            Plist = new PDictionary ();
            Plist ["CFBundleDisplayName"] = displayName;
            Plist ["CFBundleIdentifier"] = identifier;
            Plist.Save (Task.AppManifest);
        }
Example #26
0
        static bool IsWatchAppExtension(ITaskItem appex, PDictionary plist, out string watchAppBundleDir)
        {
            PString expectedBundleIdentifier, bundleIdentifier, extensionPoint;
            PDictionary extension, attributes;

            watchAppBundleDir = null;

            if (!plist.TryGetValue ("NSExtension", out extension))
                return false;

            if (!extension.TryGetValue ("NSExtensionPointIdentifier", out extensionPoint))
                return false;

            if (extensionPoint.Value != "com.apple.watchkit")
                return false;

            // Okay, we've found the WatchKit App Extension...
            if (!extension.TryGetValue ("NSExtensionAttributes", out attributes))
                return false;

            if (!attributes.TryGetValue ("WKAppBundleIdentifier", out expectedBundleIdentifier))
                return false;

            var pwd = PathUtils.ResolveSymbolicLink (Environment.CurrentDirectory);

            // Scan the *.app subdirectories to find the WatchApp bundle...
            foreach (var bundle in Directory.GetDirectories (appex.ItemSpec, "*.app")) {
                if (!File.Exists (Path.Combine (bundle, "Info.plist")))
                    continue;

                plist = PDictionary.FromFile (Path.Combine (bundle, "Info.plist"));

                if (!plist.TryGetValue ("CFBundleIdentifier", out bundleIdentifier))
                    continue;

                if (bundleIdentifier.Value != expectedBundleIdentifier.Value)
                    continue;

                watchAppBundleDir = PathUtils.AbsoluteToRelative (pwd, PathUtils.ResolveSymbolicLink (bundle));

                return true;
            }

            return false;
        }
Example #27
0
        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;
        }
Example #28
0
        protected void MergePartialPlistTemplates(PDictionary plist)
        {
            if (PartialAppManifests == null)
                return;

            foreach (var template in PartialAppManifests) {
                PDictionary partial;

                try {
                    partial = PDictionary.FromFile (template.ItemSpec);
                } catch (Exception ex) {
                    Log.LogError ("Error loading partial Info.plist template file '{0}': {1}", template.ItemSpec, ex.Message);
                    continue;
                }

                MergePartialPlistDictionary (plist, partial);
            }
        }
Example #29
0
        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;
        }
Example #30
0
        IEnumerable<ITaskItem> GetCompiledBundleResources(PDictionary output, string intermediateBundleDir)
        {
            var pwd = PathUtils.ResolveSymbolicLink (Environment.CurrentDirectory);
            PDictionary dict;
            PArray array;

            if (output.TryGetValue (string.Format ("com.apple.{0}.compilation-results", ToolName), out dict) && dict.TryGetValue ("output-files", out array)) {
                foreach (var path in array.OfType<PString> ().Select (x => x.Value)) {
                    // don't include the generated plist files as BundleResources
                    if (path.EndsWith ("partial-info.plist", StringComparison.Ordinal))
                        continue;

                    var vpath = PathUtils.AbsoluteToRelative (pwd, PathUtils.ResolveSymbolicLink (path));
                    var item = new TaskItem (vpath);

                    // Note: the intermediate bundle dir functions as a top-level bundle dir
                    var logicalName = PathUtils.AbsoluteToRelative (intermediateBundleDir, path);

                    if (logicalName.StartsWith ("../OnDemandResources/", StringComparison.Ordinal)) {
                        logicalName = logicalName.Substring (3);

                        var outputPath = Path.Combine (OutputPath, logicalName);

                        item.SetMetadata ("OutputPath", outputPath);
                    }

                    item.SetMetadata ("LogicalName", logicalName);
                    item.SetMetadata ("Optimize", "false");

                    yield return item;
                }
            }

            yield break;
        }