Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Caravel.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = A7F1DD881B17D957001E9B94;
Expand Down Expand Up @@ -290,6 +291,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -330,6 +332,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -351,7 +354,7 @@
PRODUCT_NAME = Caravel;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -368,7 +371,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = Caravel;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
15 changes: 9 additions & 6 deletions caravel-test.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -475,11 +476,12 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand Down Expand Up @@ -515,10 +517,11 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -534,7 +537,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.coshx.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -549,7 +552,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.coshx.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -569,7 +572,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.coshx.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/caravel-test.app/caravel-test";
};
name = Debug;
Expand All @@ -586,7 +589,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.coshx.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/caravel-test.app/caravel-test";
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion caravel-test/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
4 changes: 2 additions & 2 deletions caravel-test/BaseController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ open class BaseController: UIViewController {
return wkWebViewConfigurations[index]
}

func setUp(_ page: String, webView: UIWebView) -> ((Void) -> Void, EventBus.Draft?) {
func setUp(_ page: String, webView: UIWebView) -> (() -> Void, EventBus.Draft?) {
var draft: EventBus.Draft?
var action: (Void) -> Void
var action: () -> Void
let request = URLRequest(url: Bundle.main.url(forResource: page, withExtension: "html")!)

if BaseController.isUsingWKWebView {
Expand Down
2 changes: 1 addition & 1 deletion caravel-test/BasicTriggeringController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ open class BasicTriggeringController: BaseController {
}

if BaseController.isUsingWKWebView {
Caravel.getDefault(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
Caravel.getDefaultReady(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
} else {
Caravel.getDefault(self, webView: _webView, whenReady: action)
}
Expand Down
2 changes: 1 addition & 1 deletion caravel-test/BenchmarkController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BenchmarkController: UIViewController {
webView.removeFromSuperview()
self.view.addSubview(self.wkWebView!)

Caravel.getDefault(self, wkWebView: self.wkWebView!, draft: draft, whenReady: action)
Caravel.getDefaultReady(self, wkWebView: self.wkWebView!, draft: draft, whenReady: action)

self.wkWebView!.load(request)
} else {
Expand Down
2 changes: 1 addition & 1 deletion caravel-test/EventDataController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ open class EventDataController: BaseController {
}

if BaseController.isUsingWKWebView {
Caravel.getDefault(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
Caravel.getDefaultReady(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
} else {
Caravel.getDefault(self, webView: _webView, whenReady: action)
}
Expand Down
2 changes: 1 addition & 1 deletion caravel-test/EventNameController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ open class EventNameController: BaseController {
}

if BaseController.isUsingWKWebView {
Caravel.getDefault(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
Caravel.getDefaultReady(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
} else {
Caravel.getDefault(self, webView: _webView, whenReady: action)
}
Expand Down
4 changes: 2 additions & 2 deletions caravel-test/InitializationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ open class InitializationController: BaseController {
}

if BaseController.isUsingWKWebView {
Caravel.getDefault(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
Caravel.getDefaultReady(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
} else {
Caravel.getDefault(self, webView: _webView, whenReady: action)
}

tuple.0()

if BaseController.isUsingWKWebView {
Caravel.getDefault(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action2)
Caravel.getDefaultReady(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action2)
} else {
Caravel.getDefault(self, webView: _webView, whenReady: action2)
}
Expand Down
2 changes: 1 addition & 1 deletion caravel-test/MultipleSubscriberController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ open class MultipleSubscriberController: BaseController {
}

if BaseController.isUsingWKWebView {
Caravel.getDefault(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
Caravel.getDefaultReady(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
} else {
Caravel.getDefault(self, webView: _webView, whenReady: action)
}
Expand Down
4 changes: 2 additions & 2 deletions caravel-test/TwoBucketController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class TwoBucketController: BaseController {
}

if BaseController.isUsingWKWebView {
Caravel.getDefault(self, wkWebView: getWKWebView(0), draft: tuple1.1!, whenReady: action1)
Caravel.getDefault(self, wkWebView: getWKWebView(1), draft: tuple2.1!, whenReady: action2)
Caravel.getDefaultReady(self, wkWebView: getWKWebView(0), draft: tuple1.1!, whenReady: action1)
Caravel.getDefaultReady(self, wkWebView: getWKWebView(1), draft: tuple2.1!, whenReady: action2)
} else {
Caravel.getDefault(self, webView: webView1, whenReady: action1)
Caravel.getDefault(self, webView: webView2, whenReady: action2)
Expand Down
2 changes: 1 addition & 1 deletion caravel-test/TwoEventController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ open class TwoEventController: BaseController {
}

if BaseController.isUsingWKWebView {
Caravel.getDefault(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
Caravel.getDefaultReady(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
} else {
Caravel.getDefault(self, webView: _webView, whenReady: action)
}
Expand Down
4 changes: 2 additions & 2 deletions caravel-test/UnregistrationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class UnregistrationController: BaseController {
}

if BaseController.isUsingWKWebView {
Caravel.getDefault(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
Caravel.getDefaultReady(self, wkWebView: getWKWebView(), draft: tuple.1!, whenReady: action)
} else {
Caravel.getDefault(self, webView: webView, whenReady: action)
}
Expand All @@ -59,7 +59,7 @@ class UnregistrationController: BaseController {
}
}

func unsubscribe() {
@objc func unsubscribe() {
self.bus!.unregister()
self.timer?.invalidate()
self.timer = nil
Expand Down
8 changes: 8 additions & 0 deletions caravel.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
18 changes: 9 additions & 9 deletions caravel/Caravel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ open class Caravel {

- returns: Current instance
*/
open static func getDefault(_ subscriber: AnyObject, webView: UIWebView, whenReady: @escaping (EventBus) -> Void) -> Caravel {
public static func getDefault(_ subscriber: AnyObject, webView: UIWebView, whenReady: @escaping (EventBus) -> Void) -> Caravel {
let d = CaravelFactory.getDefault()
try! testSubscriber(subscriber, target: webView)
d.addBus(subscriber, webView: webView, whenReady: whenReady, inBackground: true)
Expand All @@ -228,7 +228,7 @@ open class Caravel {

- returns: Current instance
*/
open static func getDefault(_ subscriber: AnyObject, webView: UIWebView, whenReadyOnMain: @escaping (EventBus) -> Void) -> Caravel {
public static func getDefault(_ subscriber: AnyObject, webView: UIWebView, whenReadyOnMain: @escaping (EventBus) -> Void) -> Caravel {
let d = CaravelFactory.getDefault()
try! testSubscriber(subscriber, target: webView)
d.addBus(subscriber, webView: webView, whenReady: whenReadyOnMain, inBackground: false)
Expand All @@ -245,7 +245,7 @@ open class Caravel {

- returns: Current instance
*/
open static func get(_ subscriber: AnyObject, name: String, webView: UIWebView, whenReady: @escaping (EventBus) -> Void) -> Caravel {
public static func get(_ subscriber: AnyObject, name: String, webView: UIWebView, whenReady: @escaping (EventBus) -> Void) -> Caravel {
let d = CaravelFactory.get(name)
try! testSubscriber(subscriber, target: webView)
d.addBus(subscriber, webView: webView, whenReady: whenReady, inBackground: true)
Expand All @@ -262,7 +262,7 @@ open class Caravel {

- returns: Current instance
*/
open static func get(_ subscriber: AnyObject, name: String, webView: UIWebView, whenReadyOnMain: @escaping (EventBus) -> Void) -> Caravel {
public static func get(_ subscriber: AnyObject, name: String, webView: UIWebView, whenReadyOnMain: @escaping (EventBus) -> Void) -> Caravel {
let d = CaravelFactory.get(name)
try! testSubscriber(subscriber, target: webView)
d.addBus(subscriber, webView: webView, whenReady: whenReadyOnMain, inBackground: false)
Expand All @@ -276,7 +276,7 @@ open class Caravel {

- returns: Bus draft
*/
open static func getDraft(_ configuration: WKWebViewConfiguration) -> EventBus.Draft {
public static func getDraft(_ configuration: WKWebViewConfiguration) -> EventBus.Draft {
return EventBus.buildDraft(configuration)
}

Expand All @@ -290,7 +290,7 @@ open class Caravel {

- returns: Current instance
*/
open static func getDefault(_ subscriber: AnyObject, wkWebView: WKWebView, draft: EventBus.Draft, whenReady: @escaping (EventBus) -> Void) -> Caravel {
public static func getDefaultReady(_ subscriber: AnyObject, wkWebView: WKWebView, draft: EventBus.Draft, whenReady: @escaping (EventBus) -> Void) -> Caravel {
let d = CaravelFactory.getDefault()
try! testSubscriber(subscriber, target: wkWebView)
d.addBus(subscriber, wkWebView: wkWebView, draft: draft, whenReady: whenReady, inBackground: true)
Expand All @@ -307,7 +307,7 @@ open class Caravel {

- returns: Current instance
*/
open static func getDefault(_ subscriber: AnyObject, wkWebView: WKWebView, draft: EventBus.Draft, whenReadyOnMain: @escaping (EventBus) -> Void) -> Caravel {
public static func getDefaultReadyOnMain(_ subscriber: AnyObject, wkWebView: WKWebView, draft: EventBus.Draft, whenReadyOnMain: @escaping (EventBus) -> Void) -> Caravel {
let d = CaravelFactory.getDefault()
try! testSubscriber(subscriber, target: wkWebView)
d.addBus(subscriber, wkWebView: wkWebView, draft: draft, whenReady: whenReadyOnMain, inBackground: false)
Expand All @@ -325,7 +325,7 @@ open class Caravel {

- returns: Current instance
*/
open static func get(_ subscriber: AnyObject, name: String, wkWebView: WKWebView, draft: EventBus.Draft, whenReady: @escaping (EventBus) -> Void) -> Caravel {
public static func get(_ subscriber: AnyObject, name: String, wkWebView: WKWebView, draft: EventBus.Draft, whenReady: @escaping (EventBus) -> Void) -> Caravel {
let d = CaravelFactory.get(name)
try! testSubscriber(subscriber, target: wkWebView)
d.addBus(subscriber, wkWebView: wkWebView, draft: draft, whenReady: whenReady, inBackground: true)
Expand All @@ -343,7 +343,7 @@ open class Caravel {

- returns: Current instance
*/
open static func get(_ subscriber: AnyObject, name: String, wkWebView: WKWebView, draft: EventBus.Draft, whenReadyOnMain: @escaping (EventBus) -> Void) -> Caravel {
public static func get(_ subscriber: AnyObject, name: String, wkWebView: WKWebView, draft: EventBus.Draft, whenReadyOnMain: @escaping (EventBus) -> Void) -> Caravel {
let d = CaravelFactory.get(name)
try! testSubscriber(subscriber, target: wkWebView)
d.addBus(subscriber, wkWebView: wkWebView, draft: draft, whenReady: whenReadyOnMain, inBackground: false)
Expand Down
4 changes: 2 additions & 2 deletions caravel/internal/DataSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal class DataSerializer {
}

internal static func deserialize(_ input: String) -> AnyObject {
if input.characters.count > 0 {
if input.count > 0 {
if (input.first == "[" && input.last == "]") || (input.first == "{" && input.last == "}") {
// Array or Dictionary, matching JSON format
let json = input.data(using: String.Encoding.utf8, allowLossyConversion: false)!
Expand All @@ -53,7 +53,7 @@ internal class DataSerializer {
}

var isNumber = true
for i in 0..<input.characters.count {
for i in 0..<input.count {
if Int(input[i]) != nil || input[i] == "." || input[i] == "," {
// Do nothing
} else {
Expand Down
2 changes: 1 addition & 1 deletion caravel/internal/proxies/UIWebViewDelegateProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal class UIWebViewDelegateProxy: NSObject, UIWebViewDelegate {
self.originalDelegate?.webView?(webView, didFailLoadWithError: error)
}

func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebView.NavigationType) -> Bool {
var shouldLoad = true // Default behavior: execute URL
let original = self.originalDelegate?.webView?(webView, shouldStartLoadWith: request, navigationType: navigationType)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class UIWebViewDelegateProxyMediator {
}

static func subscribe(_ webView: UIWebView, observer: IUIWebViewObserver) {
let action: (Void) -> Bool = {
let action: () -> Bool = {
for (k, v) in proxies {
if k == webView.hash {
v.subscribe(observer)
Expand Down
6 changes: 3 additions & 3 deletions caravel/utils/StringExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
internal extension String {

var length: Int {
return self.characters.count
return self.count
}

var first: String? {
Expand All @@ -23,14 +23,14 @@ internal extension String {
}

subscript (i: Int) -> Character {
return self[self.characters.index(self.startIndex, offsetBy: i)]
return self[self.index(self.startIndex, offsetBy: i)]
}

subscript (i: Int) -> String {
return String(self[i] as Character)
}

subscript (r: Range<Int>) -> String {
return substring(with: (characters.index(startIndex, offsetBy: r.lowerBound) ..< characters.index(startIndex, offsetBy: r.upperBound)))
return substring(with: (index(startIndex, offsetBy: r.lowerBound) ..< index(startIndex, offsetBy: r.upperBound)))
}
}