App builds in xcodeproj (todo widget)

This commit is contained in:
Joe Mattiello
2023-03-02 00:40:11 -05:00
parent 4c9c5b1a56
commit f49fa24743
49 changed files with 498 additions and 295 deletions

View File

@@ -10,6 +10,7 @@ import UIKit
import SideStoreCore
import RoxasUIKit
import os.log
import Nuke
@@ -156,7 +157,7 @@ private extension AppContentViewController {
cell.imageView.image = image
if let error = error {
print("Error loading image:", error)
os_log("Error loading image: %@", type: .error, error.localizedDescription)
}
}

View File

@@ -9,6 +9,7 @@
import Foundation
import SideStoreCore
import Intents
import os.log
@available(iOS 14, *)
public final class IntentHandler: NSObject, RefreshAllIntentHandling {
@@ -107,7 +108,7 @@ private extension IntentHandler {
} catch RefreshError.noInstalledApps {
self.finish(intent, response: RefreshAllIntentResponse(code: .success, userActivity: nil))
} catch let error as NSError {
print("Failed to refresh apps in background.", error)
os_log("Failed to refresh apps in background. %@", type: .error , error.localizedDescription)
self.finish(intent, response: RefreshAllIntentResponse.failure(localizedDescription: error.localizedFailureReason ?? error.localizedDescription))
}

View File

@@ -9,14 +9,17 @@
import Intents
import Shared
import SideStoreCore
import os.log
@available(iOS 14, *)
public class ViewAppIntentHandler: NSObject, ViewAppIntentHandling {
public func provideAppOptionsCollection(for _: ViewAppIntent, with completion: @escaping (INObjectCollection<App>?, Error?) -> Void) {
public func provideAppOptionsCollection(for intent: ViewAppIntent, with completion: @escaping (INObjectCollection<App>?, Error?) -> Void) {
DatabaseManager.shared.start { error in
if let error = error {
print("Error starting extension:", error)
}
os_log("Error starting extension: %@", type: .error , error.localizedDescription)
} else {
os_log("Started extension: %@", type: .info , intent.debugDescription)
}
DatabaseManager.shared.persistentContainer.performBackgroundTask { context in
let apps = InstalledApp.all(in: context).map { installedApp in

View File

@@ -9,6 +9,7 @@
import UIKit
import RoxasUIKit
import os.log
import Nuke
@@ -68,7 +69,7 @@ private extension BrowseCollectionViewCell {
cell.imageView.image = image
if let error = error {
print("Error loading image:", error)
os_log("Error loading image: %@", type: .error , error.localizedDescription)
}
}

View File

@@ -10,6 +10,7 @@ import UIKit
import SideStoreCore
import RoxasUIKit
import os.log
import Nuke
@@ -140,7 +141,7 @@ private extension BrowseViewController {
cell.bannerView.iconImageView.image = image
if let error = error {
print("Error loading image:", error)
os_log("Error loading image: %@", type: .error , error.localizedDescription)
}
}
@@ -240,7 +241,7 @@ private extension BrowseViewController {
let toastView = ToastView(error: error)
toastView.show(in: self)
case .success: print("Installed app:", app.bundleIdentifier)
case .success: os_log("Installed app: %@", type: .info , app.bundleIdentifier)
}
self.collectionView.reloadItems(at: [indexPath])

View File

@@ -7,6 +7,7 @@
//
import Foundation
import os.log
extension FileManager {
func directorySize(at directoryURL: URL) -> Int? {
@@ -21,7 +22,7 @@ extension FileManager {
total += fileSize
} catch {
print("Failed to read file size for item: \(fileURL).", error)
os_log("Failed to read file size for item: %@. %@", type: .error, fileURL.absoluteString, error.localizedDescription)
}
}

View File

@@ -19,6 +19,7 @@ import AltSign
import SideKit
import SideStoreCore
import RoxasUIKit
import os.log
public extension AppManager {
static let didFetchSourceNotification = Notification.Name("io.altstore.AppManager.didFetchSource")
@@ -166,7 +167,7 @@ public extension AppManager {
try context.save()
} catch {
print("Error while fetching installed apps.", error)
os_log("Error while fetching installed apps. %@", type: .error , error.localizedDescription)
}
#endif
@@ -182,15 +183,15 @@ public extension AppManager {
guard let isDirectory = resourceValues.isDirectory, let bundleID = resourceValues.name else { continue }
if isDirectory && !installedAppBundleIDs.contains(bundleID) && !self.isActivelyManagingApp(withBundleID: bundleID) {
print("DELETING CACHED APP:", bundleID)
os_log("DELETING CACHED APP: %@", type: .info , bundleID)
try FileManager.default.removeItem(at: appDirectory)
}
} catch {
print("Failed to remove cached app directory.", error)
os_log("Failed to remove cached app directory. %@", type: .error , error.localizedDescription)
}
}
} catch {
print("Failed to remove cached apps.", error)
os_log("Failed to remove cached apps. %@", type: .error , error.localizedDescription)
}
}
}
@@ -350,7 +351,7 @@ public extension AppManager {
{
let authenticationOperation = self.authenticate(presentingViewController: nil) { (result) in
// result contains name, email, auth token, OTP and other possibly personal/account specific info. we don't want this logged
//print("Authenticated for fetching App IDs with result:", result)
//os_log("Authenticated for fetching App IDs with result: %@", type: .info , result)
}
let fetchAppIDsOperation = FetchAppIDsOperation(context: authenticationOperation.context)
@@ -382,7 +383,7 @@ public extension AppManager {
try result.get()
self.updatePatronsResult = .success(())
} catch {
print("Error updating Friend Zone Patrons:", error)
os_log("Error updating Friend Zone Patrons: %@", type: .error , error.localizedDescription)
self.updatePatronsResult = .failure(error)
}
@@ -564,7 +565,7 @@ public extension AppManager {
removeAppBackupOperation.resultHandler = { result in
switch result {
case .success: break
case let .failure(error): print("Failed to remove app backup.", error)
case let .failure(error): os_log("Failed to remove app backup. %@", type: .error , error.localizedDescription)
}
// Throw the error from removeAppOperation,
@@ -664,7 +665,7 @@ public extension AppManager {
public extension AppManager {
@discardableResult
public func backgroundRefresh(_ installedApps: [InstalledApp], presentsNotifications: Bool = false, completionHandler: @escaping (Result<[String: Result<InstalledApp, Error>], Error>) -> Void) -> BackgroundRefreshAppsOperation {
func backgroundRefresh(_ installedApps: [InstalledApp], presentsNotifications: Bool = false, completionHandler: @escaping (Result<[String: Result<InstalledApp, Error>], Error>) -> Void) -> BackgroundRefreshAppsOperation {
let backgroundRefreshAppsOperation = BackgroundRefreshAppsOperation(installedApps: installedApps)
backgroundRefreshAppsOperation.resultHandler = completionHandler
backgroundRefreshAppsOperation.presentsFinishedNotification = presentsNotifications
@@ -1185,7 +1186,7 @@ private extension AppManager {
switch result {
case let .failure(error):
// Don't report error, since it doesn't really matter.
print("Failed to delete app backup.", error)
os_log("Failed to delete app backup. %@", type: .error , error.localizedDescription)
case .success: break
}
@@ -1383,7 +1384,7 @@ private extension AppManager {
let bundleIcons = ["CFBundlePrimaryIcon": ["CFBundleIconFiles": [iconFileURL.lastPathComponent]]]
infoDictionary["CFBundleIcons"] = bundleIcons
} catch {
print("Failed to write app icon data.", error)
os_log("Failed to write app icon data. %@", type: .error , error.localizedErrorCode)
}
}
}
@@ -1473,7 +1474,7 @@ private extension AppManager {
WidgetCenter.shared.reloadAllTimelines()
}
do { try installedApp.managedObjectContext?.save() } catch { print("Error saving installed app.", error) }
do { try installedApp.managedObjectContext?.save() } catch { os_log("Error saving installed app. %@", type: .error, error.localizedDescription) }
} catch {
group.set(.failure(error), forAppWithBundleIdentifier: operation.bundleIdentifier)
@@ -1527,7 +1528,11 @@ private extension AppManager {
_ = LoggedError(error: sanitizedError, app: app, operation: loggedErrorOperation, context: context)
try context.save()
} catch let saveError {
print("[ALTLog] Failed to log error \(sanitizedError.domain) code \(sanitizedError.code) for \(app.bundleIdentifier):", saveError)
os_log("[ALTLog] Failed to log error %@ code %@ for %@: %@", type: .error,
sanitizedError.domain,
sanitizedError.code,
app.bundleIdentifier,
saveError.localizedErrorCode)
}
}
}

View File

@@ -14,6 +14,7 @@ import UIKit
import AltSign
import SideStoreCore
import RoxasUIKit
import os.log
import Nuke
@@ -242,7 +243,7 @@ private extension MyAppsViewController {
cell.bannerView.iconImageView.image = image
if let error = error {
print("Error loading image:", error)
os_log("Error loading image: %@", type: .error , error.localizedDescription)
}
}
@@ -442,7 +443,7 @@ private extension MyAppsViewController {
let (_, context) = try result.get()
try context.save()
} catch {
print("Failed to fetch App IDs.", error)
os_log("Failed to fetch App IDs. %@", type: .error , error.localizedDescription)
}
}
}
@@ -575,7 +576,7 @@ private extension MyAppsViewController {
let interaction = INInteraction.refreshAllApps()
interaction.donate { error in
guard let error = error else { return }
print("Failed to donate intent \(interaction.intent).", error)
os_log("Failed to donate intent %@ . %@", type: .error , interaction.intent, error.localizedDescription)
}
}
}
@@ -605,7 +606,7 @@ private extension MyAppsViewController {
self.collectionView.reloadItems(at: [indexPath])
case .success:
print("Updated app:", installedApp.bundleIdentifier)
os_log("Updated app: %@", type: .info , installedApp.bundleIdentifier)
// No need to reload, since the the update cell is gone now.
}
@@ -774,7 +775,7 @@ private extension MyAppsViewController {
completion(.success(()))
app.managedObjectContext?.perform {
print("Successfully installed app:", app.bundleIdentifier)
os_log("Successfully installed app: %@", type: .info , app.bundleIdentifier)
}
case .failure(OperationError.cancelled):
@@ -900,7 +901,15 @@ private extension MyAppsViewController {
}
}
print("Finished refreshing with results:", results.map { ($0, $1.error?.localizedDescription ?? "success") })
let errors = results.filter({ $1.error != nil }).map{ ($0, $1.error?.localizedDescription ?? "no description") }
let successes = results.filter({ $1.error == nil }).map{ ($0, "success") }
if !errors.isEmpty {
os_log("Finished refreshing Errors: %@", type: .error, errors.map { "\($0.0) - \($0.1)" }.joined(separator: "\n"))
}
if !successes.isEmpty {
os_log("Finished refreshing success: %@", type: .info, successes.map { "\($0.0) - \($0.1)" }.joined(separator: "\n"))
}
}
}
@@ -914,7 +923,7 @@ private extension MyAppsViewController {
} catch OperationError.cancelled {
// Ignore
} catch {
print("Failed to activate app:", error)
os_log("Failed to activate app: %@", type: .error , error.localizedDescription)
DispatchQueue.main.async {
installedApp.isActive = false
@@ -977,9 +986,9 @@ private extension MyAppsViewController {
let app = try result.get()
try? app.managedObjectContext?.save()
print("Finished deactivating app:", app.bundleIdentifier)
os_log("Finished deactivating app: %@", type: .info , app.bundleIdentifier)
} catch {
print("Failed to activate app:", error)
os_log("Failed to activate app: %@", type: .error , error.localizedDescription)
DispatchQueue.main.async {
installedApp.isActive = true
@@ -1035,9 +1044,9 @@ private extension MyAppsViewController {
let app = try result.get()
try? app.managedObjectContext?.save()
print("Finished backing up app:", app.bundleIdentifier)
os_log("Finished backing up app: %@", type: .info , app.bundleIdentifier)
} catch {
print("Failed to back up app:", error)
os_log("Failed to back up app: %@", type: .error , error.localizedDescription)
DispatchQueue.main.async {
let toastView = ToastView(error: error)
@@ -1066,9 +1075,9 @@ private extension MyAppsViewController {
let app = try result.get()
try? app.managedObjectContext?.save()
print("Finished restoring app:", app.bundleIdentifier)
os_log("Finished restoring app: %@", type: .info , app.bundleIdentifier)
} catch {
print("Failed to restore app:", error)
os_log("Failed to restore app: %@", type: .error , error.localizedDescription)
DispatchQueue.main.async {
let toastView = ToastView(error: error)
@@ -1131,7 +1140,7 @@ private extension MyAppsViewController {
}
}
} catch {
print("Failed to change app icon.", error)
os_log("Failed to change app icon. %@", type: .error , error.localizedDescription)
DispatchQueue.main.async {
let toastView = ToastView(error: error)
@@ -1160,7 +1169,7 @@ private extension MyAppsViewController {
@objc func didFetchSource(_: Notification) {
DispatchQueue.main.async {
if self.updatesDataSource.fetchedResultsController.fetchedObjects == nil {
do { try self.updatesDataSource.fetchedResultsController.performFetch() } catch { print("Error fetching:", error) }
do { try self.updatesDataSource.fetchedResultsController.performFetch() } catch { os_log("Error fetching: %@", type: .error , error.localizedDescription) }
}
self.update()
@@ -1179,7 +1188,7 @@ private extension MyAppsViewController {
do {
try FileManager.default.removeItem(at: url)
} catch {
print("Unable to remove imported .ipa.", error)
os_log("Unable to remove imported .ipa. %@", type: .error , error.localizedDescription)
}
}
}
@@ -1415,7 +1424,7 @@ extension MyAppsViewController {
actions.append(restoreBackupAction)
}
} else if let error = outError {
print("Unable to check if backup exists:", error)
os_log("Unable to check if backup exists: %@", type: .error , error.localizedDescription)
}
}
@@ -1784,7 +1793,7 @@ extension MyAppsViewController: UIDocumentPickerDelegate {
switch controller.documentPickerMode {
case .import, .open:
sideloadApp(at: fileURL) { result in
print("Sideloaded app at \(fileURL) with result:", result)
os_log("Sideloaded app at %@ with result: %@", type: .info , fileURL.absoluteString, String(describing: result))
}
case .exportToService, .moveToService: break

View File

@@ -13,6 +13,7 @@ import SideStoreCore
import RoxasUIKit
import Nuke
import os.log
private final class AppBannerFooterView: UICollectionReusableView {
let bannerView = AppBannerView(frame: .zero)
@@ -159,7 +160,7 @@ private extension NewsViewController {
cell.imageView.image = image
if let error = error {
print("Error loading image:", error)
os_log("Error loading image: %@", type: .error , error.localizedDescription)
}
}
@@ -278,7 +279,7 @@ private extension NewsViewController {
let toastView = ToastView(error: error)
toastView.show(in: self)
case .success: print("Installed app:", storeApp.bundleIdentifier)
case .success: os_log("Installed app: %@", type: .info, storeApp.bundleIdentifier)
}
UIView.performWithoutAnimation {

View File

@@ -9,7 +9,7 @@
import Foundation
import Network
import RoxasUIKit
import os.log
import AltSign
import SideStoreCore
@@ -178,7 +178,11 @@ public final class AuthenticationOperation: ResultOperation<(ALTTeam, ALTCertifi
override func finish(_ result: Result<(ALTTeam, ALTCertificate, ALTAppleAPISession), Error>) {
guard !isFinished else { return }
print("Finished authenticating with result:", result.error?.localizedDescription ?? "success")
if let error = result.error {
os_log("Failed to finish authenticating wirth error: %@", type: .error, error.localizedDescription)
} else {
os_log("Successfully authenticating", type: .info)
}
let context = DatabaseManager.shared.persistentContainer.newBackgroundContext()
context.perform {

View File

@@ -8,6 +8,7 @@
import CoreData
import UIKit
import os.log
import SideStoreCore
import EmotionalDamage
@@ -85,7 +86,7 @@ public final class BackgroundRefreshAppsOperation: ResultOperation<[String: Resu
start_em_proxy(bind_addr: Consts.Proxy.serverURL)
managedObjectContext.perform {
print("Apps to refresh:", self.installedApps.map(\.bundleIdentifier))
os_log("Apps to refresh: %@", type: .error , self.installedApps.map(\.bundleIdentifier))
self.startListeningForRunningApps()
@@ -95,7 +96,7 @@ public final class BackgroundRefreshAppsOperation: ResultOperation<[String: Resu
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
self.managedObjectContext.perform {
let filteredApps = self.installedApps.filter { !self.runningApplications.contains($0.bundleIdentifier) }
print("Filtered Apps to Refresh:", filteredApps.map { $0.bundleIdentifier })
os_log("Filtered Apps to Refresh: %@", type: .info , filteredApps.map { $0.bundleIdentifier }.joined(separator: "\n"))
let group = AppManager.shared.refresh(filteredApps, presentingViewController: nil)
group.beginInstallationHandler = { installedApp in
@@ -179,7 +180,7 @@ private extension BackgroundRefreshAppsOperation {
} catch RefreshError.noInstalledApps {
shouldPresentAlert = false
} catch {
print("Failed to refresh apps in background.", error)
os_log("Failed to refresh apps in background. %@", type: .error , error.localizedDescription)
content.title = NSLocalizedString("Failed to Refresh Apps", comment: "")
content.body = error.localizedDescription
@@ -218,7 +219,7 @@ private extension BackgroundRefreshAppsOperation {
context.performAndWait {
_ = RefreshAttempt(identifier: self.refreshIdentifier, result: result, context: context)
do { try context.save() } catch { print("Failed to save refresh attempt.", error) }
do { try context.save() } catch { os_log("Failed to save refresh attempt. %@", type: .error , error.localizedDescription) }
}
}

View File

@@ -13,6 +13,7 @@ import AltSign
import SideKit
import SideStoreCore
import Shared
import os.log
private extension DownloadAppOperation {
struct DependencyError: ALTLocalizedError {
@@ -63,7 +64,7 @@ final class DownloadAppOperation: ResultOperation<ALTApplication> {
return
}
print("Downloading App:", bundleIdentifier)
os_log("Downloading App: %@", type: .info , bundleIdentifier)
guard let sourceURL = sourceURL else { return finish(.failure(OperationError.appNotFound)) }
@@ -104,7 +105,7 @@ final class DownloadAppOperation: ResultOperation<ALTApplication> {
do {
try FileManager.default.removeItem(at: temporaryDirectory)
} catch {
print("Failed to remove DownloadAppOperation temporary directory: \(temporaryDirectory).", error)
os_log("Failed to remove DownloadAppOperation temporary directory: %@. %@", type: .error , temporaryDirectory.absoluteString, error.localizedDescription)
}
super.finish(result)

View File

@@ -17,7 +17,7 @@ private extension URL {
}
public extension FetchTrustedSourcesOperation {
public struct TrustedSource: Decodable {
struct TrustedSource: Decodable {
public var identifier: String
public var sourceURL: URL?
}

View File

@@ -13,6 +13,7 @@ import SideStoreCore
import RoxasUIKit
import MiniMuxerSwift
import minimuxer
import os.log
@objc(InstallAppOperation)
final class InstallAppOperation: ResultOperation<InstalledApp> {
@@ -156,7 +157,7 @@ final class InstallAppOperation: ResultOperation<InstalledApp> {
do {
try FileManager.default.removeItem(at: fileURL)
} catch {
print("Failed to remove refreshed .ipa:", error)
os_log("Failed to remove refreshed .ipa: %@", type: .error , error.localizedDescription)
}
}
@@ -172,7 +173,7 @@ private extension InstallAppOperation {
do {
try FileManager.default.removeItem(at: context.temporaryDirectory)
} catch {
print("Failed to remove temporary directory.", error)
os_log("Failed to remove temporary directory. %@", type: .error , error.localizedDescription)
}
}
}

View File

@@ -12,6 +12,7 @@ import UIKit
import AltSign
import SideStoreCore
import RoxasUIKit
import os.log
@available(iOS 14.0, *)
extension PatchViewController {
@@ -75,7 +76,7 @@ public final class PatchViewController: UIViewController {
do {
try FileManager.default.createDirectory(at: temporaryDirectory, withIntermediateDirectories: true, attributes: nil)
} catch {
print("Failed to create temporary directory:", error)
os_log("Failed to create temporary directory: %@", type: .error , error.localizedDescription)
}
update()
@@ -178,7 +179,7 @@ private extension PatchViewController {
do {
try FileManager.default.removeItem(at: temporaryDirectory)
} catch {
print("Failed to remove temporary directory:", error)
os_log("Failed to remove temporary directory: %@", type: .error , error.localizedDescription)
}
if let observation = didEnterBackgroundObservation {
@@ -275,7 +276,7 @@ private extension PatchViewController {
self.resignedApp = ALTApplication(fileURL: resignedAppURL)
} catch {
print("Error unzipping app bundle:", error)
os_log("Error unzipping app bundle: %@", type: .error , error.localizedDescription)
unzippingError = error
}
}

View File

@@ -7,6 +7,7 @@
//
import Foundation
import os.log
@objc(RemoveAppBackupOperation)
final class RemoveAppBackupOperation: ResultOperation<Void> {
@@ -53,12 +54,12 @@ final class RemoveAppBackupOperation: ResultOperation<Void> {
#else
print("Failed to remove app backup directory:", error)
os_log("Failed to remove app backup directory: %@", type: .error , error.localizedDescription)
self.finish(.failure(error))
#endif
} catch {
print("Failed to remove app backup directory:", error)
os_log("Failed to remove app backup directory: %@", type: .error , error.localizedDescription)
self.finish(.failure(error))
}
}

View File

@@ -11,7 +11,7 @@ import RoxasUIKit
import AltSign
import SideStoreCore
import os.log
@objc(ResignAppOperation)
final class ResignAppOperation: ResultOperation<ALTApplication> {
@@ -47,7 +47,7 @@ final class ResignAppOperation: ResultOperation<ALTApplication> {
let prepareAppBundleProgress = prepareAppBundle(for: app, profiles: profiles) { result in
guard let appBundleURL = self.process(result) else { return }
print("Resigning App:", self.context.bundleIdentifier)
os_log("Resigning App: %@", type: .info , self.context.bundleIdentifier)
// Resign app bundle
let resignProgress = self.resignAppBundle(at: appBundleURL, team: team, certificate: certificate, profiles: Array(profiles.values)) { result in

View File

@@ -14,6 +14,7 @@ import RoxasUIKit
import SideKit
import Nuke
import QuickLook
import os.log
final class ErrorLogViewController: UITableViewController {
private lazy var dataSource = self.makeDataSource()
@@ -248,7 +249,7 @@ extension ErrorLogViewController {
try context.save()
completion(true)
} catch {
print("[ALTLog] Failed to delete LoggedError \(loggedError.objectID):", error)
os_log("[ALTLog] Failed to delete LoggedError %@: %@", type: .error , loggedError.objectID, error.localizedDescription)
completion(false)
}
}

View File

@@ -11,6 +11,7 @@ import UIKit
import SideStoreCore
import RoxasUIKit
import os.log
struct SourceError: LocalizedError {
enum Code {
@@ -285,12 +286,12 @@ private extension SourcesViewController {
DispatchQueue.main.async {
do {
let sources = try result.get()
print("Fetched trusted sources:", sources.map { $0.identifier })
os_log("Fetched trusted sources: %@", type: .info , sources.map { $0.identifier }.joined(separator: "\n"))
let sectionUpdate = RSTCellContentChange(type: .update, sectionIndex: 0)
self.trustedSourcesDataSource.setItems(sources, with: [sectionUpdate])
} catch {
print("Error fetching trusted sources:", error)
os_log("Error fetching trusted sources: %@", type: .error , error.localizedDescription)
let sectionUpdate = RSTCellContentChange(type: .update, sectionIndex: 0)
self.trustedSourcesDataSource.setItems([], with: [sectionUpdate])