Ejemplo n.º 1
0
        private static void RunOptool(string optoolPath, string opToolCmd)
        {
#if UDL_DEBUG
            Debug.Log("UDL: optool | " + optoolPath + "  " + opToolCmd);
#endif

            ShellHelper.ShellRequest req = ShellHelper.ProcessFileCommand(optoolPath, opToolCmd);
            req.OnLog += delegate(int arg1, string arg2) { Debug.Log(arg2); };

            req.OnDone += delegate()
            {
                Debug.Log("Successfully injected framework on Build");
                _injectionComplete = true;
                BuildProcessor.TriggerOnPostBuildProcessCompleted();
            };

            req.OnError += delegate() { Debug.Log("Error injecting framework on Build"); };
        }
Ejemplo n.º 2
0
        private static void MacCopy(string universalDeepLinkFrameworkPath, string frameworkFolderPath)
        {
            var toolFile = "cp";

            var copyArguments = "-a"
                                + " "
                                + @"""" + universalDeepLinkFrameworkPath + @""""
                                + "  "
                                + @"""" + frameworkFolderPath + @"""";

            ShellHelper.ShellRequest req = ShellHelper.ProcessFileCommand(toolFile, copyArguments);

            req.OnLog += delegate(int arg1, string arg2) { Debug.Log(arg2); };

            req.OnDone += delegate() { Debug.Log("Copy UniversalDeepLink Framawork Completed"); };

            req.OnError += delegate() { Debug.Log("Error on UniversalDeepLink Copy Framework"); };
        }
Ejemplo n.º 3
0
        private void ExtractFrameworkAndAddItToXcode(string pathToBuiltProject)
        {
            //
            //  Extracts framework
            //
            const string frameworksDir = "Frameworks";
            //const string frameworksDir = "Plugins";
            var pathToExport2 = Path.Combine((GetMacOsProjectPath(pathToBuiltProject)), "Plugins");
            var pathToExport  = Directory.GetParent(GetMacOsProjectPath(pathToBuiltProject)).FullName;
            var pathToLib     = Path.Combine(Application.dataPath, EditorHelpers.PluginPath + "/libs/Standalone/UniversalDeepLink.framework.zip");


            ShellHelper.ShellRequest unzip = ShellHelper.ProcessFileCommand("unzip", string.Format("-o \"{0}\" -d \"{1}\"", pathToLib, pathToExport));
            //
            //  Remove this and remove the Copy file options from the pbxx
            //
            ShellHelper.ShellRequest _ = ShellHelper.ProcessFileCommand("unzip", string.Format("-o \"{0}\" -d \"{1}\"", pathToLib, pathToExport2));

            unzip.OnDone += () =>
            {
                string     projectPath = PBXProject.GetPBXProjectPath(_macOsXcodeProj);
                PBXProject project     = new PBXProject();
                project.ReadFromString(File.ReadAllText(projectPath));

                //
                //  Adds framework to pbx
                //
                var frameworkInProject = Path.Combine(Application.productName, frameworksDir);
                frameworkInProject = Path.Combine(frameworkInProject, FrameworkName);
                var prodGuid = project.TargetGuidByName(Application.productName);

                var myFramework = project.AddFile(FrameworkName, frameworkInProject, PBXSourceTree.Source);
                project.AddFileToBuild(prodGuid, myFramework);
                PBXProjectExtensions.AddFileToEmbedLibraries(project, prodGuid, myFramework);

                File.WriteAllText(projectPath, project.WriteToString());
                BuildProcessor.TriggerOnPostBuildProcessCompleted();
            };
        }
Ejemplo n.º 4
0
        private void InjectFrameworkInGameApp(string pathToBuiltProject)
        {
            _injectionComplete = false;
#if UDL_DEBUG
            Debug.Log("UDL: Injecting Lib");
#endif
            var workDirectory = Path.Combine(Application.dataPath,
                                             EditorHelpers.PluginPath + "/libs/Tools/");

            var optoolPath = Path.Combine(workDirectory, "optool");

            var executablePath = "\"@executable_path/../Frameworks/UniversalDeepLink.framework/Versions/A/UniversalDeepLink\"";

            var parentDir = Path.Combine(pathToBuiltProject, "Contents/MacOS/");

            string gameExec = GetGameExec(pathToBuiltProject, parentDir);

            var gameAppPath = @"""" + gameExec + @"""";

            string opToolCmd = "install -c load -p " + executablePath + " -t " + gameAppPath;

            ShellHelper.ShellRequest chmod = ShellHelper.ProcessFileCommand("chmod", "+x \"" + optoolPath + "\"");

            //var appDir = new DirectoryInfo(pathToBuiltProject).Name.Replace(".app", string.Empty);
            var pathToExport = Path.Combine(pathToBuiltProject, "Contents/Frameworks/");
            var pathToRemove = Path.Combine(pathToExport, "UniversalDeepLink.framework");
            var pathToLib    = Path.Combine(Application.dataPath, EditorHelpers.PluginPath + "/libs/Standalone/UniversalDeepLink.framework.zip");

#if UDL_DEBUG
            Debug.Log("UDL: chmod +x \"" + optoolPath + "\"");
#endif
            chmod.OnDone += () =>
            {
                ShellHelper.ShellRequest delete = ShellHelper.ProcessFileCommand("rm", " -r \"" + pathToRemove + "\"");
                delete.OnDone += () =>
                {
#if UDL_DEBUG
                    Debug.Log("UDL: unzip -o " + string.Format("-o \"{0}\" -d \"{1}\"", pathToLib, pathToExport));
#endif

                    ShellHelper.ShellRequest unzip = ShellHelper.ProcessFileCommand("unzip", string.Format("-o \"{0}\" -d \"{1}\"", pathToLib, pathToExport));

                    unzip.OnDone += () =>
                    {
                        RunOptool(optoolPath, opToolCmd);
                    };



                    unzip.OnError += () =>
                    {
                        Debug.Log("Error unzipping " + pathToRemove);
                    };
                };

                delete.OnError += () =>
                {
                    Debug.Log("Error deleting " + pathToRemove);
                };
            };

            //
            //  Wait until all commands execute
            //
            int maxSecsWait = 10;
            for (int i = 0; i < maxSecsWait && _injectionComplete == false; i++)
            {
                Thread.Sleep(1000);
                ShellHelper.Step();
            }
        }