From 502a5488b020b6d34540fb98ad3d09a1a80d3cbe Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Thu, 12 Sep 2019 13:04:15 -0700 Subject: [PATCH] Adds support for installing AltStore beta from AltStore --- AltStore/Info.plist | 16 ++++------------ AltStore/Managing Apps/AppManager.swift | 2 +- AltStore/Model/App.swift | 10 ++++++++++ AltStore/My Apps/MyAppsViewController.swift | 9 ++++++++- AltStore/Operations/ResignAppOperation.swift | 2 +- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/AltStore/Info.plist b/AltStore/Info.plist index a9e93ab1..2cb241ae 100644 --- a/AltStore/Info.plist +++ b/AltStore/Info.plist @@ -22,16 +22,6 @@ 0.2 CFBundleURLTypes - - CFBundleTypeRole - Editor - CFBundleURLName - AltStore - CFBundleURLSchemes - - altstore-com.rileytestut.altstore - - CFBundleTypeRole Editor @@ -48,9 +38,11 @@ LSApplicationQueriesSchemes altstore-com.rileytestut.AltStore - altstore-com.rileytestut.Delta - altstore-com.rileytestut.Clip altstore-com.rileytestut.AltStore.Beta + altstore-com.rileytestut.Delta + altstore-com.rileytestut.Delta.Beta + altstore-com.rileytestut.Clip + altstore-com.rileytestut.Clip.Beta LSRequiresIPhoneOS diff --git a/AltStore/Managing Apps/AppManager.swift b/AltStore/Managing Apps/AppManager.swift index 426f89b7..f46c5a9b 100644 --- a/AltStore/Managing Apps/AppManager.swift +++ b/AltStore/Managing Apps/AppManager.swift @@ -52,7 +52,7 @@ extension AppManager do { let installedApps = try context.fetch(fetchRequest) - for app in installedApps where app.storeApp != nil + for app in installedApps where app.storeApp != nil && app.bundleIdentifier != StoreApp.altstoreAppID { if UIApplication.shared.canOpenURL(app.openAppURL) { diff --git a/AltStore/Model/App.swift b/AltStore/Model/App.swift index 00e9ad58..875409cf 100644 --- a/AltStore/Model/App.swift +++ b/AltStore/Model/App.swift @@ -14,7 +14,13 @@ import AltSign extension StoreApp { + #if BETA + static let altstoreAppID = "com.rileytestut.AltStore.Beta" + static let alternativeAltStoreAppID = "com.rileytestut.AltStore" + #else static let altstoreAppID = "com.rileytestut.AltStore" + static let alternativeAltStoreAppID = "com.rileytestut.AltStore.Beta" + #endif } @objc(StoreApp) @@ -139,6 +145,10 @@ extension StoreApp app.versionDate = Date() app.downloadURL = URL(string: "http://rileytestut.com")! + #if BETA + app.isBeta = true + #endif + return app } } diff --git a/AltStore/My Apps/MyAppsViewController.swift b/AltStore/My Apps/MyAppsViewController.swift index fb0c16ed..4e7d9c82 100644 --- a/AltStore/My Apps/MyAppsViewController.swift +++ b/AltStore/My Apps/MyAppsViewController.swift @@ -84,6 +84,10 @@ class MyAppsViewController: UICollectionViewController self.sideloadingProgressView.progressTintColor = .altRed self.sideloadingProgressView.progress = 0 + #if !BETA + self.navigationItem.leftBarButtonItem = nil + #endif + if let navigationBar = self.navigationController?.navigationBar { navigationBar.addSubview(self.sideloadingProgressView) @@ -313,7 +317,10 @@ private extension MyAppsViewController } else { - self.dataSource.predicate = NSPredicate(format: "%K == nil OR %K == NO", #keyPath(InstalledApp.storeApp), #keyPath(InstalledApp.storeApp.isBeta)) + self.dataSource.predicate = NSPredicate(format: "%K == nil OR %K == NO OR %K == %@", + #keyPath(InstalledApp.storeApp), + #keyPath(InstalledApp.storeApp.isBeta), + #keyPath(InstalledApp.bundleIdentifier), StoreApp.altstoreAppID) } } } diff --git a/AltStore/Operations/ResignAppOperation.swift b/AltStore/Operations/ResignAppOperation.swift index 3bbd0ae0..61e9c612 100644 --- a/AltStore/Operations/ResignAppOperation.swift +++ b/AltStore/Operations/ResignAppOperation.swift @@ -395,7 +395,7 @@ private extension ResignAppOperation var additionalValues: [String: Any] = [Bundle.Info.urlTypes: allURLSchemes] - if self.context.bundleIdentifier == StoreApp.altstoreAppID + if self.context.bundleIdentifier == StoreApp.altstoreAppID || self.context.bundleIdentifier == StoreApp.alternativeAltStoreAppID { guard let udid = Bundle.main.object(forInfoDictionaryKey: Bundle.Info.deviceID) as? String else { throw OperationError.unknownUDID } additionalValues[Bundle.Info.deviceID] = udid