[debug]: enabled back appropriate preprocessor debug blocks as before wherever applicable

This commit is contained in:
Magesh K
2025-01-12 18:01:11 +05:30
parent 61989e7d40
commit 55f4aa7deb
10 changed files with 72 additions and 63 deletions

View File

@@ -82,7 +82,7 @@ class ViewController: UIViewController
self.activityIndicatorView.color = .altstoreText
self.activityIndicatorView.startAnimating()
// TODO: @mahee96: Disabled this buttons which were present for debugging purpose.
// TODO: @mahee96: Disabled these backup/restore buttons in altbackup.app screen which were present for debugging purpose.
// Can find something useful for these later, but these are not required by this backup/restore app
// #if DEBUG
// let button1 = UIButton(type: .system)

View File

@@ -294,9 +294,9 @@ extension AppDelegate
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { (success, error) in
}
// #if DEBUG
// UIApplication.shared.registerForRemoteNotifications()
// #endif
#if DEBUG && targetEnvironment(simulator)
UIApplication.shared.registerForRemoteNotifications()
#endif
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)

View File

@@ -1930,11 +1930,12 @@ extension MyAppsViewController
var outError: NSError? = nil
self.coordinator.coordinate(readingItemAt: backupDirectoryURL, options: [.withoutChanges], error: &outError) { (backupDirectoryURL) in
// #if DEBUG
// backupExists = true
// #else
#if DEBUG && targetEnvironment(simulator)
backupExists = true
#else
backupExists = FileManager.default.fileExists(atPath: backupDirectoryURL.path)
// #endif
#endif
}
if backupExists
@@ -1965,13 +1966,12 @@ extension MyAppsViewController
}
// #if DEBUG
// if installedApp.bundleIdentifier != StoreApp.altstoreAppID
// {
// actions.append(removeAction)
// }
//
// #else
#if DEBUG && targetEnvironment(simulator)
if installedApp.bundleIdentifier != StoreApp.altstoreAppID
{
actions.append(removeAction)
}
#else
if (UserDefaults.standard.legacySideloadedApps ?? []).contains(installedApp.bundleIdentifier)
{
@@ -1985,7 +1985,7 @@ extension MyAppsViewController
actions.append(removeAction)
}
// #endif
#endif
}
// Change the order of entries to make changes to how the context menu is displayed

View File

@@ -715,9 +715,10 @@ private extension AuthenticationOperation
// If we're not using the same certificate used to install AltStore, warn user that they need to refresh.
guard !provisioningProfile.certificates.contains(signer.certificate) else { return completionHandler(false) }
//#if DEBUG
// #if DEBUG && targetEnvironment(simulator)
// completionHandler(false)
//#else
// #else
DispatchQueue.main.async {
let context = AuthenticatedOperationContext(context: self.context)
context.operations.removeAllObjects() // Prevent deadlock due to endless waiting on previous operations to finish.
@@ -733,7 +734,7 @@ private extension AuthenticationOperation
completionHandler(false)
}
}
//#endif
// #endif
}
}

View File

