コード例 #1
0
    /*! @brief              Updates the Xcode project.
     *      @param buildTarget  the target build platform
     *      @param path         the path of the target build
     */
    public void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            string           plistPath = Path.Combine(path, "Info.plist");
            PlistDocument    info      = GetInfoPlist(plistPath);
            PlistElementDict rootDict  = info.root;
            // // Add the keys
            if (this.shareString != null)
            {
                rootDict.SetString("NSHealthShareUsageDescription", this.shareString);
            }
//			else {
//				Debug.LogError("unable to read NSHealthShareUsageDescription");
//			}
            if (this.updateString != null)
            {
                rootDict.SetString("NSHealthUpdateUsageDescription", this.updateString);
            }

            // Write the file
            info.WriteToFile(plistPath);

            string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

            PBXProject proj = new PBXProject();
            proj.ReadFromFile(projPath);

            string targetName = PBXProject.GetUnityTargetName();
            string target     = proj.TargetGuidByName(targetName);


            // Entitlements
            //--------------
            string projectname      = GetProjectName(info);
            string entitlementsFile = Path.ChangeExtension(projectname, "entitlements");
            string entitlementsPath = Path.Combine(path, entitlementsFile);
            var    dst = Path.Combine(projPath, entitlementsPath);
            CreateEntitlements(dst);
            proj.AddFileToBuild(target, proj.AddFile(entitlementsPath, entitlementsPath, PBXSourceTree.Source));
            proj.AddBuildProperty(target, "CODE_SIGN_ENTITLEMENTS", entitlementsPath);

            // add HealthKit capability
            ProjectCapabilityManager capabilities = new ProjectCapabilityManager(projPath, entitlementsPath, targetName);
            capabilities.AddHealthKit();

            // add HealthKit Framework
            proj.AddFrameworkToProject(target, "HealthKit.framework", true);

            // Set a custom link flag
            proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");

            proj.WriteToFile(projPath);
        }
    }
コード例 #2
0
        public void AddHealthKitWorks()
        {
            SetupTestProject();
            ResetGuidGenerator();

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

            capManager.AddHealthKit();
            capManager.WriteToFile();

            TestOutputProject(capManager.project, "add_healthkit.pbxproj");
            TestOutput("test.entitlements", "add_healthkit.entitlements");
            TestOutput("Info.plist", "add_healthkit.plist");
        }
コード例 #3
0
        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;
             *  }
             * }
             */
        }
コード例 #4
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();
            }
        }