Skip to content

Commit 36a33fc

Browse files
author
hikaruna
committed
iOS8対応
1 parent 668cc5a commit 36a33fc

File tree

6 files changed

+5
-202
lines changed

6 files changed

+5
-202
lines changed

Alamofire.xcodeproj/project.pbxproj

+2
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,7 @@
16171617
DYLIB_INSTALL_NAME_BASE = "@rpath";
16181618
INFOPLIST_FILE = Source/Info.plist;
16191619
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
1620+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
16201621
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
16211622
PRODUCT_BUNDLE_IDENTIFIER = org.alamofire.Alamofire;
16221623
PRODUCT_NAME = Alamofire;
@@ -1634,6 +1635,7 @@
16341635
DYLIB_INSTALL_NAME_BASE = "@rpath";
16351636
INFOPLIST_FILE = Source/Info.plist;
16361637
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
1638+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
16371639
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
16381640
PRODUCT_BUNDLE_IDENTIFIER = org.alamofire.Alamofire;
16391641
PRODUCT_NAME = Alamofire;

Example/iOS Example.xcodeproj/project.pbxproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@
264264
31E476701C55DD5900968569 /* Alamofire OSX Tests.xctest */ = {
265265
isa = PBXReferenceProxy;
266266
fileType = wrapper.cfbundle;
267-
path = "Alamofire OSX Tests.xctest";
267+
path = "Alamofire macOS Tests.xctest";
268268
remoteRef = 31E4766F1C55DD5900968569 /* PBXContainerItemProxy */;
269269
sourceTree = BUILT_PRODUCTS_DIR;
270270
};
@@ -439,6 +439,7 @@
439439
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
440440
CLANG_ENABLE_MODULES = YES;
441441
INFOPLIST_FILE = Resources/Info.plist;
442+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
442443
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
443444
PRODUCT_BUNDLE_IDENTIFIER = "org.alamofire.iOS-Example";
444445
PRODUCT_NAME = "iOS Example";
@@ -454,6 +455,7 @@
454455
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
455456
CLANG_ENABLE_MODULES = YES;
456457
INFOPLIST_FILE = Resources/Info.plist;
458+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
457459
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
458460
PRODUCT_BUNDLE_IDENTIFIER = "org.alamofire.iOS-Example";
459461
PRODUCT_NAME = "iOS Example";

Source/Alamofire.swift

-36
Original file line numberDiff line numberDiff line change
@@ -418,39 +418,3 @@ public func upload(
418418
encodingCompletion: encodingCompletion
419419
)
420420
}
421-
422-
#if !os(watchOS)
423-
424-
// MARK: - Stream Request
425-
426-
// MARK: Hostname and Port
427-
428-
/// Creates a `StreamRequest` using the default `SessionManager` for bidirectional streaming with the `hostname`
429-
/// and `port`.
430-
///
431-
/// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned.
432-
///
433-
/// - parameter hostName: The hostname of the server to connect to.
434-
/// - parameter port: The port of the server to connect to.
435-
///
436-
/// - returns: The created `StreamRequest`.
437-
@discardableResult
438-
public func stream(withHostName hostName: String, port: Int) -> StreamRequest {
439-
return SessionManager.default.stream(withHostName: hostName, port: port)
440-
}
441-
442-
// MARK: NetService
443-
444-
/// Creates a `StreamRequest` using the default `SessionManager` for bidirectional streaming with the `netService`.
445-
///
446-
/// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned.
447-
///
448-
/// - parameter netService: The net service used to identify the endpoint.
449-
///
450-
/// - returns: The created `StreamRequest`.
451-
@discardableResult
452-
public func stream(with netService: NetService) -> StreamRequest {
453-
return SessionManager.default.stream(with: netService)
454-
}
455-
456-
#endif

Source/Request.swift

