Skip to content

Commit a01ea30

Browse files
committed
this might fix the hanging issue on iOS 18+, needs more testing.
1 parent a93e165 commit a01ea30

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

MuffinStoreJailed/Downgrader.swift

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ import Foundation
99
import UIKit
1010
import Telegraph
1111
import Zip
12+
import SwiftUI
13+
import SafariServices
14+
15+
struct SafariWebView: UIViewControllerRepresentable {
16+
let url: URL
17+
18+
func makeUIViewController(context: Context) -> SFSafariViewController {
19+
return SFSafariViewController(url: url)
20+
}
21+
22+
func updateUIViewController(_ uiViewController: SFSafariViewController, context: Context) {
23+
}
24+
}
1225

1326
func downgradeAppToVersion(appId: String, versionId: String, ipaTool: IPATool) {
1427
let path = ipaTool.downloadIPAForVersion(appId: appId, appVerId: versionId)
@@ -35,6 +48,9 @@ func downgradeAppToVersion(appId: String, versionId: String, ipaTool: IPATool) {
3548
let appVersion = infoPlist["CFBundleShortVersionString"] as! String
3649
print("appBundleId: \(appBundleId)")
3750
print("appVersion: \(appVersion)")
51+
52+
let finalURL = "https://api.palera.in/genPlist?bundleid=\(appBundleId)&name=\(appBundleId)&version=\(appVersion)&fetchurl=http://127.0.0.1:9090/signed.ipa"
53+
let installURL = "itms-services://?action=download-manifest&url=" + finalURL.addingPercentEncoding(withAllowedCharacters: .alphanumerics)!
3854

3955
DispatchQueue.global(qos: .background).async {
4056
let server = Server()
@@ -44,15 +60,31 @@ func downgradeAppToVersion(appId: String, versionId: String, ipaTool: IPATool) {
4460
let signedIPAData = try Data(contentsOf: destinationUrl)
4561
return HTTPResponse(body: signedIPAData)
4662
})
63+
64+
server.route(.GET, "install", { _ in
65+
print("Serving install page")
66+
let installPage = """
67+
<script type="text/javascript">
68+
window.location = "\(installURL)"
69+
</script>
70+
"""
71+
return HTTPResponse(.ok, headers: ["Content-Type": "text/html"], content: installPage)
72+
})
4773

4874
try! server.start(port: 9090)
4975
print("Server has started listening")
5076

5177
DispatchQueue.main.async {
5278
print("Requesting app install")
53-
let finalURL = "https://api.palera.in/genPlist?bundleid=\(appBundleId)&name=\(appBundleId)&version=\(appVersion)&fetchurl=http://127.0.0.1:9090/signed.ipa"
54-
let finalURLfr = "itms-services://?action=download-manifest&url=" + finalURL.addingPercentEncoding(withAllowedCharacters: .alphanumerics)!
55-
UIApplication.shared.open(URL(string: finalURLfr)!)
79+
let majoriOSVersion = Int(UIDevice.current.systemVersion.components(separatedBy: ".").first!)!
80+
if majoriOSVersion >= 18 {
81+
// iOS 18+ ( idk why this is needed but it seems to fix it for some people )
82+
let safariView = SafariWebView(url: URL(string: "http://127.0.0.1:9090/install")!)
83+
UIApplication.shared.windows.first?.rootViewController?.present(UIHostingController(rootView: safariView), animated: true, completion: nil)
84+
} else {
85+
// iOS 17-
86+
UIApplication.shared.open(URL(string: installURL)!)
87+
}
5688
}
5789

5890
while server.isRunning {

0 commit comments

Comments
 (0)