public void AddAppGroupsWorks()
        {
            SetupTestProject();
            ResetGuidGenerator();

            var capManager = new ProjectCapabilityManager(PBXProject.GetPBXProjectPath(GetTestOutputPath()), "test.entitlements", PBXProject.GetUnityTargetName());

            capManager.AddAppGroups(new string[] { "test1", "test2" });
            capManager.WriteToFile();

            TestOutputProject(capManager.project, "add_appgroups.pbxproj");
            TestOutput("test.entitlements", "add_appgroups.entitlements");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add the required capabilities and entitlements for OneSignal
        /// </summary>
        private void AddProjectCapabilities()
        {
            var targetGuid = _project.GetMainTargetGuid();
            var targetName = _project.GetMainTargetName();

            var entitlementsPath = GetEntitlementsPath(targetGuid, targetName);
            var projCapability   = new ProjectCapabilityManager(_projectPath, entitlementsPath, targetName);

            projCapability.AddBackgroundModes(BackgroundModesOptions.RemoteNotifications);
            projCapability.AddPushNotifications(false);
            projCapability.AddAppGroups(new[] { _appGroupName });

            projCapability.WriteToFile();
        }
    private static void AddAppGroup(string buildPath, string appGroup)
    {
        string projectPath = PBXProject.GetPBXProjectPath(buildPath);
        var    project     = new PBXProject();

        project.ReadFromString(File.ReadAllText(projectPath));

        #if UNITY_2019_3_OR_NEWER
        string targetGuid = project.GetUnityMainTargetGuid();
        var    manager    = new ProjectCapabilityManager(projectPath, "Entitlements.entitlements", null, targetGuid);
        #else
        string targetGuid = project.TargetGuidByName("Unity-iPhone");
        var    manager    = new ProjectCapabilityManager(projectPath, "Entitlements.entitlements", targetGuid);
        #endif
        manager.AddAppGroups(new string[] { appGroup });
        manager.WriteToFile();
    }
Ejemplo n.º 4
0
        /// <summary>
        /// Create and add the notification extension to the project
        /// </summary>
        private void AddNotificationServiceExtension()
        {
#if !UNITY_CLOUD_BUILD
            // refresh plist and podfile on appends
            ExtensionCreatePlist(_outputPath);
            ExtensionAddPodsToTarget();

            var extensionGuid = _project.TargetGuidByName(ServiceExtensionTargetName);

            // skip target setup if already present
            if (!string.IsNullOrEmpty(extensionGuid))
            {
                return;
            }

            extensionGuid = _project.AddAppExtension(_project.GetMainTargetGuid(),
                                                     ServiceExtensionTargetName,
                                                     PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS) + "." + ServiceExtensionTargetName,
                                                     ServiceExtensionTargetName + "/" + "Info.plist" // Unix path as it's used by Xcode
                                                     );

            ExtensionAddSourceFiles(extensionGuid);

            // Makes it so that the extension target is Universal (not just iPhone) and has an iOS 10 deployment target
            _project.SetBuildProperty(extensionGuid, "TARGETED_DEVICE_FAMILY", "1,2");
            _project.SetBuildProperty(extensionGuid, "IPHONEOS_DEPLOYMENT_TARGET", "10.0");
            _project.SetBuildProperty(extensionGuid, "SWIFT_VERSION", "5.0");
            _project.SetBuildProperty(extensionGuid, "ARCHS", "arm64");
            _project.SetBuildProperty(extensionGuid, "DEVELOPMENT_TEAM", PlayerSettings.iOS.appleDeveloperTeamID);

            _project.AddBuildProperty(extensionGuid, "LIBRARY_SEARCH_PATHS",
                                      $"$(PROJECT_DIR)/Libraries/{PluginLibrariesPath.Replace("\\", "/")}");

            _project.WriteToFile(_projectPath);

            // add capabilities + entitlements
            var entitlementsPath = GetEntitlementsPath(extensionGuid, ServiceExtensionTargetName);
            var projCapability   = new ProjectCapabilityManager(_projectPath, entitlementsPath, ServiceExtensionTargetName);

            projCapability.AddAppGroups(new[] { _appGroupName });

            projCapability.WriteToFile();
#endif
        }
        static void AddCapabilities(PBXProject proj, string targetGuid, ProjectCapabilityManager capManager)
        {
            var capability = ISD_Settings.Instance.Capability;

            if (capability.iCloud.Enabled)
            {
                if (capability.iCloud.iCloudDocument || capability.iCloud.customContainers.Count > 0)
                {
                    capManager.AddiCloud(capability.iCloud.keyValueStorage, capability.iCloud.iCloudDocument, capability.iCloud.customContainers.ToArray());
                }
                else
                {
                    capManager.AddiCloud(capability.iCloud.keyValueStorage, false, null);
                }
            }

            if (capability.PushNotifications.Enabled)
            {
                capManager.AddPushNotifications(capability.PushNotifications.development);
            }

            if (capability.GameCenter.Enabled)
            {
                capManager.AddGameCenter();
            }

            if (capability.Wallet.Enabled)
            {
                capManager.AddWallet(capability.Wallet.passSubset.ToArray());
            }

            if (capability.Siri.Enabled)
            {
                capManager.AddSiri();
            }

            if (capability.ApplePay.Enabled)
            {
                capManager.AddApplePay(capability.ApplePay.merchants.ToArray());
            }

            if (capability.InAppPurchase.Enabled)
            {
                capManager.AddInAppPurchase();
            }

            if (capability.Maps.Enabled)
            {
                var options = MapsOptions.None;
                foreach (var opt in capability.Maps.options)
                {
                    MapsOptions opt2 = (MapsOptions)opt;
                    options |= opt2;
                }
                capManager.AddMaps(options);
            }

            if (capability.PersonalVPN.Enabled)
            {
                capManager.AddPersonalVPN();
            }

            if (capability.BackgroundModes.Enabled)
            {
                var options = BackgroundModesOptions.None;
                foreach (var opt in capability.BackgroundModes.options)
                {
                    BackgroundModesOptions opt2 = (BackgroundModesOptions)opt;
                    options |= opt2;
                }
                capManager.AddBackgroundModes(options);
            }


            if (capability.InterAppAudio.Enabled)
            {
                capManager.AddInterAppAudio();
            }

            if (capability.KeychainSharing.Enabled)
            {
                capManager.AddKeychainSharing(capability.KeychainSharing.accessGroups.ToArray());
            }

            if (capability.AssociatedDomains.Enabled)
            {
                capManager.AddAssociatedDomains(capability.AssociatedDomains.domains.ToArray());
            }

            if (capability.AppGroups.Enabled)
            {
                capManager.AddAppGroups(capability.AppGroups.groups.ToArray());
            }

            if (capability.DataProtection.Enabled)
            {
                capManager.AddDataProtection();
            }

            if (capability.HomeKit.Enabled)
            {
                capManager.AddHomeKit();
            }

            if (capability.HealthKit.Enabled)
            {
                capManager.AddHealthKit();
            }

            if (capability.WirelessAccessoryConfiguration.Enabled)
            {
                capManager.AddWirelessAccessoryConfiguration();
            }

            /*
             *
             *
             * if (ISD_Settings.Instance.Capabilities.Count == 0) {
             *  return;
             * }
             *
             *
             * foreach (var cap in ISD_Settings.Instance.Capabilities) {
             *  switch(cap.CapabilityType) {
             *
             *
             *       case ISD_CapabilityType.InAppPurchase:
             *          capManager.AddInAppPurchase();
             *          break;
             *      case ISD_CapabilityType.GameCenter:
             *          capManager.AddGameCenter();
             *          break;
             *      case ISD_CapabilityType.PushNotifications:
             *          var pushSettings = ISD_Settings.Instance.PushNotificationsCapabilitySettings;
             *          capManager.AddPushNotifications(pushSettings.Development);
             *          break;
             *
             *      default:
             *          var capability = ISD_PBXCapabilityTypeUtility.ToPBXCapability(cap.CapabilityType);
             *          string entitlementsFilePath = null;
             *          if(!string.IsNullOrEmpty(cap.EntitlementsFilePath)) {
             *              entitlementsFilePath = cap.EntitlementsFilePath;
             *          }
             *
             *
             *          proj.AddCapability(targetGuid, capability, entitlementsFilePath, cap.AddOptionalFramework);
             *          break;
             *  }
             * }
             */
        }
