Skip to content

Update to Swift 4, Xcode 9.2#126

Merged
keith merged 20 commits intobr1sk:masterfrom
hannesoid:swift4
Jan 23, 2018
Merged

Update to Swift 4, Xcode 9.2#126
keith merged 20 commits intobr1sk:masterfrom
hannesoid:swift4

Conversation

@hannesoid
Copy link
Copy Markdown
Contributor

What this contains

  • updates project to Swift 4 and update project settings & warnings to Xcode 9.2
  • changes OpenRadar parsing to use KeyPaths and not blocks
  • get Attachement dropping to work (still a bit confused though)
  • Touched storyboard to make Xcode happy

Tests

  • I ran the unit tests successfully locally
  • I ran the application and clicked around
  • I didn't test any actual submissions or dupe-creating, maybe somebody could do this?

Copy link
Copy Markdown
Member

@keith keith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a first pass, this looks great! I’ll look at the key path stuff soon


private func setupStatusItem() {
let image = NSImage(named: "StatusItemIcon")!
let image = NSImage(named: NSImage.Name(rawValue: "StatusItemIcon"))!
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, super weird this isn’t the same as UIKit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed! 😜

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use an image literal, but I think it's not supported on older macs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the docs say this type is 10.13+, but I assume that's not actually true

extension NSStatusItem {
static func create(image: NSImage, menu: NSMenu) -> NSStatusItem {
let statusItem = NSStatusBar.system().statusItem(withLength: NSVariableStatusItemLength)
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you omit the enum or is this just a constant?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.variableLength seems to be a CGFloat, so NSStatusItem can't be omitted

import AppKit

private let kMainStoryboard = NSStoryboard(name: "Main", bundle: nil)
private let kMainStoryboard = NSStoryboard(name: NSStoryboard.Name(rawValue: "Main"), bundle: nil)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there’s no string one for this either?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find anyhing simpler…

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can change NSStoryboard.Name to .init and that'll also solve the line length here

extension NSTextView {
var stringValue: String {
return self.string ?? ""
return self.string
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I wonder if we can remove this property now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

extension NSTextView: Validatable {
var isValid: Bool {
return self.string?.isEmpty == false
return self.string.isEmpty == false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use ! Here instead of == false now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@hannesoid
Copy link
Copy Markdown
Contributor Author

Thanks @keith! I did the little string things

Copy link
Copy Markdown
Member

@keith keith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few minor comments

public var steps: String?
public var version: String?
fileprivate var appendingToActual: String? {
get { return actual }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.actual

public var version: String?
fileprivate var appendingToActual: String? {
get { return actual }
set { actual = appendOrReturn(actual, newValue) }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.actual twice

private var files: [String] {
return self.draggingPasteboard().propertyList(forType: NSFilenamesPboardType) as? [String] ?? []
private var files: [URL] {
let asStrings = self.draggingPasteboard().propertyList(forType: makeFileNameType()) as? [String] ?? []
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace makeFileNameType inline with .init(rawValue: "foo") for this case IMO

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left the makeFileNameType() in place as it is used twice and gives room for the explainatory comment. Maybe in the future somebody with more thorough macOS SDK knowledge than me could find a way to use the enum and not stringy version.

@keith
Copy link
Copy Markdown
Member

keith commented Jan 15, 2018

I think the build is failing here because of SWIFT_VERSION + Pods, you can apply this patch:

diff --git i/Podfile w/Podfile
index 66fb2ac..9066034 100644
--- i/Podfile
+++ w/Podfile
@@ -13,4 +13,10 @@ end
 
 post_install do |installer|
   installer.pods_project.root_object.attributes["LastUpgradeCheck"] = "9999"
+
+  installer.pods_project.targets.each do |target|
+    target.build_configurations.each do |config|
+      config.build_settings["SWIFT_VERSION"] = "4.0"
+    end
+  end
 end

And it should fix that

@keith
Copy link
Copy Markdown
Member

keith commented Jan 15, 2018

Lint is failing here too, I think there's a false positive because I haven't updated it in a while, trying it locally. There's also some long lines, currently we require a max of 110 columns, see the log for where

"observed results": \.appendingToActual,
"steps to reproduce": \.steps,
"summary": \.description,
"version": \.version
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a trailing comma so the diff if we add another field will be smaller

@keith
Copy link
Copy Markdown
Member

keith commented Jan 15, 2018

Also please add a changelog entry here under enhancements

@keith
Copy link
Copy Markdown
Member

keith commented Jan 15, 2018

I don't see that lint failure locally with either version, I'll land #130 and you can rebase and hopefully it'll pass

@hannesoid
Copy link
Copy Markdown
Contributor Author

hannesoid commented Jan 16, 2018

I rebased, then did the other things, starting d4d28ae.

## Enhancements

- None.
- Update project to Swift 4.0 and Xcode 9.2
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include the URL here like below

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sure, I overlooked that

@hannesoid
Copy link
Copy Markdown
Contributor Author

Travis was still set to xcode8.3, which doesn't support swift 4…

@keith
Copy link
Copy Markdown
Member

keith commented Jan 18, 2018 via email

@hannesoid
Copy link
Copy Markdown
Contributor Author

Yep, did that.
Now the reason it is still failing on ci seems that Sonar is attempted to be compiled with Swift 4 instead of 3.

@keith
Copy link
Copy Markdown
Member

keith commented Jan 19, 2018

Ah the problem now is we need to upgrade Sonar once I merge this PR br1sk/Sonar#33

I'm just waiting on CI

@keith
Copy link
Copy Markdown
Member

keith commented Jan 19, 2018

That's merged so you can bundle exec pod update Sonar

@hannesoid
Copy link
Copy Markdown
Contributor Author

Yay, the checks have passed, @keith I think we could merge this now?

@keith keith merged commit 096c995 into br1sk:master Jan 23, 2018
@keith
Copy link
Copy Markdown
Member

keith commented Jan 23, 2018

Thanks for doing this!

@hannesoid
Copy link
Copy Markdown
Contributor Author

🎉

@hannesoid hannesoid deleted the swift4 branch January 23, 2018 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants