Skip to content

Commit

Permalink
update to swift 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ddddxxx committed Feb 4, 2019
1 parent 620d79d commit ba6963d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 22 deletions.
8 changes: 2 additions & 6 deletions LyricsX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand Down Expand Up @@ -1053,6 +1054,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -1078,7 +1080,6 @@
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = ddddxxx.LyricsX;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1104,7 +1105,6 @@
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = ddddxxx.LyricsX;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down Expand Up @@ -1132,7 +1132,6 @@
PRODUCT_NAME = LyricsX;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = IS_FOR_MAS;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand Down Expand Up @@ -1160,7 +1159,6 @@
PRODUCT_NAME = LyricsX;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = IS_FOR_MAS;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -1178,7 +1176,6 @@
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = ddddxxx.LyricsXHelper;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1196,7 +1193,6 @@
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = ddddxxx.LyricsXHelper;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
10 changes: 5 additions & 5 deletions LyricsX/Component/AppController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class AppController: NSObject, MusicPlayerManagerDelegate {

timer = Timer(timeInterval: 0.1, target: self, selector: #selector(updatePlayerPosition), userInfo: nil, repeats: true)
timer?.tolerance = 0.02
RunLoop.current.add(timer!, forMode: .commonModes)
RunLoop.current.add(timer!, forMode: .common)

self.currentTrackChanged(track: playerManager.player?.currentTrack)
currentTrackChanged(track: playerManager.player?.currentTrack)
}

func writeToiTunes(overwrite: Bool) {
Expand Down Expand Up @@ -226,7 +226,7 @@ class AppController: NSObject, MusicPlayerManagerDelegate {
}

@objc func updatePlayerPosition() {
guard let position = AppController.shared.playerManager.player?.playerPosition else {
guard let position = playerManager.player?.playerPosition else {
return
}
playerPositionMutated(position: position)
Expand All @@ -235,7 +235,7 @@ class AppController: NSObject, MusicPlayerManagerDelegate {
// MARK: LyricsSourceDelegate

func lyricsReceived(lyrics: Lyrics) {
let track = AppController.shared.playerManager.player?.currentTrack
let track = playerManager.player?.currentTrack
guard lyrics.metadata.title == track?.title ?? "",
lyrics.metadata.artist == track?.artist ?? "" else {
return
Expand Down Expand Up @@ -267,7 +267,7 @@ extension AppController {
let error = NSError(domain: lyricsXErrorDomain, code: 0, userInfo: errorInfo)
throw error
}
guard let track = AppController.shared.playerManager.player?.currentTrack else {
guard let track = playerManager.player?.currentTrack else {
let errorInfo = [
NSLocalizedDescriptionKey: "No music playing",
NSLocalizedRecoverySuggestionErrorKey: "Play a music and try again."
Expand Down
10 changes: 5 additions & 5 deletions LyricsX/Utility/CTExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import Foundation

// MARK: - CTRubyAnnotation

extension NSAttributedStringKey {
extension NSAttributedString.Key {

static let rubyAnnotation = kCTRubyAnnotationAttributeName as NSAttributedStringKey
static let rubyAnnotation = kCTRubyAnnotationAttributeName as NSAttributedString.Key

/// kCTRubyAnnotationSizeFactorAttributeName
static let rubyAnnotationSizeFactor = NSAttributedStringKey("CTRubyAnnotationSizeFactor")
static let rubyAnnotationSizeFactor = NSAttributedString.Key("CTRubyAnnotationSizeFactor")

static let ctForegroundColor = kCTForegroundColorAttributeName as NSAttributedStringKey
static let ctForegroundColor = kCTForegroundColorAttributeName as NSAttributedString.Key
}

extension CTRubyAnnotation {
Expand All @@ -39,7 +39,7 @@ extension CTRubyAnnotation {
position: CTRubyPosition = .before,
alignment: CTRubyAlignment = .auto,
overhang: CTRubyOverhang = .auto,
attributes: [NSAttributedStringKey: Any] = [:]) -> CTRubyAnnotation {
attributes: [NSAttributedString.Key: Any] = [:]) -> CTRubyAnnotation {
if #available(OSX 10.12, *) {
return CTRubyAnnotationCreateWithAttributes(alignment, overhang, position, string as CFString, attributes as CFDictionary)
} else {
Expand Down
2 changes: 1 addition & 1 deletion LyricsX/Utility/Polyfill.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ extension NSStoryboard {
guard let mainStoryboardName = Bundle.main.infoDictionary?["NSMainStoryboardFile"] as? String else {
return nil
}
return NSStoryboard(name: NSStoryboard.Name(rawValue: mainStoryboardName), bundle: .main)
return NSStoryboard(name: NSStoryboard.Name(mainStoryboardName), bundle: .main)
}
}
2 changes: 1 addition & 1 deletion LyricsX/View/DragNDropView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DragNDropView: NSView {
}

override func performDragOperation(_ sender: NSDraggingInfo) -> Bool {
let pboard = sender.draggingPasteboard()
let pboard = sender.draggingPasteboard

if pboard.types?.contains(.string) == true,
let str = pboard.string(forType: .string) {
Expand Down
4 changes: 2 additions & 2 deletions LyricsX/View/FontSelectTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class FontSelectTextField: NSTextField, NSWindowDelegate {
fontPanel?.makeKeyAndOrderFront(self)
}

override func changeFont(_ sender: Any?) {
@objc func changeFont(_ sender: Any?) {
guard let manager = sender as? NSFontManager else {
return
}
Expand All @@ -92,7 +92,7 @@ class FontSelectTextField: NSTextField, NSWindowDelegate {

private static let swizzler: Void = {
let cls = FontSelectTextField.self
let sel = #selector(NSObject.validModesForFontPanel)
let sel = Selector(("validModesForFontPanel"))
let dummySel = #selector(FontSelectTextField.dummyValidModesForFontPanel)
guard let dummyIMP = class_getMethodImplementation(cls, dummySel),
let dummyImpl = class_getInstanceMethod(cls, dummySel),
Expand Down
4 changes: 2 additions & 2 deletions LyricsX/View/KaraokeLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ class KaraokeLabel: NSTextField {
for tokenType in tokenizer where tokenType.contains(.isCJWordMask) {
if isVertical {
let tokenRange = tokenizer.currentTokenRange()
let attr: [NSAttributedStringKey: Any] = [
let attr: [NSAttributedString.Key: Any] = [
.verticalGlyphForm: true,
.baselineOffset: (font?.pointSize ?? 24) * 0.25,
]
attrString.addAttributes(attr, range: tokenRange)
}
guard shouldDrawFurigana else { continue }
if let (furigana, range) = tokenizer.currentFuriganaAnnotation(in: string) {
var attr: [NSAttributedStringKey: Any] = [.rubyAnnotationSizeFactor: 0.5]
var attr: [NSAttributedString.Key: Any] = [.rubyAnnotationSizeFactor: 0.5]
attr[.ctForegroundColor] = textColor
let annotation = CTRubyAnnotation.create(furigana, attributes: attr)
attrString.addAttribute(.rubyAnnotation, value: annotation, range: range)
Expand Down

0 comments on commit ba6963d

Please sign in to comment.