コード例 #1
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, item.Key == ApplicationIdentifierKey);
                    }
                    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, MSBStrings.W0110, item.Key);
                    }
                    else if (!profile.Entitlements.ContainsKey(item.Key))
                    {
                        Log.LogWarning(null, null, null, Entitlements, 0, 0, 0, 0, MSBStrings.W0111, item.Key);
                    }
                }
                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, item.Key == ApplicationIdentifierKey);
                }
                else if (value is PArray)
                {
                    value = MergeEntitlementArray((PArray)value, profile);
                }
                else
                {
                    value = value.Clone();
                }

                if (value != null)
                {
                    entitlements[item.Key] = value;
                }
            }

            switch (Platform)
            {
            case ApplePlatform.MacOSX:
            case ApplePlatform.MacCatalyst:
                if (Debug && entitlements.TryGetValue("com.apple.security.app-sandbox", out PBoolean sandbox) && sandbox.Value)
                {
                    entitlements ["com.apple.security.network.client"] = new PBoolean(true);
                }
                break;
            }

            return(entitlements);
        }
コード例 #2
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);
        }