private bool CanDrawTab(eSettingsType _tab)
        {
            Features _supportedFeatures = ((NPSettings)target).GetApplicationSettings().SupportedFeatures;

            switch (_tab)
            {
            case eSettingsType.BILLING_SETTINGS:
                return(_supportedFeatures.UsesBilling);

            case eSettingsType.CLOUD_SERVICES_SETTINGS:
                return(_supportedFeatures.UsesCloudServices);

            case eSettingsType.GAME_SERVICES_SETTINGS:
                return(_supportedFeatures.UsesGameServices);

            case eSettingsType.MEDIA_LIBRARY_SETTINGS:
                return(_supportedFeatures.UsesMediaLibrary);

            case eSettingsType.NETWORK_CONNECTVITY_SETTINGS:
                return(_supportedFeatures.UsesNetworkConnectivity);

            case eSettingsType.NOTIFICATION_SERVICE_SETTINGS:
                return(_supportedFeatures.UsesNotificationService);

            case eSettingsType.SOCIAL_NETWORK_SETTINGS:
                return(_supportedFeatures.UsesTwitter);

            default:
                break;
            }

            return(true);
        }
        private void UpdatePluginPlatforms(Features _supportedFeatures)
        {
                #if !UNITY_4
            foreach (PluginImporter plugin in PluginImporter.GetAllImporters())
            {
                if (plugin == null || Path.IsPathRooted(plugin.assetPath))                  // Skip null or inbuilt plugins
                {
                    continue;
                }

                string filename = Path.GetFileName(plugin.assetPath);

                if (plugin.assetPath.Contains(Constants.kAndroidPluginsPath))
                {
                    // Debug.Log("[Updating Plugin Properties] " + plugin.assetPath);
                    if (filename.Equals(Constants.kTwitterLibraryName))
                    {
                        plugin.SetCompatibleWithAnyPlatform(false);
                        plugin.SetCompatibleWithPlatform(BuildTarget.Android, _supportedFeatures.UsesTwitter);
                    }

                    if (filename.Equals(Constants.kYoutubeLibraryName))
                    {
                        plugin.SetCompatibleWithAnyPlatform(false);
                        plugin.SetCompatibleWithPlatform(BuildTarget.Android, _supportedFeatures.UsesMediaLibrary);
                    }
                }
            }
                #endif
        }
        private static void ExecutePostProcessAction(string buildPath)
        {
            // Load plist
            string _infoPlistFilePath = GetInfoPlistFilePath(buildPath);

            infoPlist = Plist.LoadPlistAtPath(_infoPlistFilePath);

            // Prepare project
            CleanupProject();
            CreateTempFolder();

            Features _supportedFeatures = NPSettings.Application.SupportedFeatures;

            if (_supportedFeatures.UsesTwitter)
            {
                DecompressTwitterSDKFiles();
            }

            if (_supportedFeatures.UsesBilling)
            {
                AddBuildInfoToBillingClass();
            }

            // execute actions specific to features used within app
            GenerateXcodeModFiles();
            UpdateInfoPlist(buildPath);
            ModifyPchFile(buildPath);

            // release properties
            infoPlist = null;
        }
        private void UpdateDefineSymbols()
        {
            Features      _supportedFeatures      = m_applicationSettings.SupportedFeatures;
            AddonServices _supportedAddonServices = m_applicationSettings.SupportedAddonServices;

                #if UNITY_ANDROID
            if (_supportedFeatures.UsesCloudServices && !_supportedFeatures.UsesGameServices)
            {
                string _error = "Cloud Services on Android needs Game Services feature to be enabled. Please enable Game Services now.";
                Debug.LogWarning("[Cross Platform Native Plugins] " + _error);
                EditorUtility.DisplayDialog("Cross Platform Native Plugins - Alert", _error, "Ok");
            }

                #if USES_BILLING
            if (string.IsNullOrEmpty(NPSettings.Billing.Android.PublicKey))
            {
                string _error = "Please specify Public key in Billing Settings for using Billing feature. You can get this key from Google Play Developer Console -> Your App -> Development & Tools -> Services & API -> Licensing & in-app billing.";
                Debug.LogWarning("[Cross Platform Native Plugins] " + _error);
            }
                #endif
                #endif

            BuildTargetGroup[] _buildTargets = GetBuildTargets();
            foreach (BuildTargetGroup _target in _buildTargets)
            {
                string[]      _curDefineSymbols = UnityPlayerSettings.GetScriptingDefineSymbolsForGroup(_target).Split(defineSeperators, StringSplitOptions.RemoveEmptyEntries);
                List <string> _newDefineSymbols = new List <string>(_curDefineSymbols);

                // Asset type
                #pragma warning disable
                if (kIsFullVersion)
                {
                    if (_newDefineSymbols.Contains(kLiteVersionMacro))
                    {
                        _newDefineSymbols.Remove(kLiteVersionMacro);
                    }
                }
                else
                {
                    if (!_newDefineSymbols.Contains(kLiteVersionMacro))
                    {
                        _newDefineSymbols.Add(kLiteVersionMacro);
                    }
                }
                #pragma warning restore

                // Regarding supported features
                AddOrRemoveFeatureDefineSymbol(_newDefineSymbols, _supportedFeatures.UsesAddressBook, kAddressBookMacro);
                AddOrRemoveFeatureDefineSymbol(_newDefineSymbols, _supportedFeatures.UsesBilling, kBillingMacro);
                AddOrRemoveFeatureDefineSymbol(_newDefineSymbols, _supportedFeatures.UsesCloudServices, kCloudServicesMacro);
                AddOrRemoveFeatureDefineSymbol(_newDefineSymbols, _supportedFeatures.UsesGameServices, kGameServicesMacro);
                AddOrRemoveFeatureDefineSymbol(_newDefineSymbols, _supportedFeatures.UsesMediaLibrary, kMediaLibraryMacro);
                AddOrRemoveFeatureDefineSymbol(_newDefineSymbols, _supportedFeatures.UsesNetworkConnectivity, kNetworkConnectivityMacro);
                AddOrRemoveFeatureDefineSymbol(_newDefineSymbols, _supportedFeatures.UsesNotificationService, kNotificationServiceMacro);
                AddOrRemoveFeatureDefineSymbol(_newDefineSymbols, _supportedFeatures.UsesSharing, kSharingMacro);
                AddOrRemoveFeatureDefineSymbol(_newDefineSymbols, _supportedFeatures.UsesTwitter, kTwitterMacro);
                AddOrRemoveFeatureDefineSymbol(_newDefineSymbols, _supportedFeatures.UsesWebView, kWebViewMacro);
                AddOrRemoveFeatureDefineSymbol(_newDefineSymbols, m_utilitySettings.RateMyApp.IsEnabled, kRateMyAppMacro);

                // Regarding supported addon features
                AddOrRemoveFeatureDefineSymbol(_newDefineSymbols, _supportedAddonServices.UsesSoomlaGrow, kMacroSoomlaGrowService);
                AddOrRemoveFeatureDefineSymbol(_newDefineSymbols, _supportedAddonServices.UsesOneSignal, kMacroOneSignalService);

                // Now save these changes
                UnityPlayerSettings.SetScriptingDefineSymbolsForGroup(_target, string.Join(";", _newDefineSymbols.ToArray()));
            }
        }
