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

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

            capManager.AddGameCenter();
            capManager.WriteToFile();

            TestOutputProject(capManager.project, "add_gamecenter.pbxproj");
            TestOutput("Info.plist", "add_gamecenter.plist");
        }
        public void AddMultipleCapabilitiesWorks()
        {
            SetupTestProject();
            ResetGuidGenerator();

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

            capManager.AddGameCenter();
            capManager.AddInAppPurchase();
            capManager.AddMaps(MapsOptions.Airplane);
            capManager.WriteToFile();

            TestOutputProject(capManager.project, "add_multiple.pbxproj");
        }
Beispiel #3
0
        static void AddCapabilities(PBXProject proj, string targetGuid, ProjectCapabilityManager capManager)
        {
            if (ISD_Settings.Instance.Capabilities.Count == 0)
            {
                return;
            }



            foreach (var cap in ISD_Settings.Instance.Capabilities)
            {
                switch (cap.CapabilityType)
                {
                case ISD_CapabilityType.Cloud:
                    var cloudSettings = ISD_Settings.Instance.iCloudCapabilitySettings;
                    capManager.AddiCloud(cloudSettings.KeyValueStorage, cloudSettings.iCloudDocument, new string[] { });
                    break;

                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;
                }
            }
        }
Beispiel #4
0
        private static void SetCapabilitiesSimple(string buildPath, string entitlementsName)
        {
            string     pbxPath    = PBXProject.GetPBXProjectPath(buildPath);
            PBXProject pbxProject = new PBXProject();

            pbxProject.ReadFromFile(pbxPath);
            var target_name = PBXProject.GetUnityTargetName();
            // var target_guid = pbxProject.TargetGuidByName(target_name);

            var capManager = new ProjectCapabilityManager(pbxPath, entitlementsName, target_name);

            capManager.AddGameCenter();
            capManager.AddInAppPurchase();
            bool developmentMode = true; // Development mode should be used while testing your application outside of the App Store.

            capManager.AddPushNotifications(developmentMode);
            capManager.AddBackgroundModes(BackgroundModesOptions.RemoteNotifications); //todo: Problem is: is not setting up remote notification flag

            capManager.WriteToFile();                                                  // will update Info List, Will update Capability Entitlements
        }
Beispiel #5
0
    private static void AddCapabilities(PBXProject project, string pathToBuildProject)
    {
        string targetGuid = project.GetUnityMainTargetGuid();
        string relativeEntitlementsFilePath = ProductName + "." + "entitlements";

        ProjectCapabilityManager manager = new ProjectCapabilityManager(pathToBuildProject + "/Unity-iPhone.xcodeproj/project.pbxproj", relativeEntitlementsFilePath, "Unity-iPhone");

        // 1. game center
        manager.AddGameCenter();
        if (project.ContainsFramework(targetGuid, "GameKit.framework") == false)
        {
            Debug.Log("Add GameKit.framework");
            project.AddFrameworkToProject(targetGuid, "GameKit.framework", true);
        }

        // 2. purchase
        manager.AddInAppPurchase();
        if (project.ContainsFramework(targetGuid, "StoreKit.framework") == false)
        {
            Debug.Log("Add StoreKit.framework");
            project.AddFrameworkToProject(targetGuid, "StoreKit.framework", true);
        }

        // 3. remote push
        manager.AddPushNotifications(true);
        project.AddFile(relativeEntitlementsFilePath, relativeEntitlementsFilePath);
        project.AddBuildProperty(targetGuid, "CODE_SIGN_ENTITLEMENTS", relativeEntitlementsFilePath);

        // 4. background
        manager.AddBackgroundModes(BackgroundModesOptions.RemoteNotifications);

        // 4. domains
        //string[] domains = { "xxx"};
        //manager.AddAssociatedDomains(domains);

        manager.WriteToFile();
    }
        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;
             *  }
             * }
             */
        }
