Exemple #1
0
        public static bool SignIpa(string path)
        {
            if (!File.Exists(Path.Combine(Program.DeveloperPath, "key.pem")))
            {
                File.Copy(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tools/developer/readme"), Path.Combine(Program.DeveloperPath, "readme"), true);
                Extensions.ShowMessage(MessageType.Error, "Cannot codesign application", "No certificate found in " + Program.DeveloperPath + ".\nRead README for information about how to place them.");
                return(false);
            }

            Program.WinInstance.StateLabel.Text = "Signing IPA";
            if (File.Exists(Path.Combine(Project.Path, "build/" + Project.Name + ".ipa")))
            {
                File.Delete(Path.Combine(Project.Path, "build/" + Project.Name + ".ipa"));
            }

            var process = Extensions.GetProcess(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tools/helper/sign-ipa"), string.Format("-m {4} -c {3} -k {2} -o {1} {0}",
                                                                                                                                                                      "'" + path + "'",
                                                                                                                                                                      "'" + Path.Combine(Project.Path, "build/" + Project.Name + ".ipa'"),
                                                                                                                                                                      "'" + Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tools/developer/key.pem'"),
                                                                                                                                                                      "'" + Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tools/developer/certificate.pem'"),
                                                                                                                                                                      "'" + Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tools/developer/provision-profile.mobileprovision'")
                                                                                                                                                                      ));

            int i = Program.WinInstance.Output.Run(process, (int)ActionCategory.Sideload);

            Program.WinInstance.ProgressBar.Fraction += Program.WinInstance.ProgressBar.PulseStep;

            return(i == 0);
        }
Exemple #2
0
        public static bool BuildProject()
        {
            if (!Directory.Exists(Program.SDKPath) || !Directory.EnumerateFileSystemEntries(Program.SDKPath).Any())
            {
                Extensions.ShowMessage(MessageType.Error, "Cannot build application", "SDK path is empty, add SDK to " + Program.SDKPath);
                return(false);
            }

            var cachedir = Path.Combine(Project.Path, ".icode");

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

            Directory.CreateDirectory(cachedir);
            string s = "";

            Program.WinInstance.ProgressBar.PulseStep = 1.0d / (double)(((double)Project.Classes.Count(c => c.Filename.EndsWith(".m", StringComparison.CurrentCulture))) + 2d);

            if (Project.Classes.Any((arg) => arg.Filename.EndsWith(".swift", StringComparison.CurrentCultureIgnoreCase)))
            {
                Extensions.ShowMessage(MessageType.Error, "Cannot build.", "Swift is not supported for the moment.");
            }

            foreach (var @class in from c in Project.Classes where !c.Filename.EndsWith(".h", StringComparison.CurrentCultureIgnoreCase) select c)
            {
                Program.WinInstance.StateLabel.Text = "Building " + @class;
                Directory.CreateDirectory(Path.Combine(cachedir, "build"));
                var flags = string.Join(" ", Flags) + " -c " + string.Join(" ", @class.CompilerFlags) + " ";
                var proc  = Extensions.GetProcess("clang", flags + "'" + Path.Combine(Project.Path, @class.Filename) + "' -o '" + Path.Combine(cachedir, "build", @class.Filename + ".output") + "'");
                if (Program.WinInstance.Output.Run(proc, (int)ActionCategory.Make) != 0)
                {
                    return(false);
                }
                s += "'" + Path.Combine(cachedir, "build", @class.Filename + ".output") + "' ";
                Program.WinInstance.ProgressBar.Fraction += Program.WinInstance.ProgressBar.PulseStep;
            }
            Program.WinInstance.StateLabel.Text = "Linking";
            Directory.CreateDirectory(Path.Combine(Project.Path, ".icode/Payload/" + Project.Name + ".app/"));
            var process = Extensions.GetProcess("clang", @"-target '" + Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tools/target/arm64-apple-darwin14") + "' -framework " + string.Join(" -framework ", Project.Frameworks) + " -isysroot '" + Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tools/sdk") + "' -arch arm64 -o '" + Path.Combine(Project.Path, ".icode/Payload/" + Project.Name + ".app/" + Project.Name) + "' " + s);

            if (Program.WinInstance.Output.Run(process, (int)ActionCategory.Link) != 0)
            {
                return(false);
            }

            Program.WinInstance.ProgressBar.Fraction += Program.WinInstance.ProgressBar.PulseStep;
            Program.WinInstance.StateLabel.Text       = "Packing IPA";
            foreach (var f in Directory.GetFiles(Path.Combine(Project.Path, "Resources")))
            {
                File.Copy(f, Path.Combine(Project.Path, ".icode/Payload/" + Project.Name + ".app/"));
            }

            Directory.Delete(Path.Combine(cachedir, "build"), true);

            if (!Directory.Exists(Path.Combine(Project.Path, "build")))
            {
                Directory.CreateDirectory(Path.Combine(Project.Path, "build"));
            }

            if (File.Exists(Path.Combine(Project.Path, "build/" + Project.Name + "-unsigned.ipa")))
            {
                File.Delete(Path.Combine(Project.Path, "build/" + Project.Name + "-unsigned.ipa"));
            }

            ZipFile.CreateFromDirectory(cachedir, Path.Combine(Project.Path, "build/" + Project.Name + "-unsigned.ipa"));
            return(SignIpa(Path.Combine(Project.Path, "build/" + Project.Name + "-unsigned.ipa")));
        }