//		{
//			"Fabric": {
//				"APIKey": "{0}",
//				"Kits": [
//				    {
//					"KitInfo": {
//						"consumerKey": "",
//						"consumerSecret": ""
//					},
//					"KitName": "Twitter"
//				    }
//				    ]
//			}
//		}

        private static void UpdateInfoPlist(string buildPath)
        {
            Debug.Log("[PostProcessBuild] : ModifyInfoPlist : " + buildPath);

            Dictionary <string, object> _newPermissionsDict = new Dictionary <string, object>();

            // In this section, we add additional information required for proper functioning of used native features
            ApplicationSettings _applicationSettings = NPSettings.Application;
            Features            _supportedFeatures   = _applicationSettings.SupportedFeatures;

                        #if USES_TWITTER
            if (_supportedFeatures.UsesTwitter)
            {
                const string _kFabricKitRootKey = "Fabric";

                TwitterSettings _twitterSettings = NPSettings.SocialNetworkSettings.TwitterSettings;
                string          _fabricJsonStr   = string.Format(kFabricKitJsonStringFormat, _twitterSettings.ConsumerKey);

                IDictionary _fabricJsonDictionary = (IDictionary)JSONUtility.FromJSON(_fabricJsonStr);
                _newPermissionsDict[_kFabricKitRootKey] = _fabricJsonDictionary[_kFabricKitRootKey];
            }
                        #endif

            // In this section, we add extra flags required as per Apple guidelines
            if (_supportedFeatures.UsesNotificationService)
            {
                if (_supportedFeatures.NotificationService.usesRemoteNotification)
                {
                    const string _kUIBackgroundModesKey = "UIBackgroundModes";
                    IList        _backgroundModesList   = AddUniqueValues(sourceList: (IList)infoPlist.GetKeyPathValue(_kUIBackgroundModesKey),
                                                                          values: "remote-notification");
                    _newPermissionsDict[_kUIBackgroundModesKey] = _backgroundModesList;
                }
            }

            if (_supportedFeatures.UsesGameServices)
            {
                const string _kDeviceCapablitiesKey = "UIRequiredDeviceCapabilities";
                IList        _deviceCapablitiesList = AddUniqueValues(sourceList: (IList)infoPlist.GetKeyPathValue(_kDeviceCapablitiesKey),
                                                                      values: "gamekit");
                _newPermissionsDict[_kDeviceCapablitiesKey] = _deviceCapablitiesList;
            }

            if (_supportedFeatures.UsesSharing)
            {
                const string _kQuerySchemesKey   = "LSApplicationQueriesSchemes";
                IList        _queriesSchemesList = AddUniqueValues(sourceList: (IList)infoPlist.GetKeyPathValue(_kQuerySchemesKey),
                                                                   values: new string[] { "whatsapp", "fb", "twitter" });
                _newPermissionsDict[_kQuerySchemesKey] = _queriesSchemesList;
            }

            if (_supportedFeatures.UsesNetworkConnectivity || _supportedFeatures.UsesWebView)
            {
                const string _kATSKey            = "NSAppTransportSecurity";
                const string _karbitraryLoadsKey = "NSAllowsArbitraryLoads";

                IDictionary _transportSecurityDict = (IDictionary)infoPlist.GetKeyPathValue(_kATSKey);
                if (_transportSecurityDict == null)
                {
                    _transportSecurityDict = new Dictionary <string, object>();
                }

                _transportSecurityDict[_karbitraryLoadsKey] = true.ToString();
                _newPermissionsDict[_kATSKey] = _transportSecurityDict;
            }

            // Add privacy info
            const string _kPermissionContacts           = "NSContactsUsageDescription";
            const string _kPermissionCamera             = "NSCameraUsageDescription";
            const string _kPermissionPhotoLibrary       = "NSPhotoLibraryUsageDescription";
            const string _kPermissionModifyPhotoLibrary = "NSPhotoLibraryAddUsageDescription";

            if (_supportedFeatures.UsesAddressBook)
            {
                _newPermissionsDict[_kPermissionContacts] = _applicationSettings.IOS.AddressBookUsagePermissionDescription;
            }

            if (_supportedFeatures.UsesMediaLibrary)
            {
                if (_supportedFeatures.MediaLibrary.usesCamera)
                {
                    _newPermissionsDict[_kPermissionCamera] = _applicationSettings.IOS.CameraUsagePermissionDescription;
                }

                if (_supportedFeatures.MediaLibrary.usesPhotoAlbum)
                {
                    _newPermissionsDict [_kPermissionPhotoLibrary]       = _applicationSettings.IOS.PhotoAlbumUsagePermissionDescription;
                    _newPermissionsDict [_kPermissionModifyPhotoLibrary] = _applicationSettings.IOS.PhotoAlbumModifyUsagePermissionDescription;
                }
            }

            if (_supportedFeatures.UsesSharing)
            {
                _newPermissionsDict [_kPermissionModifyPhotoLibrary] = _applicationSettings.IOS.PhotoAlbumModifyUsagePermissionDescription;
            }

            if (_newPermissionsDict.Count == 0)
            {
                return;
            }

            // Create a backup of old plist
            string _infoPlistBackupSavePath = GetInfoPlistBackupFilePath(buildPath);
            infoPlist.Save(_infoPlistBackupSavePath);

            // Save the plist with new permissions
            foreach (string _key in _newPermissionsDict.Keys)
            {
                infoPlist.AddValue(_key, _newPermissionsDict[_key]);
            }

            string _infoPlistSavePath = GetInfoPlistFilePath(buildPath);
            infoPlist.Save(_infoPlistSavePath);
        }
        private static void     GenerateXcodeModFiles()
        {
            string _modDataStr = File.ReadAllText(kRelativePathXcodeModDataCollectionFile);

            if (_modDataStr == null)
            {
                throw new System.IO.FileNotFoundException("Couldn't find mod data file.");
            }

            // create mod file related to supported features
            Dictionary <string, object> _modDataDict = (Dictionary <string, object>)JSONUtility.FromJSON(_modDataStr);
            Features      _supportedFeatures         = NPSettings.Application.SupportedFeatures;
            AddonServices _supportedAddonServices    = NPSettings.Application.SupportedAddonServices;

            ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeyCommon, kRelativePathIOSNativeCodeFolder);

            if (_supportedFeatures.UsesAddressBook)
            {
                ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeyAddressBook, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesBilling)
            {
                ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeyBilling, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesCloudServices)
            {
                ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeyCloudServices, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesGameServices)
            {
                ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeyGameServices, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesMediaLibrary)
            {
                ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeyMediaLibrary, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesNetworkConnectivity)
            {
                ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeyNetworkConnectivity, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesNotificationService)
            {
                ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeyNotification, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesSharing)
            {
                ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeySharing, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesTwitter)
            {
                ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeyTwitter, kRelativePathIOSNativeCodeFolder);
                ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeyTwitterSDK, kRelativePathNativePluginsSDKFolder);
            }

            if (_supportedFeatures.UsesWebView)
            {
                ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeyWebView, kRelativePathIOSNativeCodeFolder);
            }

            // Create mod file related to supported addon features
            if (_supportedAddonServices.UsesSoomlaGrow)
            {
                ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeySoomlaGrow, kRelativePathIOSNativeCodeFolder);
            }

            if (NPSettings.Utility.RateMyApp.IsEnabled)
            {
                ExtractAndSerializeXcodeModInfo(_modDataDict, kModKeyStoreReview, kRelativePathIOSNativeCodeFolder);
            }
        }