-
Notifications
You must be signed in to change notification settings - Fork 601
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
Swift 3.0 support #192
Swift 3.0 support #192
Conversation
Sorry about the |
Not a problem, I can squash them if you want with a more meaningful message 😄 |
Thanks a lot for this PR @Liquidsoul ! Sometimes the CI fails for no reason (well… for timeout reasons and for Xcode CLI tools weirdness randomly returning error code 65, see #188). I just asked Travis to restart the build, let's hope and see. Also, could you please add an entry in the |
return { req in req.url?.path?.hasPrefix(path) ?? false } | ||
#else | ||
return { req in req.url?.path?.hasPrefix(path) ?? false } | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm tired but I don't see the difference between the code for #if os(tvOS)
and for #else
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a bad merge. But this was there (with a difference I thought) because the legacy-swift setting for the tvOS target was YES
(should be NO
). I fixed this in my fork, so this #if os(tvOS)
shouldn't be there and the legacy-swift setting should be checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 81017a6be3596ad16651bb5a522b7338fe63d984 fixes this but I forgot to remove this conditional 😊
Additionally @mxcl @Liquidsoul As an effort to adhere to the Moya contribution guidelines*, I've added you as collaborator to You'll now be able to create branches directly on the project (instead of having to have your fork) and have the ability to triage and label issues & PRs too. Use those new rights to your liking — or don't use them at all, it's up to you. * still haven't found the time to properly copy the |
Thanks @AliSoftware ! About this PR, I wonder if we should merge it as-is. My advice would be to set |
CocoaPods users can work around this thanks for the PRs: CocoaPods/CocoaPods#5540, CocoaPods/CocoaPods#5760 but Carthage users can't.
👍 from me. |
I've updated the PR to set the |
IMO people are more likely to use Swift 3.0 than 2.3. Anyone using Swift is used to having to update and will want to be using the latest versions of everything. |
@mxcl I honestly don't know. I mean, at work for client projects we're still on 2.3. Hell for some projects we're even still on 2.2. Because it would be really time-consuming to migrate your code to the new beta of each Swift 3 release every time a new beta is released, and because we didn't sell the time for that to the client and don't have time nor leisure to take the risk. OTOH, on personal projects where there's less strict deadlines and where we want to use Swift 3 as soon as each new beta is released to be always on top, we might prefer Swift 3 over 2.3. I think until Swift 3 / Xcode 8 is officially released we can keep 2.3 in the example project, and change that to 3 once Swift 3 is official (even if it should be quite soon now). Thoughts? PS: @Liquidsoul I'm not sure I understand your last comment, since when I look at the Changed Files tab, I see |
@AliSoftware The full diff can be misleading. This is because I've configured the Swift version at the project level and so removed the settings on the targets (see commit 9010c3a22636cbf8a7f904483001b76749d25f17). |
All tests do not pass yet
SWIFT_VERSION is now configured only at the project level
We need to cast to NSURL because URL.path does not behave like NSURL.path in Swift 3.0. URL.path does not stop at the first ';' and returns the entire string.
Got it! |
I've fixed the conflicts, hope this will pass the CI on first try ! 😁 |
We should probably add something in the
Problem is, if we do that, what about past September once Swift 3 is released, will we switch Note: I'm not a Carthage user, so idk if there's a way to generate multiple pre-build framework for Carthage in GitHub Releases (one for 2.3 and one for 3.0) and let the users specify which pre-build version they want to download / depend on? Or will they be force to use |
@@ -8,6 +8,8 @@ | |||
[@ikesyo](https://github.com/ikesyo), [#185](https://github.com/AliSoftware/OHHTTPStubs/pull/185) | |||
* Fix: Carthage support and Examples configurations | |||
[@Liquidsoul](https://github.com/Liquidsoul), [#190](https://github.com/AliSoftware/OHHTTPStubs/issues/190) | |||
* Added Swift 3.0 support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip: please add two spaces after the full-stop, so that the markdown renders a line break and renders the next line as a separate line (otherwise it will join the lines) 😉
Fair point. The ticket I've opened against Carthage may make our setting moot anyway. It's a pity Apple didn't anticipate this sort of scenario and make the setting inheritable. Perhaps they did and we just don't understand how to use it. |
I do not think this is that bad for Carthage users. They would just have to update the dependency as for any version bump, but I may be wrong. Maybe we should consider the standard user case, not the beta users? The ones using Xcode 7.x, with Swift 2.2 and who will migrate automatically to Xcode 8 in september. |
@Liquidsoul Swift 2.2 and Swift 2.3 are not ABI-compatible afaik. This means that even in your example use case, after upgrading from Xcode 7 (and using Swift 2.2) to Xcode 8 (+ |
They won't need to use a different version of |
Fair enough. I'm convinced 😉 So here's what I propose, does it match your idea of the ideal solution you suggested above?
Does that feel right to you? (And if so, do you feel like documenting this on a user's perspective in the |
Seems perfect 👍 |
I suggest that I create another pull-request for the |
Both are fine by me. Seems more logical to me to have everything related in the same PR but it's up to you. |
You're right, seems more logical to have it here. |
I've added something in the Carthage section about Xcode 7 😉 |
🎉 time to merge this 👍 |
5.2.0 is live now! 🎉 Thanks again for the good work folks, nicely done! 👍 👌 |
Hi !
I have picked up the work of @mxcl to make OHHTTPStubs support swift 3.0.
The objective was to make the code works on every version of swift (2.2, 2.3, 3.0) to fix issue #189.
To achieve this, I made some tradeoffs.
Remove first parameter label in Swift 3.0
To avoid declaring the methods multiple times to support both 2.3 and 3.0 syntax, some warnings are generated when using 2.x compilers.
For example, so that we can still use
isPath("myPath")
in Swift 3.0, the declaration has been changed tofunc isPath(_ path: String) -> OHHTTPStubsTestBlock
.This generates the following warning on 2.x compilers:
Extraneous '_' in parameter: 'path' has no keyword argument name
Multiple
#if
branching to instantiate eitherURLRequest
orNSURLRequest
in testsWhile we could do some tricks using extensions to support 3.0 methods and attributes in swift 2.x, this is not feasible for a whole
struct
/class
likeURLRequest
/NSURLRequest
. So, in the tests, every time we were instantiating aNSURLRequest
object, the call is now replaced by the creation of aURLRequest
value-type using#if
branching.We may want to factorize this code into a helper function in the test class though. But this may need to convert all
NSURLRequest
toNSMutableURLRequest
to have only one method call.Use
NSURL
'spath
inisPath
instead ofURL
'spath
The
path
property onURL
does not behave as the one inNSURL
. InURL
, the path is not truncated at the first semicolon. This has the effect to make the actual tests fail. So to fix this, I usedNSURL
'spath
.For this pull request, I used the swift version of Xcode 8 beta 4.
I hope this helps!