Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Resolves an issue where 32-bit Audio Bridge may quit unexpectedly.
Browse files Browse the repository at this point in the history
  • Loading branch information
cormiertyshawn895 committed Apr 26, 2020
1 parent 49c127f commit 56e0afc
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 142 deletions.
8 changes: 6 additions & 2 deletions Retroactive.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
042E9E492381AC2C001D3F38 /* AppKit in Resources */ = {isa = PBXBuildFile; fileRef = 042E9E452381AC2B001D3F38 /* AppKit */; };
042E9E4B2381AC2C001D3F38 /* GeneralFixerScript in Resources */ = {isa = PBXBuildFile; fileRef = 042E9E472381AC2B001D3F38 /* GeneralFixerScript */; };
042E9E4C2381AC2C001D3F38 /* VideoFixer in Resources */ = {isa = PBXBuildFile; fileRef = 042E9E482381AC2B001D3F38 /* VideoFixer */; };
0443E5E924562A7A008C4E9B /* MobileDevice.framework.zip in Resources */ = {isa = PBXBuildFile; fileRef = 0443E5E824562A7A008C4E9B /* MobileDevice.framework.zip */; };
046034E22381B41200070C86 /* KeynoteFixer in Resources */ = {isa = PBXBuildFile; fileRef = 046034E12381B41200070C86 /* KeynoteFixer */; };
046034E42381B6E800070C86 /* KeynoteScript in Resources */ = {isa = PBXBuildFile; fileRef = 046034E32381B6E800070C86 /* KeynoteScript */; };
046034E72381C18A00070C86 /* BrowserKit.framework.zip in Resources */ = {isa = PBXBuildFile; fileRef = 046034E52381C18900070C86 /* BrowserKit.framework.zip */; };
Expand Down Expand Up @@ -118,6 +119,7 @@
042E9E452381AC2B001D3F38 /* AppKit */ = {isa = PBXFileReference; lastKnownFileType = folder; path = AppKit; sourceTree = "<group>"; };
042E9E472381AC2B001D3F38 /* GeneralFixerScript */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = GeneralFixerScript; sourceTree = "<group>"; };
042E9E482381AC2B001D3F38 /* VideoFixer */ = {isa = PBXFileReference; lastKnownFileType = folder; path = VideoFixer; sourceTree = "<group>"; };
0443E5E824562A7A008C4E9B /* MobileDevice.framework.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = MobileDevice.framework.zip; sourceTree = "<group>"; };
046034E12381B41200070C86 /* KeynoteFixer */ = {isa = PBXFileReference; lastKnownFileType = folder; path = KeynoteFixer; sourceTree = "<group>"; };
046034E32381B6E800070C86 /* KeynoteScript */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = KeynoteScript; sourceTree = "<group>"; };
046034E52381C18900070C86 /* BrowserKit.framework.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = BrowserKit.framework.zip; sourceTree = "<group>"; };
Expand Down Expand Up @@ -330,6 +332,7 @@
046034E32381B6E800070C86 /* KeynoteScript */,
042E9E472381AC2B001D3F38 /* GeneralFixerScript */,
60D7289F23D5787B0006F233 /* VMFCPFixerScript */,
0443E5E824562A7A008C4E9B /* MobileDevice.framework.zip */,
607C3D812382665900FAE528 /* AudioToolbox.framework.zip */,
046034E52381C18900070C86 /* BrowserKit.framework.zip */,
046034E62381C18A00070C86 /* ProKit.framework.zip */,
Expand Down Expand Up @@ -629,6 +632,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0443E5E924562A7A008C4E9B /* MobileDevice.framework.zip in Resources */,
32F763582365018600200ED7 /* capsule.icns in Resources */,
6008E6C623820F7300A2F659 /* InfoPlist.strings in Resources */,
6039E6EA2383CB560023DAB8 /* HighSierra32Bit.mobileconfig in Resources */,
Expand Down Expand Up @@ -968,7 +972,7 @@
CODE_SIGN_ENTITLEMENTS = Retroactive/Support/Retroactive.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 56;
CURRENT_PROJECT_VERSION = 58;
INFOPLIST_FILE = Retroactive/Support/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -989,7 +993,7 @@
CODE_SIGN_ENTITLEMENTS = Retroactive/Support/Retroactive.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 56;
CURRENT_PROJECT_VERSION = 58;
INFOPLIST_FILE = Retroactive/Support/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
153 changes: 117 additions & 36 deletions Retroactive/AppManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,103 @@ class AppManager: NSObject {

var choseniTunesVersion: iTunesVersion?

var fixerUpdateAvailable: Bool = false
func removeFCP7PresetsIfNeeded() {
if chosenApp != .finalCutPro7 {
return
}
do {
let exists = FileManager.default.fileExists(atPath: kCustomSettingsPath)
if (!exists) {
return
}
let contents = try FileManager.default.contentsOfDirectory(atPath: kCustomSettingsPath)
let presets = contents.filter { $0.lowercased().hasSuffix(".fcpre") }
if (presets.count == 0) {
return
}
} catch {
print("Can't determine if custom settings exist \(error)")
}
}

func compatibleListContains(shortVersionNumber: String) -> Bool {
return self._compatibleShortVersionOfChosenApp.contains { (iterateVersionNumber) -> Bool in
return (iterateVersionNumber == shortVersionNumber)
}
}

func hasAlreadyPatchedIDOrVersionNumber(bundleID: String, fullVersionNumber: String, shortVersionNumber: String) -> Bool {
return bundleID == self.patchedBundleIDOfChosenApp
|| fullVersionNumber == self.patchedVersionStringOfChosenApp
|| (self.patchedBundleIDOfChosenApp == nil && self.patchedVersionStringOfChosenApp == nil && compatibleListContains(shortVersionNumber: shortVersionNumber))
}

func hasOrDoesNotRequireUnderscoredSheBangScriptNextToLargeBinary(foundAppPath: String) -> Bool {
let appMacOSPath = "\(foundAppPath)/Contents/MacOS"
let appBinaryPath = "\(appMacOSPath)/\(AppManager.shared.binaryNameOfChosenApp)"
let macAppBinaryPathUnderscore = "\(appBinaryPath)_"

switch chosenApp {
case .finalCutPro7, .logicPro9, .pages4, .numbers2, .keynote5:
let exists = FileManager.default.fileExists(atPath: macAppBinaryPathUnderscore)
if (exists) {
do {
if let fileSize = try FileManager.default.attributesOfItem(atPath: appBinaryPath)[.size] as? UInt64 {
print("file size of non underscore is \(fileSize) bytes")
if (fileSize < 1000) {
print("The non underscored file is a fixer, no mach-o binary is smaller than 1000 bytes.")
return true
} else {
print("The non underscored file probably isn't a fixer because it exceeds 1000 bytes, it probably got there with an app update.")
}
}
} catch {
print("Can't determine file size, \(error)")
}
}
return false
default:
return true
}
}

func hasAlreadyAppliedOrDoesNotRequireFixer(foundAppPath: String) -> Bool {
switch chosenApp {
case .aperture, .iphoto, .finalCutPro7, .logicPro9, .pages4, .numbers2, .keynote5:
if hasOrDoesNotRequireUnderscoredSheBangScriptNextToLargeBinary(foundAppPath: foundAppPath) == false {
return false
}
if chosenApp == .logicPro9 && FileManager.default.fileExists(atPath: "\(foundAppPath)/Contents/Frameworks/MobileDevice.framework") == false {
return false
}
let existingFixerPath = "\(foundAppPath)/\(AppManager.shared.fixerFrameworkSubPath)"
if let existingFixerBundle = Bundle.init(path: existingFixerPath),
let existingFixerVersion = existingFixerBundle.cfBundleVersionInt,
let resourcePath = Bundle.main.resourcePath {
let fixerResourcePath = "\(resourcePath)/\(AppManager.shared.fixerFrameworkName)/Resources/Info.plist"
if let loadedFixerInfoPlist = NSDictionary(contentsOfFile: fixerResourcePath) as? Dictionary<String, Any>,
let bundledFixerVersionString = loadedFixerInfoPlist[kCFBundleVersion] as? String, let bundledFixerVersion = Int(bundledFixerVersionString) {
if (existingFixerVersion >= bundledFixerVersion) {
return true
}
}
}
return false
case .xcode:
let appBundle = Bundle(path: foundAppPath)
if let minSysVersionString = appBundle?.object(forInfoDictionaryKey: kLSMinimumSystemVersion) as? String {
print("Xcode min OS version: \(minSysVersionString), current OS version: \(ProcessInfo.osVersionNumberString)")
if (ProcessInfo.osVersionNumberString.osIsAtLeast(otherOS: minSysVersionString)) {
print("Current OS is at least Xcode min OS")
return true
}
}
return false
default:
print("\(String(describing: chosenApp)) doesn't need a fixer, so hasUpToDateFixer always returns true")
return true
}
}

var locationOfChosenApp: String?
var nameOfChosenApp: String {
Expand Down Expand Up @@ -597,11 +693,11 @@ class AppManager: NSObject {
case .logicPro9:
return ["1700.67"]
case .keynote5:
return ["1170"]
return []
case .pages4:
return ["1048"]
return []
case .numbers2:
return ["554"]
return []
default:
return []
}
Expand Down Expand Up @@ -692,7 +788,7 @@ class AppManager: NSObject {
case .appStore:
return "12.6.5"
case .configurator:
return "999.99.99"
return ""
case .classicTheme:
return "11.4"
case .coverFlow:
Expand Down Expand Up @@ -746,30 +842,25 @@ class AppManager: NSObject {
}
}

var patchedBundleIDOfChosenApp: String {
var patchedBundleIDOfChosenApp: String? {
get {
switch self.chosenApp {
case .aperture:
return "com.apple.Aperture3"
case .iphoto:
return "com.apple.iPhoto9"
case .itunes:
fallthrough
return nil
case .xcode:
// Intentionally left unused for everything after this enum case
return "com.apple.intentionally-left-unused"
return nil
case .finalCutPro7:
return "com.apple.FinalCutPro7"
return nil
case .logicPro9:
return "com.apple.logic.pro9"
case .keynote5:
return "com.apple.iWork.Keynote5"
case .pages4:
return "com.apple.iWork.Pages4"
case .numbers2:
return "com.apple.iWork.Numbers2"
return nil
case .keynote5, .pages4, .numbers2:
return nil
default:
return ""
return nil
}
}
}
Expand Down Expand Up @@ -829,42 +920,32 @@ class AppManager: NSObject {
}


var patchedVersionStringOfChosenApp: String {
var patchedVersionStringOfChosenApp: String? {
get {
switch self.chosenApp {
case .aperture:
return "99.9"
case .iphoto:
return "99.9"
case .aperture, .iphoto:
return nil
case .itunes:
switch choseniTunesVersion {
case .darkMode:
return "12.9.5"
case .appStore:
return "12.6.5"
case .configurator:
return "999.99.99"
case .classicTheme:
return "11.4"
case .coverFlow:
return "10.7"
case .none:
return ""
case .configurator, .none:
return nil
}
case .finalCutPro7:
return "7.0.4"
case .logicPro9:
return "1700.68"
case .xcode:
return "9999.99" // Intentionally left unused
case .keynote5:
return "1171"
case .pages4:
return "1049"
case .numbers2:
return "555"
case .xcode, .keynote5, .pages4, .numbers2:
return nil
default:
return ""
return nil
}
}
}
Expand Down
Loading

0 comments on commit 56e0afc

Please sign in to comment.