Ejemplo n.º 6
0
        private static void AddCapabilities(ProjectCapabilityManager capManager)
        {
            var capability = ISD_Settings.Instance.Capability;

            if (capability.iCloud.Enabled)
            {
                if (capability.iCloud.iCloudDocument || capability.iCloud.customContainers.Count > 0)
                {
                    capManager.AddiCloud(capability.iCloud.keyValueStorage, capability.iCloud.iCloudDocument, capability.iCloud.customContainers.ToArray());
                }
                else
                {
                    capManager.AddiCloud(capability.iCloud.keyValueStorage, false, null);
                }
            }

            if (capability.PushNotifications.Enabled)
            {
                capManager.AddPushNotifications(capability.PushNotifications.development);
            }

            if (capability.GameCenter.Enabled)
            {
                capManager.AddGameCenter();
            }

            if (capability.Wallet.Enabled)
            {
                capManager.AddWallet(capability.Wallet.passSubset.ToArray());
            }

            if (capability.Siri.Enabled)
            {
                capManager.AddSiri();
            }

            if (capability.ApplePay.Enabled)
            {
                capManager.AddApplePay(capability.ApplePay.merchants.ToArray());
            }

            if (capability.InAppPurchase.Enabled)
            {
                capManager.AddInAppPurchase();
            }

            if (capability.Maps.Enabled)
            {
                var options = MapsOptions.None;
                foreach (var opt in capability.Maps.options)
                {
                    MapsOptions opt2 = (MapsOptions)opt;
                    options |= opt2;
                }
                capManager.AddMaps(options);
            }

            if (capability.PersonalVPN.Enabled)
            {
                capManager.AddPersonalVPN();
            }

            if (capability.BackgroundModes.Enabled)
            {
                var options = BackgroundModesOptions.None;
                foreach (var opt in capability.BackgroundModes.options)
                {
                    BackgroundModesOptions opt2 = (BackgroundModesOptions)opt;
                    options |= opt2;
                }
                capManager.AddBackgroundModes(options);
            }


            if (capability.InterAppAudio.Enabled)
            {
                capManager.AddInterAppAudio();
            }

            if (capability.KeychainSharing.Enabled)
            {
                capManager.AddKeychainSharing(capability.KeychainSharing.accessGroups.ToArray());
            }

            if (capability.AssociatedDomains.Enabled)
            {
                capManager.AddAssociatedDomains(capability.AssociatedDomains.domains.ToArray());
            }

            if (capability.AppGroups.Enabled)
            {
                capManager.AddAppGroups(capability.AppGroups.groups.ToArray());
            }

            if (capability.DataProtection.Enabled)
            {
                capManager.AddDataProtection();
            }

            if (capability.HomeKit.Enabled)
            {
                capManager.AddHomeKit();
            }

            if (capability.HealthKit.Enabled)
            {
                capManager.AddHealthKit();
            }

            if (capability.WirelessAccessoryConfiguration.Enabled)
            {
                capManager.AddWirelessAccessoryConfiguration();
            }
        }