-27
Original file line numberDiff line numberDiff line change
@@ -571,30 +571,3 @@ open class UploadRequest: DataRequest {
571571
return self
572572
}
573573
}
574-
575-
// MARK: -
576-
577-
#if !os(watchOS)
578-
579-
/// Specific type of `Request` that manages an underlying `URLSessionStreamTask`.
580-
open class StreamRequest: Request {
581-
enum Streamable: TaskConvertible {
582-
case stream(hostName: String, port: Int)
583-
case netService(NetService)
584-
585-
func task(session: URLSession, adapter: RequestAdapter?, queue: DispatchQueue) throws -> URLSessionTask {
586-
let task: URLSessionTask
587-
588-
switch self {
589-
case let .stream(hostName, port):
590-
task = queue.syncResult { session.streamTask(withHostName: hostName, port: port) }
591-
case let .netService(netService):
592-
task = queue.syncResult { session.streamTask(with: netService) }
593-
}
594-
595-
return task
596-
}
597-
}
598-
}
599-
600-
#endif

Source/SessionDelegate.swift

-80
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,6 @@ open class SessionDelegate: NSObject {
103103
/// Overrides default behavior for URLSessionDownloadDelegate method `urlSession(_:downloadTask:didResumeAtOffset:expectedTotalBytes:)`.
104104
open var downloadTaskDidResumeAtOffset: ((URLSession, URLSessionDownloadTask, Int64, Int64) -> Void)?
105105

106-
// MARK: URLSessionStreamDelegate Overrides
107-
108-
#if !os(watchOS)
109-
110-
/// Overrides default behavior for URLSessionStreamDelegate method `urlSession(_:readClosedFor:)`.
111-
open var streamTaskReadClosed: ((URLSession, URLSessionStreamTask) -> Void)?
112-
113-
/// Overrides default behavior for URLSessionStreamDelegate method `urlSession(_:writeClosedFor:)`.
114-
open var streamTaskWriteClosed: ((URLSession, URLSessionStreamTask) -> Void)?
115-
116-
/// Overrides default behavior for URLSessionStreamDelegate method `urlSession(_:betterRouteDiscoveredFor:)`.
117-
open var streamTaskBetterRouteDiscovered: ((URLSession, URLSessionStreamTask) -> Void)?
118-
119-
/// Overrides default behavior for URLSessionStreamDelegate method `urlSession(_:streamTask:didBecome:outputStream:)`.
120-
open var streamTaskDidBecomeInputAndOutputStreams: ((URLSession, URLSessionStreamTask, InputStream, OutputStream) -> Void)?
121-
122-
#endif
123-
124106
// MARK: Properties
125107

126108
var retrier: RequestRetrier?
@@ -165,21 +147,6 @@ open class SessionDelegate: NSObject {
165147
}
166148
#endif
167149

168-
#if !os(watchOS)
169-
switch selector {
170-
case #selector(URLSessionStreamDelegate.urlSession(_:readClosedFor:)):
171-
return streamTaskReadClosed != nil
172-
case #selector(URLSessionStreamDelegate.urlSession(_:writeClosedFor:)):
173-
return streamTaskWriteClosed != nil
174-
case #selector(URLSessionStreamDelegate.urlSession(_:betterRouteDiscoveredFor:)):
175-
return streamTaskBetterRouteDiscovered != nil
176-
case #selector(URLSessionStreamDelegate.urlSession(_:streamTask:didBecome:outputStream:)):
177-
return streamTaskDidBecomeInputAndOutputStreams != nil
178-
default:
179-
break
180-
}
181-
#endif
182-
183150
switch selector {
184151
case #selector(URLSessionDelegate.urlSession(_:didBecomeInvalidWithError:)):
185152
return sessionDidBecomeInvalidWithError != nil
@@ -632,50 +599,3 @@ extension SessionDelegate: URLSessionDownloadDelegate {
632599
}
633600
}
634601
}
635-
636-
// MARK: - URLSessionStreamDelegate
637-
638-
#if !os(watchOS)
639-
640-
extension SessionDelegate: URLSessionStreamDelegate {
641-
/// Tells the delegate that the read side of the connection has been closed.
642-
///
643-
/// - parameter session: The session.
644-
/// - parameter streamTask: The stream task.
645-
open func urlSession(_ session: URLSession, readClosedFor streamTask: URLSessionStreamTask) {
646-
streamTaskReadClosed?(session, streamTask)
647-
}
648-
649-
/// Tells the delegate that the write side of the connection has been closed.
650-
///
651-
/// - parameter session: The session.
652-
/// - parameter streamTask: The stream task.
653-
open func urlSession(_ session: URLSession, writeClosedFor streamTask: URLSessionStreamTask) {
654-
streamTaskWriteClosed?(session, streamTask)
655-
}
656-
657-
/// Tells the delegate that the system has determined that a better route to the host is available.
658-
///
659-
/// - parameter session: The session.
660-
/// - parameter streamTask: The stream task.
661-
open func urlSession(_ session: URLSession, betterRouteDiscoveredFor streamTask: URLSessionStreamTask) {
662-
streamTaskBetterRouteDiscovered?(session, streamTask)
663-
}
664-
665-
/// Tells the delegate that the stream task has been completed and provides the unopened stream objects.
666-
///
667-
/// - parameter session: The session.
668-
/// - parameter streamTask: The stream task.
669-
/// - parameter inputStream: The new input stream.
670-
/// - parameter outputStream: The new output stream.
671-
open func urlSession(
672-
_ session: URLSession,
673-
streamTask: URLSessionStreamTask,
674-
didBecome inputStream: InputStream,
675-
outputStream: OutputStream)
676-
{
677-
streamTaskDidBecomeInputAndOutputStreams?(session, streamTask, inputStream, outputStream)
678-
}
679-
}
680-
681-
#endif

