Skip to content

Commit

Permalink
Merge pull request #15 from Flipkart/Swift4.2_Migration
Browse files Browse the repository at this point in the history
Enabled objective-c access for public items.
  • Loading branch information
rajatgupta26 committed Feb 15, 2019
2 parents 18923b5 + e77af53 commit c0c5f7e
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 39 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:
- DESTINATION="OS=4.2,name=Apple Watch Series 3 - 42mm" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" RUN_TESTS="NO" BUILD_EXAMPLE="NO" $RUN_PERFORMANCE_TESTS="NO" POD_LINT="NO"
- DESTINATION="OS=3.2,name=Apple Watch Series 2 - 42mm" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" RUN_TESTS="NO" BUILD_EXAMPLE="NO" $RUN_PERFORMANCE_TESTS="NO" POD_LINT="NO"


- DESTINATION="OS=12.1,name=iPhone XS" SCHEME="$IOS_FRAMEWORK_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="YES" $RUN_PERFORMANCE_TESTS="YES" POD_LINT="NO"
- DESTINATION="OS=11.4,name=iPhone X" SCHEME="$IOS_FRAMEWORK_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="YES" $RUN_PERFORMANCE_TESTS="NO" POD_LINT="NO"
- DESTINATION="OS=9.0,name=iPhone 6" SCHEME="$IOS_FRAMEWORK_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="NO" $RUN_PERFORMANCE_TESTS="NO" POD_LINT="NO"
Expand Down
2 changes: 2 additions & 0 deletions Example/Swifty.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,13 @@
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;

DevelopmentTeam = T2JTZB2M8B;
LastSwiftMigration = 1010;
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;

