Skip to content

[WIP] Swift 3.0 Compatibility #277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 127 commits into from
Sep 3, 2016
Merged

[WIP] Swift 3.0 Compatibility #277

merged 127 commits into from
Sep 3, 2016

Conversation

norio-nomura
Copy link
Contributor

@norio-nomura norio-nomura commented Apr 1, 2016

@norio-nomura
Copy link
Contributor Author

It seems updating test script for Linux is not needed.

@norio-nomura norio-nomura changed the title [WIP] Swift 3 Compatibility Swift 3 Compatibility Apr 1, 2016
@norio-nomura norio-nomura changed the title Swift 3 Compatibility Swift 3.0 Compatibility Apr 1, 2016
@briancroom
Copy link
Member

Wow, this looks really great @norio-nomura! I'm especially impressed that you were able to achieve such good 2.2-3.0 compatibility. Could you rebase this when you get a chance?

@norio-nomura
Copy link
Contributor Author

Rebased.

}
}

public protocol Sequence: SequenceType {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For supporting uses associatedtype constraints on some functions, Sequence is defined as protocol inheriting SequenceType.
That would require some SequenceType types defined on consumer to conform as:

#if !swift(>=3)
extension MyCustomSequence: Nimble.Sequence {}
#endif

@briancroom
Copy link
Member

Hi @norio-nomura, I'm sorry that there's been so little activity around here for so long.

I'm inclined to say that we're best off introducing a swift3 branch for this for now, since the development snapshots are such a fast-moving target at this point and I feel like there's going to be a good bit of churn needed here to keep up. I would tentatively suggest that we could put this on master and do lightweight maintenance of a swift2.2 branch around WWDC-time, when official Swift 3 beta releases will presumably start to be pushed out.

Thoughts @norio-nomura @Quick/contributors?

@norio-nomura
Copy link
Contributor Author

This PR has already been incompatible with swift-DEVELOPMENT-SNAPSHOT-2016-04-12 because of SE-0046 Establish consistent label behavior across all parameters including first labels.
Almost of functions and methods need to be enclosed with #if swift(>=3) for supporting both of swift 2.2 and 3. e.g. https://github.com/antitypical/Result/pull/149/files

@norio-nomura
Copy link
Contributor Author

I can't say which is better whether supporting swift-2.2 and 3 simultaneously or branching them.

@modocache
Copy link
Member

I'd like to reiterate my thought that XCTest should export both APIs until Swift 3 is officially released: SR-1215. We're doing very little to make things smooth for early adopters of corelibs-xctest, I think we could do better in that respect.

@briancroom
Copy link
Member

In light of the comments on this PR, this discussion, and the evidence of the complexity of supporting 2.2 and 3 simultaneously as linked to above, I'm pretty convinced at this point that branching is required here. Additionally, I feel that the swift3 branch will need to track the development snapshots pretty closely for the next while, as breaking changes continue to roll in. Given all that, I don't think there is much value in keeping the Swift3to22.swift shim in this PR.

@norio-nomura how would you feel about updating this to work with swift-DEVELOPMENT-SNAPSHOT-2016-04-25? I think we can use this as a start of a swift3 branch at that point.

@modocache
Copy link
Member

Makes sense to me! Theoretically it's possible to have CI build the Swift 3 branch by compiling Swift from source, then passing SWIFT_EXEC to xcodebuild. That seems like overkill, though--should we just go without CI for Swift 3?

@norio-nomura norio-nomura changed the title Swift 3.0 Compatibility [WIP] Swift 3.0 Compatibility Apr 29, 2016
@norio-nomura
Copy link
Contributor Author

I'd happy to update nn-swift-3-compatibility to work with swift-DEVELOPMENT-SNAPSHOT-2016-04-25 and drop supporting swift-2.2. I hope I would do that before next snapshot coming.

@briancroom
Copy link
Member

Hmm, I wonder how feasible it would be to download and install a toolchain package until Travis starts getting Xcode betas that include a Swift 3 toolchain? Even if we decide not to do that, the Linux CI should still Just Work here, as it is already downloading and installing the specified dev snapshot.

@ashfurrow
Copy link
Member

If Travis is difficult with OS X builds, I think removing them and keeping Linux for now would be a reasonable compromise.

@norio-nomura
Copy link
Contributor Author

We can use Swift 3 with Xcode 7.3 on Travis-CI as following: https://github.com/norio-nomura/SWXMLHash/blob/nn-swift22-and-swift3-compatibility/.travis.yml#L11-L18

@briancroom
Copy link
Member

That looks worth trying to me!

@norio-nomura
Copy link
Contributor Author

norio-nomura commented May 6, 2016

Rebased and updated to swift-DEVELOPMENT-SNAPSHOT-2016-05-03-a.

