Skip to content
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 support #65

Merged
merged 17 commits into from
Jan 23, 2017
Merged

Swift 3 support #65

merged 17 commits into from
Jan 23, 2017

Conversation

eliperkins
Copy link
Contributor

This brings in the work that @soffes and @n8armstrong have done on getting the Swift 3 branch going.

Supercedes #60 which seems to have become stale.

@eliperkins
Copy link
Contributor Author

@hyperspacemark @soffes would you mind reviewing this?

@eliperkins
Copy link
Contributor Author

Also, mfw I'm not a maintainer of this project because I'm not part of the @venmo org anymore.

Copy link
Contributor

@lionel-alves lionel-alves left a comment

Choose a reason for hiding this comment

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

Thanks for getting that going Eli!

One naming suggestion but would love to have this merged 🍏

// MARK: - Helpers

extension String {
func UTF8Data() -> NSData {
return dataUsingEncoding(NSUTF8StringEncoding)!
fileprivate var utf8Data: Data {
Copy link
Contributor

Choose a reason for hiding this comment

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

⬅️

// There isn't a mutable NSHTTPURLResponse, so we have to make our own.
class URLHTTPResponse: NSHTTPURLResponse {
// There isn't a mutable HTTPURLResponse, so we have to make our own.
class HTTPURLResponse: Foundation.HTTPURLResponse {
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming this class HTTPURLResponse requires us to use Foundation.HTTPURLResponse in a lot of places here and could be confusing. What do you think about MutableHTTPURLResponse since it's a mutable version of HTTPURLResponse?

Copy link
Contributor

Choose a reason for hiding this comment

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

I had a similar concern but since this isn't a part of the public API, I think we can address it later and not block merging this.

extension HTTPURLResponse {
convenience init(dictionary: [String: Any]) {
let url = URL(string: dictionary["url"] as! String)!
self.init(url: url, mimeType: nil, expectedContentLength: 0, textEncodingName: nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

⬅️

return addDataTask(request)
}

public override func dataTaskWithRequest(request: NSURLRequest, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> NSURLSessionDataTask {
open override func dataTask(with request: URLRequest, completionHandler: @escaping ((Data?, Foundation.URLResponse?, Error?) -> Void)) -> URLSessionDataTask {
Copy link
Contributor

Choose a reason for hiding this comment

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

⬅️

return addDownloadTask(request)
}

public override func downloadTaskWithRequest(request: NSURLRequest, completionHandler: (NSURL?, NSURLResponse?, NSError?) -> Void) -> NSURLSessionDownloadTask {
open override func downloadTask(with request: URLRequest, completionHandler: @escaping (URL?, Foundation.URLResponse?, Error?) -> Void) -> URLSessionDownloadTask {
Copy link
Contributor

Choose a reason for hiding this comment

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

⬅️

return addUploadTask(request, fromData: bodyData)
}

public override func uploadTaskWithRequest(request: NSURLRequest, fromData bodyData: NSData?, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> NSURLSessionUploadTask {
open override func uploadTask(with request: URLRequest, from bodyData: Data?, completionHandler: @escaping (Data?, Foundation.URLResponse?, Error?) -> Void) -> URLSessionUploadTask {
Copy link
Contributor

Choose a reason for hiding this comment

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

⬅️

return addUploadTask(request, fromData: data)
}

public override func uploadTaskWithRequest(request: NSURLRequest, fromFile fileURL: NSURL, completionHandler: (NSData?, NSURLResponse?, NSError?) -> Void) -> NSURLSessionUploadTask {
let data = NSData(contentsOfURL: fileURL)!
open override func uploadTask(with request: URLRequest, fromFile fileURL: URL, completionHandler: @escaping (Data?, Foundation.URLResponse?, Error?) -> Void) -> URLSessionUploadTask {
Copy link
Contributor

Choose a reason for hiding this comment

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

⬅️

print("[DVR] Persisted cassette at \(outputPath). Please add this file to your test target")
return
Copy link
Contributor

Choose a reason for hiding this comment

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

⬅️

@soffes
Copy link
Contributor

soffes commented Jan 23, 2017

Thanks for owning this @eliperkins <3

@hyperspacemark hyperspacemark merged commit f042a92 into venmo:master Jan 23, 2017
@eliperkins eliperkins deleted the ep/swift3 branch January 23, 2017 20:33
olegdanu-newstore pushed a commit to NewStore/DVR that referenced this pull request Sep 27, 2018
* Update to Swift 3

* Bump version 0.4.0

* Rename HTTPURLResponse file too

* Prefer private over fileprivate

* Fix serializating HTTPURLResponse

* Don't say we failed if we didn't

* Swift 3.0.1

* tvOS target

* Swift 3.0.1

* Fix tvOS deployment target

* Fix upload tests

* Explicitly set SWIFT_VERSION

Without this, Xcode complains about the legacy Swift version not being
set.

* Remove explicit toolchain from CI

* Specify SDK for CI

* Add destinations for CI

...because Travis CI is so good.

* Use latest version of Xcode

* Clean up spacing
olegdanu-newstore pushed a commit to NewStore/DVR that referenced this pull request Sep 28, 2018
* Update to Swift 3

* Bump version 0.4.0

* Rename HTTPURLResponse file too

* Prefer private over fileprivate

* Fix serializating HTTPURLResponse

* Don't say we failed if we didn't

* Swift 3.0.1

* tvOS target

* Swift 3.0.1

* Fix tvOS deployment target

* Fix upload tests

* Explicitly set SWIFT_VERSION

Without this, Xcode complains about the legacy Swift version not being
set.

* Remove explicit toolchain from CI

* Specify SDK for CI

* Add destinations for CI

...because Travis CI is so good.

* Use latest version of Xcode

* Clean up spacing
olegdanu-newstore pushed a commit to NewStore/DVR that referenced this pull request Sep 28, 2018
* Update to Swift 3

* Bump version 0.4.0

* Rename HTTPURLResponse file too

* Prefer private over fileprivate

* Fix serializating HTTPURLResponse

* Don't say we failed if we didn't

* Swift 3.0.1

* tvOS target

* Swift 3.0.1

* Fix tvOS deployment target

* Fix upload tests

* Explicitly set SWIFT_VERSION

Without this, Xcode complains about the legacy Swift version not being
set.

* Remove explicit toolchain from CI

* Specify SDK for CI

* Add destinations for CI

...because Travis CI is so good.

* Use latest version of Xcode

* Clean up spacing
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.

5 participants