DevelopmentTeam = T2JTZB2M8B;
LastSwiftMigration = 1010;
TestTargetID = 607FACCF1AFB9204008FA782;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Core/Constraint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum TaskState {
open class Constraint {

/// Public initializer
public init(){}
@objc public init(){}

/// Synchronizer - makes sure that constraint evaluation is thread-safe.
let synchronizer = DispatchQueue(label: "swifty.constraintSyncronizer")
Expand Down Expand Up @@ -100,7 +100,7 @@ open class Constraint {
- Parameter error: NSError?
*/
public func finish(with error: Error?) {
@objc public func finish(with error: Error?) {
synchronizer.async {
self.state = .notExecuting
for task in self.tasks {
Expand Down
12 changes: 6 additions & 6 deletions Sources/Core/NetworkResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ public protocol ResponseParser {
// MARK: - Properties

/// The HTTPURLResponse receieved from the network
public var response : HTTPURLResponse?
@objc public var response : HTTPURLResponse?

/// The raw Data receieved from the network
public var data: Data?
@objc public var data: Data?

/// Error that response encountered (if any)
public var error: NSError?
@objc public var error: NSError?

/// The result of the response serialization
public var result: Any?
@objc public var result: Any?

/// The ResponseParser that Swifty should use to serialize this repsonse
public var parser: ResponseParser?
Expand Down Expand Up @@ -65,7 +65,7 @@ public protocol ResponseParser {
/// - Parameters:
/// - response: HTTPURLResponse?
/// - data: Data?
public func succeed(response: HTTPURLResponse?, data: Data?){
@objc public func succeed(response: HTTPURLResponse?, data: Data?){
self.response = response
self.data = data
self.error = nil
Expand All @@ -75,7 +75,7 @@ public protocol ResponseParser {
/// Forcefully fails the response, with the given error. This is especially useful in response interceptors.
///
/// - Parameter error: NSError.
public func fail(error: NSError){
@objc public func fail(error: NSError){
self.error = error
}
}
6 changes: 3 additions & 3 deletions Sources/Core/Swifty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct SwiftyInterceptors {
@objc final public class Swifty: NSObject {

/// Swifty's shared instance: It's highly recommended you create your own Swifty instances with your customizations (Constraints, Interceptors) instead of using the shared instance.
public static let shared = Swifty()
@objc public static let shared = Swifty()

/// The URLSession of this Swifty instance
let session: URLSession
Expand Down Expand Up @@ -95,7 +95,7 @@ struct SwiftyInterceptors {
/// - resource: NetworkResource
/// - successBlock: SwiftySuccessBlock
/// - failureBlock: SwiftyFailureBlock
public func add(_ resource: NetworkResource, successBlock: @escaping SwiftySuccessBlock, failureBlock: @escaping SwiftyFailureBlock){
@objc public func add(_ resource: NetworkResource, successBlock: @escaping SwiftySuccessBlock, failureBlock: @escaping SwiftyFailureBlock){
let task = SwiftyNetworkTask(resource: resource, session: session, interceptors: self.requestInterceptors)
// Swifty Enters the group
task.group.enter()
Expand Down Expand Up @@ -131,7 +131,7 @@ struct SwiftyInterceptors {
// MARK: - WebServiceNetworkInterface.
extension Swifty: WebServiceNetworkInterface {
/// Conforms Swifty's shared instance to the WebServiceNetworkInterface protocol, making it easy to use directly with a WebService.
public func loadResource(resource: NetworkResource, completion: @escaping (NetworkResponse) -> Void) {
@objc public func loadResource(resource: NetworkResource, completion: @escaping (NetworkResponse) -> Void) {
self.add(resource, successBlock: { (networkResponse) in
completion(networkResponse)
}, failureBlock: { (networkResponse) in
Expand Down
4 changes: 2 additions & 2 deletions Sources/Core/SwiftyNetworkTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
class SwiftyNetworkTask: Task {

/// Network Resource
public var resource: NetworkResource
@objc public var resource: NetworkResource

/// Session
internal let session: URLSession
Expand All @@ -29,7 +29,7 @@ class SwiftyNetworkTask: Task {
}

/// Print's the resource's description
public var description: String {
@objc public var description: String {
return resource.description
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/Task.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum Result {
class Task {

/// Public initializer.
public init(){ }
@objc public init(){ }

/// Dispatch Group: Keeps track of the constraints and lets the task begin when all of the constraints are satisfied.
let group = DispatchGroup()
Expand Down
16 changes: 8 additions & 8 deletions Sources/WebService/NetworkResource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import Foundation
/// A wrapper over NSMutableURLRequest, it's an alias for a network request in Swifty.
///
/// It provides the chaining modifier syntax and also stores attributes and directions for Swifty to run the given network request.
public class NetworkResource: NSObject {
@objc public class NetworkResource: NSObject {

// MARK: - Properties

/// The actual NSMutableURLRequest this resource wraps over
public let request: NSMutableURLRequest
@objc public let request: NSMutableURLRequest

/// WebServiceNetworkInterface
weak var networkInterface: WebServiceNetworkInterface?
Expand All @@ -34,7 +34,7 @@ public class NetworkResource: NSObject {
var parser: ResponseParser?

/// Tags allow you to categorize your requests, which helps you to recognize them in your interceptors and constraints to take selective action
public var tags = Set<String>()
@objc public var tags = Set<String>()

/// Can have constraints
var canHaveConstraints = false
Expand All @@ -49,7 +49,7 @@ public class NetworkResource: NSObject {
/// Set this error in your own extensions of `NetworkResource` or `NetworkResourceWithBody` Modifiers to inform callers of errors that fail the request, for example, JSON encoding failures.
///
/// If this not `nil` at the time the `load` method on this request is called, the request will **automatically fail** with this error without ever hitting the network.
public var creationError: NSError?
@objc public var creationError: NSError?

// MARK: - Initializers

Expand All @@ -58,7 +58,7 @@ public class NetworkResource: NSObject {
/// - Parameters:
/// - url: URL
/// - method: httpMethod
public convenience init(url: URL, method: String) {
@objc public convenience init(url: URL, method: String) {
let request = NSMutableURLRequest(url: url)
request.httpMethod = method
self.init(request: request)
Expand All @@ -79,15 +79,15 @@ public class NetworkResource: NSObject {
/// - Parameters:
/// - request: NSMutableURLRequest
/// - networkInterface: WebServiceNetworkInterface
public init(request: NSMutableURLRequest, networkInterface: WebServiceNetworkInterface? = nil) {
@objc public init(request: NSMutableURLRequest, networkInterface: WebServiceNetworkInterface? = nil) {
self.request = request
self.networkInterface = networkInterface
}

/// Initializes the NetworkResource with the given URLRequest
///
/// - Parameter request: URLRequest.
public convenience init(request: URLRequest) {
@objc public convenience init(request: URLRequest) {
self.init(request: (request as! NSMutableURLRequest))
}

Expand All @@ -109,7 +109,7 @@ public class NetworkResource: NSObject {
Prints the resource's parameters in readable format, including the URL, Headers, Method, and the HTTP Body
*/
@discardableResult
public func printDetails() -> NetworkResource {
@objc public func printDetails() -> NetworkResource {
print(self.description)
return self
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/WebService/NetworkResourceWithBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import Foundation

/// A subclass of NetworkResource, with support for carrying a request body.
public class NetworkResourceWithBody: NetworkResource {}
@objc public class NetworkResourceWithBody: NetworkResource {}

public extension NetworkResourceWithBody {

Expand Down
24 changes: 12 additions & 12 deletions Swifty.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,11 @@
TargetAttributes = {
52D6D97B1BEFF229002C0205 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
};
52D6D9851BEFF229002C0205 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
};
52D6D9E11BEFFF6E002C0205 = {
CreatedOnToolsVersion = 7.1;
Expand Down Expand Up @@ -851,7 +851,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -903,7 +903,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -930,6 +930,7 @@
PRODUCT_NAME = Swifty;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";

SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
};
Expand All @@ -953,6 +954,7 @@
PRODUCT_NAME = Swifty;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";

SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
};
Expand All @@ -968,8 +970,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.Swifty.Swifty-iOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -983,8 +984,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.Swifty.Swifty-iOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down Expand Up @@ -1151,7 +1151,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1169,7 +1169,7 @@
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -1183,7 +1183,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TVOS_DEPLOYMENT_TARGET = 9.1;
};
name = Debug;
Expand All @@ -1199,7 +1199,7 @@
SDKROOT = appletvos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TVOS_DEPLOYMENT_TARGET = 9.1;
};
name = Release;
Expand Down
6 changes: 2 additions & 4 deletions Swifty.xcodeproj/xcshareddata/xcschemes/Swifty-iOS.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down Expand Up @@ -57,7 +56,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down

0 comments on commit c0c5f7e

Please sign in to comment.