Beispiel #7
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();
            }
        }
        protected override void OnPostProcessBuild(string playerPath)
        {
#if UNITY_IOS
            string projPath = Path.Combine(playerPath, "Unity-iPhone.xcodeproj/project.pbxproj");

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

            string target = proj.TargetGuidByName("Unity-iPhone");

            proj.SetBuildProperty(target, "ENABLE_BITCODE", m_EnableBitcode ? "YES" : "NO");

            if (string.IsNullOrEmpty(m_AppleDeveloperTeamId))
            {
                proj.SetBuildProperty(target, "DEVELOPMENT_TEAM", m_AppleDeveloperTeamId);
            }

            for (int i = 0; i < m_Frameworks.Length; i++)
            {
                var s = m_Frameworks[i];
                proj.AddFrameworkToProject(target, s, true);
            }

            for (int i = 0; i < m_Files.Length; i++)
            {
                var s = m_Files[i];
                proj.AddFileToBuild(target, proj.AddFile(Path.Combine("usr/lib/", s.Name), Path.Combine("Frameworks/", s.Name), (PBXSourceTree)s.SourceTree));
            }

            proj.WriteToFile(projPath);

            string        plistPath = Path.Combine(playerPath, "Info.plist");
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromFile(plistPath);
            PlistElementDict root = plist.root;

            for (int i = 0; i < m_InfoPlistEntries.Length; i++)
            {
                InfoPlistEntry entry = m_InfoPlistEntries[i];

                switch (entry.Type)
                {
                case PlistEntryType.Boolean:
                    root.SetBoolean(entry.Key, entry.BooleanValue);
                    break;

                case PlistEntryType.Integer:
                    root.SetInteger(entry.Key, entry.IntegerValue);
                    break;

                case PlistEntryType.String:
                    root.SetString(entry.Key, entry.StringValue);
                    break;
                }
            }

            plist.WriteToFile(plistPath);

            var capabilityManager = new ProjectCapabilityManager(projPath, "Unity-iPhone/app.entitlements", "Unity-iPhone");

            if (m_EnableGameCenter)
            {
                capabilityManager.AddGameCenter();
            }

            if (m_EnableInAppPurchase)
            {
                capabilityManager.AddInAppPurchase();
            }

            if (m_EnableKeychainSharing)
            {
                capabilityManager.AddKeychainSharing(m_KeychainAccessGroups);
            }

            if (m_EnablePushNotifications)
            {
                capabilityManager.AddPushNotifications(m_PushNotificationsDevelopment);
            }

            capabilityManager.WriteToFile();
#endif
        }