  • Removed Swift 2.2 support. Swift3to22.swift remains for linux support.
  • podspec fails since swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a
  • BeCloseToTest fails on linux since swift-DEVELOPMENT-SNAPSHOT-2016-05-03-a

Support Xcode 8 beta 6 and Preview 6
@raphaelcruzeiro
Copy link
Contributor

Did you have success using this branch of Nimble to tests actual projects? I'm trying to convert my tests to use this version of Nimble with Swift 3 and I have errors everywhere I use beCloseTo. Namely, Generic parameter 'T' could not be inferred and Ambiguous reference to member 'beCloseTo(_:within:)'. My guess is that Nimble is not working well with CGFloat.

@ikesyo
Copy link
Member

ikesyo commented Aug 23, 2016

ReactiveCocoa did: ReactiveCocoa/ReactiveCocoa#3145

@norio-nomura
Copy link
Contributor Author

@raphaelcruzeiro CGFloat was implicitly converted to NSNumber on Swift 2.2.
SE-0072 removes those conversions.
Casting your CGFloat to NSNumber will help you.
Of course PR will be welcomed. 😉

@norio-nomura
Copy link
Contributor Author

Maybe making CGFloat conforming to NMBDoubleConvertible will be better resolution.

@raphaelcruzeiro
Copy link
Contributor

@norio-nomura Agreed. I'm gonna start working on that then ;)

@norio-nomura
Copy link
Contributor Author

Now CGFloat conforms to NMBDoubleConvertible by https://github.com/norio-nomura/Nimble/pull/7
Thank you @raphaelcruzeiro!

@pcantrell
Copy link
Contributor

@raphaelcruzeiro: Siesta has been using this fork successfully (and the corresponding Quick fork as well). On the beCloseTo question, I’ve had success using and ±:

https://github.com/bustoutsolutions/siesta/blob/swift3/Tests/ProgressSpec.swift#L112

I was even able to remove a Double(…) coercion that Swift 2 required.

Thanks, @norio-nomura, for keeping these forks going!

@raphaelcruzeiro
Copy link
Contributor

Now that CGFloat conforms to NMBDoubleConvertible it should work fine for all the matchers.

And yeah! Thanks to @norio-nomura for taking the step forward and getting this branch up and working!

ikesyo and others added 3 commits August 25, 2016 00:49
`CGFloat` is in Foundation (swift-corelibs-foundation) on Linux.
Add NMBDoubleConvertible conformance to CGFloat on Linux
ikesyo and others added 2 commits September 3, 2016 00:32
# Conflicts:
#	.travis.yml
#	test
@ikesyo
Copy link
Member

ikesyo commented Sep 3, 2016

I'd like to officially manage Swift 3 migration in this repo and I've created swift-3.0 branch. @norio-nomura Could you change the base branch of this PR to that branch? Once that is done, I would merge this and submit a new PR from the branch to master. Then, subsequent PRs for Swift 3 should be targeted on the branch.

@norio-nomura norio-nomura changed the base branch from master to swift-3.0 September 3, 2016 08:17
@norio-nomura
Copy link
Contributor Author

@ikesyo Thanks! I have changed base branch to swift-3.0. 🙏

@ikesyo
Copy link
Member

ikesyo commented Sep 3, 2016

Thank you @norio-nomura and all who contributed to Swift 3 support on this PR! 🎉

@ikesyo ikesyo merged commit 4b539a2 into Quick:swift-3.0 Sep 3, 2016
@norio-nomura norio-nomura deleted the nn-swift-3-compatibility branch September 3, 2016 09:11
Megal pushed a commit to Megal/Nimble that referenced this pull request Jul 31, 2019
phatblat pushed a commit to phatblat/Nimble that referenced this pull request May 3, 2020
Quick.xcodeproj: Lower iOS deployment target to 7.0
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.