@@ -134,19 +134,21 @@ extension FetchProvisioningProfilesOperation
// or if installedApp.team is nil but resignedBundleIdentifier contains the team's identifier.
let teamsMatch = installedApp.team?.identifier == team.identifier || (installedApp.team == nil && installedApp.resignedBundleIdentifier.contains(team.identifier))
// #if DEBUG
//
// if app.isAltStoreApp
// {
// // Use legacy bundle ID format for AltStore.
// preferredBundleID = teamsMatch ? installedApp.resignedBundleIdentifier : nil
// }
// else
// {
// preferredBundleID = teamsMatch ? installedApp.resignedBundleIdentifier : nil
// }
//
// #else
// TODO: @mahee96: Try to keep the debug build and release build operations similar, refactor later with proper reasoning
// for now, restricted it to debug on simulator only
#if DEBUG && targetEnvironment(simulator)
if app.isAltStoreApp
{
// Use legacy bundle ID format for AltStore.
preferredBundleID = teamsMatch ? installedApp.resignedBundleIdentifier : nil
}
else
{
preferredBundleID = teamsMatch ? installedApp.resignedBundleIdentifier : nil
}
#else
if teamsMatch
{
@@ -160,7 +162,7 @@ extension FetchProvisioningProfilesOperation
preferredBundleID = nil
}
// #endif
#endif
}
else
{

View File

@@ -58,6 +58,7 @@ final class RemoveAppBackupOperation: ResultOperation<Void>
}
catch let error as CocoaError where error.code == CocoaError.Code.fileNoSuchFile
{
// TODO: @mahee96: Find out why should in debug builds the app-groups is not expected to match
// #if DEBUG
//
// // When debugging, it's expected that app groups don't match, so ignore.

View File

@@ -244,13 +244,14 @@ private extension ResignAppOperation
{
for case let fileURL as URL in enumerator
{
// #if DEBUG
// guard !fileURL.lastPathComponent.lowercased().contains(".xctest") else {
// // Remove embedded XCTest (+ dSYM) bundle from copied app bundle.
// try FileManager.default.removeItem(at: fileURL)
// continue
// }
// #endif
// for both sim and device, in debug mode builds, remove the tests bundles (if any)
#if DEBUG
guard !fileURL.lastPathComponent.lowercased().contains(".xctest") else {
// Remove embedded XCTest (+ dSYM) bundle from copied app bundle.
try FileManager.default.removeItem(at: fileURL)
continue
}
#endif
guard let appExtension = Bundle(url: fileURL) else { throw ALTError(.missingAppBundle) }
try prepare(appExtension)

View File

@@ -318,11 +318,12 @@ extension PatreonViewController
case .none: footerView.button.isIndicatingActivity = true
case .success?: footerView.button.isHidden = true
case .failure?:
// #if DEBUG
// let debug = true
// #else
// In simulator debug builds only enable debug mode flag
#if DEBUG && targetEnvironment(simulator)
let debug = true
#else
let debug = false
// #endif
#endif
if self.patronsDataSource.itemCount == 0 || debug
{

View File

@@ -107,6 +107,7 @@ public extension UserDefaults
(ProcessInfo.processInfo.isOperatingSystemAtLeast(ios14) && !ProcessInfo.processInfo.isOperatingSystemAtLeast(ios15_7_2)) ||
(ProcessInfo.processInfo.isOperatingSystemAtLeast(ios16) && !ProcessInfo.processInfo.isOperatingSystemAtLeast(ios16_2))
// TODO: @mahee96: why should the permissions checking be any different, for now, it shouldn't so commented debug mode code
// #if DEBUG
// let permissionCheckingDisabled = true
// #else

View File

@@ -87,21 +87,22 @@ public extension DatabaseManager
guard !self.isStarted else { return finish(nil) }
// #if DEBUG
// // Wrap in #if DEBUG to *ensure* we never accidentally delete production databases.
// if ProcessInfo.processInfo.isPreview
// {
// do
// {
// print("!!! Purging database for preview...")
// try FileManager.default.removeItem(at: PersistentContainer.defaultDirectoryURL())
// }
// catch
// {
// print("Failed to remove database directory for preview.", error)
// }
// }
// #endif
// In simulator, when previews are generated, it initializes the db, in doing so this removal may be required
#if DEBUG && targetEnvironment(simulator)
// Wrap in #if DEBUG to *ensure* we never accidentally delete production databases.
if ProcessInfo.processInfo.isPreview
{
do
{
print("!!! Purging database for preview...")
try FileManager.default.removeItem(at: PersistentContainer.defaultDirectoryURL())
}
catch
{
print("Failed to remove database directory for preview.", error)
}
}
#endif
if self.persistentContainer.isMigrationRequired
{
@@ -354,11 +355,12 @@ private extension DatabaseManager
let fileURL = installedApp.fileURL
// #if DEBUG
// let replaceCachedApp = true
// #else
// @mahee96: it shouldn't matter if it is debug/release, the file is expected to be in its place (except for simulator probably coz it doesn't suppor app installs anyway)
#if DEBUG && targetEnvironment(simulator)
let replaceCachedApp = true
#else
let replaceCachedApp = !FileManager.default.fileExists(atPath: fileURL.path) || installedApp.version != localApp.version || installedApp.buildVersion != localApp.buildVersion
// #endif
#endif
if replaceCachedApp
{