Skip to content

Commit

Permalink
Updating to Swift 4
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmichel committed Aug 5, 2018
1 parent 2800a4a commit 4662fb2
Show file tree
Hide file tree
Showing 196 changed files with 8,495 additions and 5,078 deletions.
14 changes: 10 additions & 4 deletions Juice.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
725AA5BB1E05BF3A006E5DDE = {
CreatedOnToolsVersion = 8.2;
DevelopmentTeam = YN24FFRTC8;
LastSwiftMigration = 0940;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.Sandbox = {
Expand All @@ -369,6 +370,7 @@
72DA73591E09FE19003F9262 = {
CreatedOnToolsVersion = 8.2;
DevelopmentTeam = YN24FFRTC8;
LastSwiftMigration = 0940;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.Sandbox = {
Expand Down Expand Up @@ -656,7 +658,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.bsm.macos.Juice;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -675,7 +678,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.bsm.macos.Juice;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -693,7 +697,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.bsm.macos.JuiceHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -711,7 +716,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.bsm.macos.JuiceHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
8 changes: 8 additions & 0 deletions Juice.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
4 changes: 2 additions & 2 deletions Juice/Classes/AboutPreferencesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class AboutPreferencesViewController: NSViewController {
@IBOutlet weak var versionLabel: NSTextField!
@IBOutlet weak var buildLabel: NSTextField!

override var nibName: String? {
return "AboutPreferencesViewController"
override var nibName: NSNib.Name? {
return NSNib.Name(rawValue: "AboutPreferencesViewController")
}

override func viewDidLoad() {
Expand Down
2 changes: 1 addition & 1 deletion Juice/Classes/ChargeScaleDisplay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extension SerializableChargeScaleDisplay where Self: ChargeScaleDisplay {
let completeFilePath = applicationSupportDirectory.appendingPathComponent(fileName)

do {
let data = try PropertyListSerialization.data(fromPropertyList: plistValues, format: .xml, options: .allZeros)
let data = try PropertyListSerialization.data(fromPropertyList: plistValues, format: .xml, options: 0)
try data.write(to: completeFilePath, options: .atomicWrite)
} catch (let error) {
print(NSLocalizedString("Error serializing scale", comment: "Error serializing scale") + ": \(error)")
Expand Down
4 changes: 2 additions & 2 deletions Juice/Classes/CreditsPreferencesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Cocoa

class CreditsPreferencesViewController: NSViewController {

override var nibName: String? {
return "CreditsPreferencesViewController"
override var nibName: NSNib.Name? {
return NSNib.Name(rawValue: "CreditsPreferencesViewController")
}

}
12 changes: 6 additions & 6 deletions Juice/Classes/GeneralPreferencesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class GeneralPreferencesViewController: NSViewController {
@IBOutlet weak var scalesFoundLabel: NSTextField!
@IBOutlet weak var launchOnLoginButton: NSButton!

override var nibName: String? {
return "GeneralPreferencesViewController"
override var nibName: NSNib.Name? {
return NSNib.Name(rawValue: "GeneralPreferencesViewController")
}

override func viewDidLoad() {
Expand All @@ -53,9 +53,9 @@ class GeneralPreferencesViewController: NSViewController {
default:
return
}
}.addDisposableTo(disposableBag)
}.disposed(by: disposableBag)

launchOnLoginButton.state = startOnLaunchController.startsOnLaunch ? NSOnState : NSOffState
launchOnLoginButton.state = startOnLaunchController.startsOnLaunch ? NSControl.StateValue.on : NSControl.StateValue.off
}

@objc private func statusBarStyleChanged() {
Expand All @@ -81,15 +81,15 @@ class GeneralPreferencesViewController: NSViewController {

newScale.save()

NSWorkspace.shared().open(filePath)
NSWorkspace.shared.open(filePath)
}

@IBAction func triggerRescan(_ sender: Any) {
preferences.scanApplicationSupportForFiles()
}

@IBAction func toggleStartOnLaunchButton(_ sender: Any) {
let isSet = launchOnLoginButton.state == NSOnState
let isSet = launchOnLoginButton.state == NSControl.StateValue.on
_ = startOnLaunchController.toggle(startOnLaunch: isSet)

}
Expand Down
6 changes: 3 additions & 3 deletions Juice/Classes/PreferencesCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ final class PreferencesCoordinator: PreferencesWindowControllerDelegate {
func preferences(windowController: PreferencesWindowController, clickedPreference identifier: String) {
switch identifier {

case PreferencesWindowController.Identifiers.General:
case PreferencesWindowController.Identifiers.General.rawValue:
windowController.contentViewController = GeneralPreferencesViewController()
windowController.window?.title = NSLocalizedString("General", comment: "General")
case PreferencesWindowController.Identifiers.Credits:
case PreferencesWindowController.Identifiers.Credits.rawValue:
windowController.contentViewController = CreditsPreferencesViewController()
windowController.window?.title = NSLocalizedString("Credits", comment: "Credits")
case PreferencesWindowController.Identifiers.Tip:
case PreferencesWindowController.Identifiers.Tip.rawValue:
windowController.contentViewController = AboutPreferencesViewController()
windowController.window?.title = NSLocalizedString("About", comment: "About")
default:
Expand Down
44 changes: 22 additions & 22 deletions Juice/Classes/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ protocol PreferencesWindowControllerDelegate: class {
final class PreferencesWindowController: NSWindowController, NSToolbarDelegate {

enum Identifiers {
static let General = "Preferences-General"
static let Credits = "Preferences-Credits"
static let Tip = "Preferences-Tip"
static let General = NSToolbarItem.Identifier(rawValue: "Preferences-General")
static let Credits = NSToolbarItem.Identifier(rawValue: "Preferences-Credits")
static let Tip = NSToolbarItem.Identifier(rawValue: "Preferences-Tip")
}

@IBOutlet weak var toolbar: NSToolbar!
Expand Down Expand Up @@ -51,21 +51,21 @@ final class PreferencesWindowController: NSWindowController, NSToolbarDelegate {
}
}

override var windowNibName: String? {
return "PreferencesWindowController"
override var windowNibName: NSNib.Name? {
return NSNib.Name(rawValue: "PreferencesWindowController")
}

override func windowDidLoad() {
super.windowDidLoad()
window?.level = Int(CGWindowLevelForKey(.floatingWindow))
window?.level = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(.floatingWindow)))

toolbar.selectedItemIdentifier = Identifiers.General
generalToolbarItemClicked()
}

func customToolbarItem(itemForItemIdentifier itemIdentifier: String, label: String, paletteLabel: String, toolTip: String, target: AnyObject, itemContent: NSImage?, action: Selector?, menu: NSMenu?) -> NSToolbarItem? {

let toolbarItem = NSToolbarItem(itemIdentifier: itemIdentifier)
let toolbarItem = NSToolbarItem(itemIdentifier: NSToolbarItem.Identifier(rawValue: itemIdentifier))

toolbarItem.label = label
toolbarItem.paletteLabel = paletteLabel
Expand All @@ -84,63 +84,63 @@ final class PreferencesWindowController: NSWindowController, NSToolbarDelegate {

//MARK: - NSToolbarDelegate

func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [String] {
func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
return [Identifiers.General,
NSToolbarFlexibleSpaceItemIdentifier,
NSToolbarItem.Identifier.flexibleSpace,
Identifiers.Tip]
}

func toolbarSelectableItemIdentifiers(_ toolbar: NSToolbar) -> [String] {
func toolbarSelectableItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
return [Identifiers.General,
Identifiers.Tip]
}

func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: String, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? {
func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? {
switch itemIdentifier {
case Identifiers.General:
return customToolbarItem(itemForItemIdentifier: Identifiers.General,
return customToolbarItem(itemForItemIdentifier: Identifiers.General.rawValue,
label: NSLocalizedString("General", comment: "General"),
paletteLabel: NSLocalizedString("General", comment: "General"),
toolTip: NSLocalizedString("General Settings", comment: "General Settings"),
target: self,
itemContent: NSImage(named: "General Icon"),
itemContent: NSImage(named: NSImage.Name(rawValue: "General Icon")),
action: #selector(generalToolbarItemClicked),
menu: nil)
case Identifiers.Credits:
return customToolbarItem(itemForItemIdentifier: Identifiers.Credits,
return customToolbarItem(itemForItemIdentifier: Identifiers.Credits.rawValue,
label: NSLocalizedString("Credits", comment: "Credits"),
paletteLabel: NSLocalizedString("Credits", comment: "Credits"),
toolTip: NSLocalizedString("Credits for this app", comment: "Credits for this app"),
target: self,
itemContent: NSImage(named: "Credits Icon"),
itemContent: NSImage(named: NSImage.Name(rawValue: "Credits Icon")),
action: #selector(creditsToolbarItemClicked),
menu: nil)
case Identifiers.Tip:
return customToolbarItem(itemForItemIdentifier: Identifiers.Tip,
return customToolbarItem(itemForItemIdentifier: Identifiers.Tip.rawValue,
label: NSLocalizedString("About", comment: "About"),
paletteLabel: NSLocalizedString("About", comment: "About"),
toolTip: NSLocalizedString("Version Information", comment: "Version Information"),
target: self,
itemContent: NSImage(named: "Tip Icon"),
itemContent: NSImage(named: NSImage.Name(rawValue: "Tip Icon")),
action: #selector(tipToolbarItemClicked),
menu: nil)
case NSToolbarFlexibleSpaceItemIdentifier:
return NSToolbarItem(itemIdentifier: NSToolbarFlexibleSpaceItemIdentifier)
case NSToolbarItem.Identifier.flexibleSpace:
return NSToolbarItem(itemIdentifier: NSToolbarItem.Identifier.flexibleSpace)
default:
return nil
}
}

@objc private func generalToolbarItemClicked() {
delegate?.preferences(windowController: self, clickedPreference: Identifiers.General)
delegate?.preferences(windowController: self, clickedPreference: Identifiers.General.rawValue)
}

@objc private func creditsToolbarItemClicked() {
delegate?.preferences(windowController: self, clickedPreference: Identifiers.Credits)
delegate?.preferences(windowController: self, clickedPreference: Identifiers.Credits.rawValue)
}

@objc private func tipToolbarItemClicked() {
delegate?.preferences(windowController: self, clickedPreference: Identifiers.Tip)
delegate?.preferences(windowController: self, clickedPreference: Identifiers.Tip.rawValue)
}

}
6 changes: 3 additions & 3 deletions Juice/Classes/StatusBarItemCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class StatusBarItemCoordinator: StatusMenuItemDelegate {
private let preferencesCoordinator = PreferencesCoordinator()
private let lowPowerCoordinator: LowPowerCoordinator

private let statusBarItem = NSStatusBar.system().statusItem(withLength: NSVariableStatusItemLength)
private let statusBarItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
private let statusBarItemMenu = StatusMenuItem(title: "Juice")
private let disposableBag = DisposeBag()
private let powerSourcesObservable: Observable<[PowerSource]>
Expand Down Expand Up @@ -54,11 +54,11 @@ final class StatusBarItemCoordinator: StatusMenuItemDelegate {
}

self.updateLabel(source: source)
}).addDisposableTo(disposableBag)
}).disposed(by: disposableBag)

scaleChangeObservable.subscribe(onNext: { (scale) in
self.updateLabel(scale: scale)
}).addDisposableTo(disposableBag)
}).disposed(by: disposableBag)

lowPowerCoordinator.start()
}
Expand Down
6 changes: 3 additions & 3 deletions JuiceHelper/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!

func applicationDidFinishLaunching(_ aNotification: Notification) {
guard NSWorkspace.shared().runningApplications.filter({ $0.bundleIdentifier == "com.bsm.macos.Juice" }).count == 0 else {
guard NSWorkspace.shared.runningApplications.filter({ $0.bundleIdentifier == "com.bsm.macos.Juice" }).count == 0 else {
return
}

NSWorkspace.shared().launchApplication(withBundleIdentifier: "com.bsm.macos.Juice",
options: .async,
NSWorkspace.shared.launchApplication(withBundleIdentifier: "com.bsm.macos.Juice",
options: NSWorkspace.LaunchOptions.async,
additionalEventParamDescriptor: nil,
launchIdentifier: nil)
}
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ platform :osx, '10.12'

use_frameworks!
target 'Juice' do
pod 'RxSwift', '~> 3.0.1'
pod 'RxSwift', '~> 4.2.0'
end
8 changes: 4 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
PODS:
- RxSwift (3.0.1)
- RxSwift (4.2.0)

DEPENDENCIES:
- RxSwift (~> 3.0.1)
- RxSwift (~> 4.2.0)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- RxSwift

SPEC CHECKSUMS:
RxSwift: af5680055c4ad04480189c52d28385b1029493a6
RxSwift: 99e10317ddfcc7fbe01356aafd118fde4a0be104

PODFILE CHECKSUM: ad93cb59c786ef3161b3045835904dd61c2078ff
PODFILE CHECKSUM: 4af392eb8f8b12ae3f2d39f64dc2cef676821bd3

COCOAPODS: 1.5.3
8 changes: 4 additions & 4 deletions Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4662fb2

Please sign in to comment.