예제 #1
0
        public static void Uninstall()
        {
            bool _startUninstall = EditorUtility.DisplayDialog(kUninstallAlertTitle, kUninstallAlertMessage, "Uninstall", "Cancel");

            if (_startUninstall)
            {
                foreach (string _eachFolder in kPluginFolders)
                {
                    string _absolutePath = AssetsUtility.AssetPathToAbsolutePath(_eachFolder);

                    if (Directory.Exists(_absolutePath))
                    {
                        Directory.Delete(_absolutePath, true);

                        // Delete meta files.
                        FileOperations.Delete(_absolutePath + ".meta");
                    }
                }

                // For LITE version we need to remove defines.
                GlobalDefinesManager _definesManager = new GlobalDefinesManager();

                foreach (int _eachCompiler in System.Enum.GetValues(typeof(GlobalDefinesManager.eCompiler)))
                {
                    _definesManager.RemoveDefineSymbol((GlobalDefinesManager.eCompiler)_eachCompiler, NPSettings.kLiteVersionMacro);
                }

                _definesManager.SaveAllCompilers();

                AssetDatabase.Refresh();
                EditorUtility.DisplayDialog("Cross Platform Native Plugins",
                                            "Uninstall successful!",
                                            "Ok");
            }
        }
예제 #2
0
        private static void CleanAndResetProject()
        {
            // Remove old xmod files
            string _nativeCodePath = AssetsUtility.AssetPathToAbsolutePath(kRelativePathIOSNativeCodeFolder);

            string[] _modFiles = Directory.GetFiles(_nativeCodePath, "*.xcodemods", SearchOption.AllDirectories);

            foreach (string _curFile in _modFiles)
            {
                File.SetAttributes(_curFile, FileAttributes.Normal);
                File.Delete(_curFile);
            }

            // Remove old NP files which are placed outside Assets path
            if (Directory.Exists(kRelativePathNativePluginsTempFolder))
            {
                IOExtensions.AssignPermissionRecursively(kRelativePathNativePluginsTempFolder, FileAttributes.Normal);
                Directory.Delete(kRelativePathNativePluginsTempFolder, true);
            }

            // Create new folder
            Directory.CreateDirectory(kRelativePathNativePluginsTempFolder);
        }
예제 #3
0
        private static void CleanupProject()
        {
            // Remove xmod files
            string _nativeCodePath = AssetsUtility.AssetPathToAbsolutePath(kRelativePathIOSNativeCodeFolder);

            string[] _modFiles = Directory.GetFiles(_nativeCodePath, "*.xcodemods", SearchOption.AllDirectories);

            foreach (string _filePath in _modFiles)
            {
                // Delete file
                File.SetAttributes(_filePath, FileAttributes.Normal);
                File.Delete(_filePath);

                // Delete meta file
                string _metaFilePath = _filePath + ".meta";

                if (File.Exists(_metaFilePath))
                {
                    File.SetAttributes(_metaFilePath, FileAttributes.Normal);
                    File.Delete(_metaFilePath);
                }
            }
        }
예제 #4
0
        private static void AddTwitterFilesToProject()
        {
            string _twitterNativeFolder = AssetsUtility.AssetPathToAbsolutePath(kRelativePathToTwitterNativeFiles);
            string _twitterConfileFile  = Path.Combine(_twitterNativeFolder, "Config.txt");

            // Re move the files if version has changed
            if (File.Exists(_twitterConfileFile))
            {
                string _fileVersion = File.ReadAllText(_twitterConfileFile);

                if (string.Compare(_fileVersion, EditorPrefs.GetString(kTwitterConfigKey, "0")) == 0)
                {
                    return;
                }

                EditorPrefs.SetString(kTwitterConfigKey, _fileVersion);
            }

            // Start moving files and framework
            string _projectPath           = AssetsUtility.GetProjectPath();
            string _twitterExternalFolder = Path.Combine(_projectPath, kExtenalFolderRelativePath + "/Twitter");

            if (Directory.Exists(_twitterExternalFolder))
            {
                Directory.Delete(_twitterExternalFolder, true);
            }

            Directory.CreateDirectory(_twitterExternalFolder);

            List <string> _twitterFilesList  = new List <string>();
            List <string> _twitterFolderList = new List <string>();

            // ***********************
            // Source code section
            // ***********************
            string _nativeCodeSourceFolder = Path.Combine(_twitterNativeFolder, "Source");
            string _nativeCodeDestFolder   = Path.Combine(_twitterExternalFolder, "Source");

            // Copying folder
            IOExtensions.CopyFilesRecursively(_nativeCodeSourceFolder, _nativeCodeDestFolder);

            // Adding source folder to modifier
            _twitterFolderList.Add("Twitter/Source:-fno-objc-arc");

            // ***********************
            // Framework Section
            // ***********************
            string[] _zippedFrameworkFiles = Directory.GetFiles(_twitterNativeFolder, "*.gz", SearchOption.AllDirectories);
            string   _destFrameworkFolder  = Path.Combine(_twitterExternalFolder, "Framework");

            if (!Directory.Exists(_destFrameworkFolder))
            {
                Directory.CreateDirectory(_destFrameworkFolder);
            }

            // Iterate through each zip files
            foreach (string _curZippedFile in _zippedFrameworkFiles)
            {
                Zip.DecompressToDirectory(_curZippedFile, _destFrameworkFolder);

                // Adding file to modifier
                _twitterFilesList.Add("Twitter/Framework/" + Path.GetFileNameWithoutExtension(_curZippedFile));
            }

            // ***********************
            // Xcode modifier Section
            // ***********************
            Dictionary <string, object> _xcodeModDict = new Dictionary <string, object>();

            _xcodeModDict["group"]      = "NativePlugins-Twitter";
            _xcodeModDict["libs"]       = new string[0];
            _xcodeModDict["frameworks"] = new string[] {
                "Accounts.framework:weak",
                "Social.framework:weak"
            };
            _xcodeModDict["headerpaths"] = new string[0];
            _xcodeModDict["files"]       = _twitterFilesList;
            _xcodeModDict["folders"]     = _twitterFolderList;
            _xcodeModDict["excludes"]    = new string[] {
                "^.*.meta$",
                "^.*.mdown$",
                "^.*.pdf$",
                "^.*.DS_Store"
            };
            _xcodeModDict["compiler_flags"] = new string[0];
            _xcodeModDict["linker_flags"]   = new string[0];

            File.WriteAllText(GetTwitterXcodeModFilePath(), _xcodeModDict.ToJSON());
        }