-
Notifications
You must be signed in to change notification settings - Fork 86
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
Swift 3 support #65
Conversation
Without this, Xcode complains about the legacy Swift version not being set.
@hyperspacemark @soffes would you mind reviewing this? |
Also, mfw I'm not a maintainer of this project because I'm not part of the @venmo org anymore. |
...because Travis CI is so good.
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.
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 { |
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.
⬅️
// 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 { |
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.
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
?
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 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) |
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.
⬅️
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 { |
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.
⬅️
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 { |
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.
⬅️
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 { |
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.
⬅️
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 { |
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.
⬅️
print("[DVR] Persisted cassette at \(outputPath). Please add this file to your test target") | ||
return |
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.
⬅️
Thanks for owning this @eliperkins <3 |
* 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
* 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
* 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
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.