Beispiel #9
0
        public static void NewIOSXcodeSettings()
        {
            //添加XCode引用的Framework
            string     projPath = PBXProject.GetPBXProjectPath(Otherpath);
            PBXProject proj     = new PBXProject();

            proj.ReadFromString(File.ReadAllText(projPath));
            string target = proj.TargetGuidByName("Unity-iPhone");

            // BuildSetting修改
            proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");   //这个好像是bugly需要的
            proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC"); //这个google等其他sdk非常需要的
            //proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-all_load");
            #region 添加XCode引用的Framework
            // SDK依赖 --AIHelp
            proj.AddFrameworkToProject(target, "libsqlite3.tbd", false);
            proj.AddFrameworkToProject(target, "libresolv.tbd", false);
            proj.AddFrameworkToProject(target, "WebKit.framework", false);
            // SDK依赖 --Google
            proj.AddFrameworkToProject(target, "LocalAuthentication.framework", false);
            proj.AddFrameworkToProject(target, "SafariServices.framework", false);
            proj.AddFrameworkToProject(target, "AuthenticationServices.framework", false);
            proj.AddFrameworkToProject(target, "SystemConfiguration.framework", false);
            // SDK依赖 --Apple
            proj.AddFrameworkToProject(target, "storekit.framework", false);
            proj.AddFrameworkToProject(target, "AuthenticationServices.framework", false);
            proj.AddFrameworkToProject(target, "gamekit.framework", false);
            #endregion

            string        plistPath = Path.Combine(Otherpath, "Info.plist");
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromFile(plistPath);
            PlistElementDict rootDict = plist.root;
            #region 修改Xcode工程Info.plist
            /* iOS9所有的app对外http协议默认要求改成https */
            // Add value of NSAppTransportSecurity in Xcode plist
            PlistElementDict dictTmp = rootDict.CreateDict("NSAppTransportSecurity");
            dictTmp.SetBoolean("NSAllowsArbitraryLoads", true);
            //AIHelp-权限配置
            rootDict.SetString("NSCameraUsageDescription", "是否允许访问相机?");
            rootDict.SetString("NSMicrophoneUsageDescription", "是否允许使用麦克风?");
            rootDict.SetString("NSPhotoLibraryAddUsageDescription", "是否允许添加照片?");
            rootDict.SetString("NSMicrophoneUsageDescription", "是否允许访问相册?");

            rootDict.SetString("CFBundleDevelopmentRegion", "zh_TW");
            rootDict.SetString("CFBundleVersion", "1");
            // SDK相关参数设置
            rootDict.SetString("FacebookAppID", "949004278872387");
            rootDict.SetString("GoogleClientID", "554619719418-0hdrkdprcsksigpldvtr9n5lu2lvt5kn.apps.googleusercontent.com");
            rootDict.SetString("FacebookAppDisplayName", "少女的王座");
            rootDict.SetString("AIHelpAppID", "elextech_platform_15ce9b10-f784-4ab5-8ee4-45efab40bd6a");
            rootDict.SetString("AIHelpAppKey", "ELEXTECH_app_50dd4661c57843778d850769a02f8a09");
            rootDict.SetString("AIHelpDomain", "*****@*****.**");
            rootDict.SetString("AdjustAppToken", "1k2jm7bpansw");
            rootDict.SetString("AdjustAppSecret", "1,750848352-1884995334-181661496-1073918938");
            // Set encryption usage boolean
            string encryptKey = "ITSAppUsesNonExemptEncryption";
            rootDict.SetBoolean(encryptKey, false);
            // remove exit on suspend if it exists.ios13新增
            string exitsOnSuspendKey = "UIApplicationExitsOnSuspend";
            if (rootDict.values.ContainsKey(exitsOnSuspendKey))
            {
                rootDict.values.Remove(exitsOnSuspendKey);
            }
            // URL types配置
            PlistElementArray URLTypes = rootDict.CreateArray("CFBundleURLTypes");
            //Facebook
            PlistElementDict typeRoleFB = URLTypes.AddDict();
            typeRoleFB.SetString("CFBundleTypeRole", "Editor");
            PlistElementArray urlSchemeFB = typeRoleFB.CreateArray("CFBundleURLSchemes");
            urlSchemeFB.AddString("fb949004278872387");
            //Google
            PlistElementDict typeRole = URLTypes.AddDict();
            typeRole.SetString("CFBundleTypeRole", "Editor");
            typeRole.SetString("CFBundleURLName", "com.googleusercontent.apps.554619719418-0hdrkdprcsksigpldvtr9n5lu2lvt5kn");
            PlistElementArray urlScheme = typeRole.CreateArray("CFBundleURLSchemes");
            urlScheme.AddString("com.googleusercontent.apps.554619719418-0hdrkdprcsksigpldvtr9n5lu2lvt5kn");

            // LSApplicationQueriesSchemes配置
            PlistElementArray LSApplicationQueriesSchemes = rootDict.CreateArray("LSApplicationQueriesSchemes");
            // facebook接入配置
            LSApplicationQueriesSchemes.AddString("fbapi");
            LSApplicationQueriesSchemes.AddString("fb-messenger-share-api");
            LSApplicationQueriesSchemes.AddString("fbauth2");
            LSApplicationQueriesSchemes.AddString("fbshareextension");
            // Line接入配置
            LSApplicationQueriesSchemes.AddString("lineauth");
            LSApplicationQueriesSchemes.AddString("line3rdp.$(APP_IDENTIFIER)");
            LSApplicationQueriesSchemes.AddString("line");
            #endregion

            ProjectCapabilityManager projectCapabilityManager = new ProjectCapabilityManager(projPath, "tw.entitlements", PBXProject.GetUnityTargetName());
            projectCapabilityManager.AddGameCenter();
            projectCapabilityManager.AddInAppPurchase();
            plist.WriteToFile(plistPath);
            proj.WriteToFile(projPath);
            Debug.Log("--**--4.IOSXcodeSettings--**--");
        }