Source/SessionManager.swift

-58
Original file line numberDiff line numberDiff line change
@@ -694,64 +694,6 @@ open class SessionManager {
694694
return upload
695695
}
696696

697-
#if !os(watchOS)
698-
699-
// MARK: - Stream Request
700-
701-
// MARK: Hostname and Port
702-
703-
/// Creates a `StreamRequest` for bidirectional streaming using the `hostname` and `port`.
704-
///
705-
/// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned.
706-
///
707-
/// - parameter hostName: The hostname of the server to connect to.
708-
/// - parameter port: The port of the server to connect to.
709-
///
710-
/// - returns: The created `StreamRequest`.
711-
@discardableResult
712-
open func stream(withHostName hostName: String, port: Int) -> StreamRequest {
713-
return stream(.stream(hostName: hostName, port: port))
714-
}
715-
716-
// MARK: NetService
717-
718-
/// Creates a `StreamRequest` for bidirectional streaming using the `netService`.
719-
///
720-
/// If `startRequestsImmediately` is `true`, the request will have `resume()` called before being returned.
721-
///
722-
/// - parameter netService: The net service used to identify the endpoint.
723-
///
724-
/// - returns: The created `StreamRequest`.
725-
@discardableResult
726-
open func stream(with netService: NetService) -> StreamRequest {
727-
return stream(.netService(netService))
728-
}
729-
730-
// MARK: Private - Stream Implementation
731-
732-
private func stream(_ streamable: StreamRequest.Streamable) -> StreamRequest {
733-
do {
734-
let task = try streamable.task(session: session, adapter: adapter, queue: queue)
735-
let request = StreamRequest(session: session, requestTask: .stream(streamable, task))
736-
737-
delegate[task] = request
738-
739-
if startRequestsImmediately { request.resume() }
740-
741-
return request
742-
} catch {
743-
return stream(failedWith: error)
744-
}
745-
}
746-
747-
private func stream(failedWith error: Error) -> StreamRequest {
748-
let stream = StreamRequest(session: session, requestTask: .stream(nil, nil), error: error)
749-
if startRequestsImmediately { stream.resume() }
750-
return stream
751-
}
752-
753-
#endif
754-
755697
// MARK: - Internal - Retry Request
756698

757699
func retry(_ request: Request) -> Bool {

0 commit comments

Comments
 (0)