Skip to content

Commit

Permalink
Fix loading outside the debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
kuglee committed May 3, 2018
1 parent a7d53b2 commit 4f787f6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion BatteryExtra/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.3</string>
<string>1.3.1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
Expand Down
34 changes: 18 additions & 16 deletions BatteryExtra/Loader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,26 @@ fileprivate var log: OSLog!
os_log("Could not load bundle \"%{public}@\"! Quitting...", log: log, type: .error, menuExtraBundlePath)
}

do {
try swizzle()
} catch {
switch error {
case let SwizzleError.classNotFound(errorMessage):
os_log("%{public}@", log: log, type: .error, errorMessage)
case let SwizzleError.methodNotFound(errorMessage):
os_log("%{public}@", log: log, type: .error, errorMessage)
default:
os_log("Unexpected error: %{public}@", log: log, type: .error, error as CVarArg)
DispatchQueue.main.async {
do {
try swizzle()
} catch {
switch error {
case let SwizzleError.classNotFound(errorMessage):
os_log("%{public}@", log: log, type: .error, errorMessage)
case let SwizzleError.methodNotFound(errorMessage):
os_log("%{public}@", log: log, type: .error, errorMessage)
default:
os_log("Unexpected error: %{public}@", log: log, type: .error, error as CVarArg)
}

os_log("Could not swizzle \"%@\"!", log: log, type: .error, Bundle.main.bundleIdentifier!)
return
}

os_log("Could not swizzle \"%@\"!", log: log, type: .error, Bundle.main.bundleIdentifier!)
return
}
os_log("\"%@\" was swizzled successfully!", log: log, Bundle.main.bundleIdentifier!)

os_log("\"%@\" was swizzled successfully!", log: log, Bundle.main.bundleIdentifier!)

reloadMenuExtraIfVisibleOnMenuBar(bundlePath: menuExtraBundlePath)
reloadMenuExtraIfVisibleOnMenuBar(bundlePath: menuExtraBundlePath)
}
}
}
2 changes: 1 addition & 1 deletion ReloadHelper/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.3</string>
<string>1.3.1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
Expand Down

0 comments on commit 4f787f6

Please sign in to comment.