Skip to content

Conversation

sunshinejr
Copy link
Contributor

@sunshinejr sunshinejr commented Oct 11, 2017

Hey guys!

Here with another SPM fix. This time for Swift 4 specifically. Seems like last time I was using Swift 3.2 for Quick, even though I've built it in with SPM/Swift4. This time, when switching to Swift 4.0 on Quick, I've seen an error due to XCTest.defaultTestSuite() change. Basically in Swift 3.* XCTest.defaultTestSuite() is a method and in Swift 4.* it is a variable, making the build fail.

I've fixed this one using if swift(>=4), but I'm all ears if you have another fix in mind.

Also, this could appear everywhere with Swift 4, not only SPM, but SPM was the only one I’ve tested.

Cheers!

@QuickBot
Copy link

QuickBot commented Oct 11, 2017

1 Warning
⚠️ Need to add an unit test if you’re modifying swift source

Generated by 🚫 danger

if let superclass = class_getSuperclass(subclass), superclass === klass {
block(subclass as! T.Type) // swiftlint:disable:this force_cast
}
guard let superclass = class_getSuperclass(subclass), superclass == klass else { continue }
Copy link
Contributor Author

@sunshinejr sunshinejr Oct 12, 2017

Choose a reason for hiding this comment

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

I'll need some help here. When using ===, there is still a runtime crash (EXC_BAD_ACCESS). For now I did == and it doesn't crash, but we probably need to find a real problem 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@ikesyo ikesyo left a comment

Choose a reason for hiding this comment

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

Sorry for the delay!

if let superclass = class_getSuperclass(subclass), superclass === klass {
block(subclass as! T.Type) // swiftlint:disable:this force_cast
}
guard let superclass = class_getSuperclass(subclass), superclass == klass else { continue }
Copy link
Member

Choose a reason for hiding this comment

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

/// discovered powered by Objective-C runtime), so we needed the alternative
/// way.
#if swift(>=4)
override open static var defaultTestSuite: XCTestSuite {
Copy link
Member

Choose a reason for hiding this comment

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

@sunshinejr
Copy link
Contributor Author

Thanks for the review @ikesyo! I've changed static to class, let me know if there is anything more to do in this PR.

Copy link
Member

@ikesyo ikesyo left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Thanks for the PR!

@ikesyo ikesyo merged commit f031ff0 into Quick:master Nov 25, 2017
@sunshinejr sunshinejr deleted the fix/spm_swift4 branch February 5, 2018 13:20
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.

3 participants