From ef3f1b947601b747a922fd4e0e93b4562d3a4d5f Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Sat, 18 Apr 2015 15:31:19 +0100 Subject: [PATCH 001/158] Add assert when bridge JS could not be loaded --- WebViewJavascriptBridge/WebViewJavascriptBridge.m | 1 + 1 file changed, 1 insertion(+) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index dff06e62..4db0fdb0 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -345,6 +345,7 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView { if (_numRequestsLoading == 0 && ![[webView stringByEvaluatingJavaScriptFromString:@"typeof WebViewJavascriptBridge == 'object'"] isEqualToString:@"true"]) { NSBundle *bundle = _resourceBundle ? _resourceBundle : [NSBundle mainBundle]; NSString *filePath = [bundle pathForResource:@"WebViewJavascriptBridge.js" ofType:@"txt"]; + NSAssert(filePath != nil, @"WebViewJavascriptBridge.js.txt is missing. Your bundle is probably not setup correctly (using bundle %@)", bundle); NSString *js = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; [webView stringByEvaluatingJavaScriptFromString:js]; } From 86feab4adc5f426367742e212b228bb7343b256b Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Sat, 18 Apr 2015 15:35:46 +0100 Subject: [PATCH 002/158] Add TestHost and tests skeleton --- .../project.pbxproj | 519 ++++++++++++++++++ WebViewJavascriptBridgeTestHost/AppDelegate.h | 16 + WebViewJavascriptBridgeTestHost/AppDelegate.m | 43 ++ WebViewJavascriptBridgeTestHost/Info.plist | 34 ++ WebViewJavascriptBridgeTestHost/main.m | 16 + WebViewJavascriptBridgeTests/BridgeTests.m | 22 + WebViewJavascriptBridgeTests/Info.plist | 24 + 7 files changed, 674 insertions(+) create mode 100644 WebViewJavascriptBridge.xcodeproj/project.pbxproj create mode 100644 WebViewJavascriptBridgeTestHost/AppDelegate.h create mode 100644 WebViewJavascriptBridgeTestHost/AppDelegate.m create mode 100644 WebViewJavascriptBridgeTestHost/Info.plist create mode 100644 WebViewJavascriptBridgeTestHost/main.m create mode 100644 WebViewJavascriptBridgeTests/BridgeTests.m create mode 100644 WebViewJavascriptBridgeTests/Info.plist diff --git a/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/WebViewJavascriptBridge.xcodeproj/project.pbxproj new file mode 100644 index 00000000..c4ff0ffd --- /dev/null +++ b/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -0,0 +1,519 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 3D0FE4761AE2886500BB4104 /* libWebViewJavascriptBridge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D0FE46A1AE2886400BB4104 /* libWebViewJavascriptBridge.a */; }; + 3D9E5F2D1AE2888D009D1C36 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D9E5F2C1AE2888D009D1C36 /* WebViewJavascriptBridge.m */; }; + 3D9E5F2F1AE288E5009D1C36 /* BridgeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D9E5F2E1AE288E5009D1C36 /* BridgeTests.m */; }; + 3DCCF7DB1AE28C2900CE7C51 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DCCF7DA1AE28C2900CE7C51 /* main.m */; }; + 3DCCF7DE1AE28C2900CE7C51 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DCCF7DD1AE28C2900CE7C51 /* AppDelegate.m */; }; + 3DCCF8001AE28FF600CE7C51 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 3D9E5F301AE28A5E009D1C36 /* WebViewJavascriptBridge.js.txt */; }; + 3DCCF8021AE2911100CE7C51 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DCCF8011AE2911100CE7C51 /* UIKit.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 3D0FE4771AE2886500BB4104 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 3D0FE4621AE2886400BB4104 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 3D0FE4691AE2886400BB4104; + remoteInfo = WebViewJavascriptBridge; + }; + 3DCCF7FC1AE28C3B00CE7C51 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 3D0FE4621AE2886400BB4104 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 3DCCF7D51AE28C2900CE7C51; + remoteInfo = WebViewJavascriptBridgeTestHost; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 3D0FE4681AE2886400BB4104 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 3D0FE46A1AE2886400BB4104 /* libWebViewJavascriptBridge.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWebViewJavascriptBridge.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 3D0FE4751AE2886500BB4104 /* WebViewJavascriptBridgeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WebViewJavascriptBridgeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3D0FE47B1AE2886500BB4104 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3D9E5F2B1AE2888D009D1C36 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = ""; }; + 3D9E5F2C1AE2888D009D1C36 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = ""; }; + 3D9E5F2E1AE288E5009D1C36 /* BridgeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BridgeTests.m; sourceTree = ""; }; + 3D9E5F301AE28A5E009D1C36 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebViewJavascriptBridge.js.txt; path = ../WebViewJavascriptBridge/WebViewJavascriptBridge.js.txt; sourceTree = ""; }; + 3DCCF7D61AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WebViewJavascriptBridgeTestHost.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 3DCCF7D91AE28C2900CE7C51 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3DCCF7DA1AE28C2900CE7C51 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 3DCCF7DC1AE28C2900CE7C51 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 3DCCF7DD1AE28C2900CE7C51 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 3DCCF8011AE2911100CE7C51 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 3D0FE4671AE2886400BB4104 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3D0FE4721AE2886500BB4104 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 3D0FE4761AE2886500BB4104 /* libWebViewJavascriptBridge.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3DCCF7D31AE28C2900CE7C51 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 3DCCF8021AE2911100CE7C51 /* UIKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 3D0FE4611AE2886400BB4104 = { + isa = PBXGroup; + children = ( + 3D0FE46C1AE2886400BB4104 /* WebViewJavascriptBridge */, + 3D0FE4791AE2886500BB4104 /* WebViewJavascriptBridgeTests */, + 3DCCF7D71AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost */, + 3D0FE46B1AE2886400BB4104 /* Products */, + ); + sourceTree = ""; + }; + 3D0FE46B1AE2886400BB4104 /* Products */ = { + isa = PBXGroup; + children = ( + 3D0FE46A1AE2886400BB4104 /* libWebViewJavascriptBridge.a */, + 3D0FE4751AE2886500BB4104 /* WebViewJavascriptBridgeTests.xctest */, + 3DCCF7D61AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost.app */, + ); + name = Products; + sourceTree = ""; + }; + 3D0FE46C1AE2886400BB4104 /* WebViewJavascriptBridge */ = { + isa = PBXGroup; + children = ( + 3D9E5F2B1AE2888D009D1C36 /* WebViewJavascriptBridge.h */, + 3D9E5F2C1AE2888D009D1C36 /* WebViewJavascriptBridge.m */, + ); + path = WebViewJavascriptBridge; + sourceTree = ""; + }; + 3D0FE4791AE2886500BB4104 /* WebViewJavascriptBridgeTests */ = { + isa = PBXGroup; + children = ( + 3D0FE47A1AE2886500BB4104 /* Supporting Files */, + 3D9E5F2E1AE288E5009D1C36 /* BridgeTests.m */, + ); + path = WebViewJavascriptBridgeTests; + sourceTree = ""; + }; + 3D0FE47A1AE2886500BB4104 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 3D0FE47B1AE2886500BB4104 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 3DCCF7D71AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost */ = { + isa = PBXGroup; + children = ( + 3DCCF7DC1AE28C2900CE7C51 /* AppDelegate.h */, + 3DCCF7DD1AE28C2900CE7C51 /* AppDelegate.m */, + 3DCCF8031AE2911700CE7C51 /* Frameworks */, + 3DCCF7D81AE28C2900CE7C51 /* Supporting Files */, + ); + path = WebViewJavascriptBridgeTestHost; + sourceTree = ""; + }; + 3DCCF7D81AE28C2900CE7C51 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 3DCCF7D91AE28C2900CE7C51 /* Info.plist */, + 3DCCF7DA1AE28C2900CE7C51 /* main.m */, + 3D9E5F301AE28A5E009D1C36 /* WebViewJavascriptBridge.js.txt */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 3DCCF8031AE2911700CE7C51 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 3DCCF8011AE2911100CE7C51 /* UIKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 3D0FE4691AE2886400BB4104 /* WebViewJavascriptBridge */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3D0FE47E1AE2886500BB4104 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridge" */; + buildPhases = ( + 3D0FE4661AE2886400BB4104 /* Sources */, + 3D0FE4671AE2886400BB4104 /* Frameworks */, + 3D0FE4681AE2886400BB4104 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = WebViewJavascriptBridge; + productName = WebViewJavascriptBridge; + productReference = 3D0FE46A1AE2886400BB4104 /* libWebViewJavascriptBridge.a */; + productType = "com.apple.product-type.library.static"; + }; + 3D0FE4741AE2886500BB4104 /* WebViewJavascriptBridgeTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3D0FE4811AE2886500BB4104 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridgeTests" */; + buildPhases = ( + 3D0FE4711AE2886500BB4104 /* Sources */, + 3D0FE4721AE2886500BB4104 /* Frameworks */, + 3D0FE4731AE2886500BB4104 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 3D0FE4781AE2886500BB4104 /* PBXTargetDependency */, + 3DCCF7FD1AE28C3B00CE7C51 /* PBXTargetDependency */, + ); + name = WebViewJavascriptBridgeTests; + productName = WebViewJavascriptBridgeTests; + productReference = 3D0FE4751AE2886500BB4104 /* WebViewJavascriptBridgeTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 3DCCF7D51AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3DCCF7FA1AE28C2900CE7C51 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridgeTestHost" */; + buildPhases = ( + 3DCCF7D21AE28C2900CE7C51 /* Sources */, + 3DCCF7D31AE28C2900CE7C51 /* Frameworks */, + 3DCCF7D41AE28C2900CE7C51 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = WebViewJavascriptBridgeTestHost; + productName = WebViewJavascriptBridgeTestHost; + productReference = 3DCCF7D61AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 3D0FE4621AE2886400BB4104 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0630; + ORGANIZATIONNAME = marcuswestin; + TargetAttributes = { + 3D0FE4691AE2886400BB4104 = { + CreatedOnToolsVersion = 6.3; + }; + 3D0FE4741AE2886500BB4104 = { + CreatedOnToolsVersion = 6.3; + TestTargetID = 3DCCF7D51AE28C2900CE7C51; + }; + 3DCCF7D51AE28C2900CE7C51 = { + CreatedOnToolsVersion = 6.3; + }; + }; + }; + buildConfigurationList = 3D0FE4651AE2886400BB4104 /* Build configuration list for PBXProject "WebViewJavascriptBridge" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 3D0FE4611AE2886400BB4104; + productRefGroup = 3D0FE46B1AE2886400BB4104 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 3D0FE4691AE2886400BB4104 /* WebViewJavascriptBridge */, + 3D0FE4741AE2886500BB4104 /* WebViewJavascriptBridgeTests */, + 3DCCF7D51AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 3D0FE4731AE2886500BB4104 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3DCCF7D41AE28C2900CE7C51 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3DCCF8001AE28FF600CE7C51 /* WebViewJavascriptBridge.js.txt in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 3D0FE4661AE2886400BB4104 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3D9E5F2D1AE2888D009D1C36 /* WebViewJavascriptBridge.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3D0FE4711AE2886500BB4104 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3D9E5F2F1AE288E5009D1C36 /* BridgeTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3DCCF7D21AE28C2900CE7C51 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3DCCF7DE1AE28C2900CE7C51 /* AppDelegate.m in Sources */, + 3DCCF7DB1AE28C2900CE7C51 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 3D0FE4781AE2886500BB4104 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 3D0FE4691AE2886400BB4104 /* WebViewJavascriptBridge */; + targetProxy = 3D0FE4771AE2886500BB4104 /* PBXContainerItemProxy */; + }; + 3DCCF7FD1AE28C3B00CE7C51 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 3DCCF7D51AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost */; + targetProxy = 3DCCF7FC1AE28C3B00CE7C51 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 3D0FE47C1AE2886500BB4104 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 3D0FE47D1AE2886500BB4104 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 3D0FE47F1AE2886500BB4104 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 3D0FE4801AE2886500BB4104 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; + 3D0FE4821AE2886500BB4104 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = WebViewJavascriptBridgeTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebViewJavascriptBridgeTestHost.app/WebViewJavascriptBridgeTestHost"; + }; + name = Debug; + }; + 3D0FE4831AE2886500BB4104 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + INFOPLIST_FILE = WebViewJavascriptBridgeTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebViewJavascriptBridgeTestHost.app/WebViewJavascriptBridgeTestHost"; + }; + name = Release; + }; + 3DCCF7F61AE28C2900CE7C51 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = WebViewJavascriptBridgeTestHost/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 3DCCF7F71AE28C2900CE7C51 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + INFOPLIST_FILE = WebViewJavascriptBridgeTestHost/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 3D0FE4651AE2886400BB4104 /* Build configuration list for PBXProject "WebViewJavascriptBridge" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3D0FE47C1AE2886500BB4104 /* Debug */, + 3D0FE47D1AE2886500BB4104 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3D0FE47E1AE2886500BB4104 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridge" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3D0FE47F1AE2886500BB4104 /* Debug */, + 3D0FE4801AE2886500BB4104 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3D0FE4811AE2886500BB4104 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridgeTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3D0FE4821AE2886500BB4104 /* Debug */, + 3D0FE4831AE2886500BB4104 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3DCCF7FA1AE28C2900CE7C51 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridgeTestHost" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3DCCF7F61AE28C2900CE7C51 /* Debug */, + 3DCCF7F71AE28C2900CE7C51 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 3D0FE4621AE2886400BB4104 /* Project object */; +} diff --git a/WebViewJavascriptBridgeTestHost/AppDelegate.h b/WebViewJavascriptBridgeTestHost/AppDelegate.h new file mode 100644 index 00000000..00728f35 --- /dev/null +++ b/WebViewJavascriptBridgeTestHost/AppDelegate.h @@ -0,0 +1,16 @@ +// +// AppDelegate.h +// WebViewJavascriptBridgeTestHost +// +// Created by Pieter De Baets on 18/04/2015. +// Copyright (c) 2015 marcuswestin. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end + diff --git a/WebViewJavascriptBridgeTestHost/AppDelegate.m b/WebViewJavascriptBridgeTestHost/AppDelegate.m new file mode 100644 index 00000000..5d903bf9 --- /dev/null +++ b/WebViewJavascriptBridgeTestHost/AppDelegate.m @@ -0,0 +1,43 @@ +// +// AppDelegate.m +// WebViewJavascriptBridgeTestHost +// +// Created by Pieter De Baets on 18/04/2015. +// Copyright (c) 2015 marcuswestin. All rights reserved. +// + +#import "AppDelegate.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + self.window.rootViewController = [UIViewController new]; + [self.window makeKeyAndVisible]; + + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/WebViewJavascriptBridgeTestHost/Info.plist b/WebViewJavascriptBridgeTestHost/Info.plist new file mode 100644 index 00000000..ff3b32f8 --- /dev/null +++ b/WebViewJavascriptBridgeTestHost/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + in.marcuswestin.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + + + diff --git a/WebViewJavascriptBridgeTestHost/main.m b/WebViewJavascriptBridgeTestHost/main.m new file mode 100644 index 00000000..d37bf5bd --- /dev/null +++ b/WebViewJavascriptBridgeTestHost/main.m @@ -0,0 +1,16 @@ +// +// main.m +// WebViewJavascriptBridgeTestHost +// +// Created by Pieter De Baets on 18/04/2015. +// Copyright (c) 2015 marcuswestin. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/WebViewJavascriptBridgeTests/BridgeTests.m b/WebViewJavascriptBridgeTests/BridgeTests.m new file mode 100644 index 00000000..b589b728 --- /dev/null +++ b/WebViewJavascriptBridgeTests/BridgeTests.m @@ -0,0 +1,22 @@ +// +// BridgeTests.m +// WebViewJavascriptBridge +// +// Created by Pieter De Baets on 18/04/2015. +// Copyright (c) 2015 marcuswestin. All rights reserved. +// + +#import + +@interface BridgeTests : XCTestCase + +@end + +@implementation BridgeTests + +- (void)testInit +{ + XCTAssert(YES); +} + +@end diff --git a/WebViewJavascriptBridgeTests/Info.plist b/WebViewJavascriptBridgeTests/Info.plist new file mode 100644 index 00000000..d28fbba1 --- /dev/null +++ b/WebViewJavascriptBridgeTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + in.marcuswestin.WebViewJavascriptBridge.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + From e8996ba16e302cca33bb34552940b84f1e83ac22 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Sat, 18 Apr 2015 15:36:08 +0100 Subject: [PATCH 003/158] Some basic tests --- .../project.pbxproj | 4 + WebViewJavascriptBridgeTests/BridgeTests.m | 92 ++++++++++++++++++- WebViewJavascriptBridgeTests/echo.html | 29 ++++++ 3 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 WebViewJavascriptBridgeTests/echo.html diff --git a/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/WebViewJavascriptBridge.xcodeproj/project.pbxproj index c4ff0ffd..318ebd36 100644 --- a/WebViewJavascriptBridge.xcodeproj/project.pbxproj +++ b/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 3D0FE4761AE2886500BB4104 /* libWebViewJavascriptBridge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D0FE46A1AE2886400BB4104 /* libWebViewJavascriptBridge.a */; }; + 3D99867E1AE2A3B2001DDA2C /* echo.html in Resources */ = {isa = PBXBuildFile; fileRef = 3D99867D1AE2A3B2001DDA2C /* echo.html */; }; 3D9E5F2D1AE2888D009D1C36 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D9E5F2C1AE2888D009D1C36 /* WebViewJavascriptBridge.m */; }; 3D9E5F2F1AE288E5009D1C36 /* BridgeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D9E5F2E1AE288E5009D1C36 /* BridgeTests.m */; }; 3DCCF7DB1AE28C2900CE7C51 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DCCF7DA1AE28C2900CE7C51 /* main.m */; }; @@ -49,6 +50,7 @@ 3D0FE46A1AE2886400BB4104 /* libWebViewJavascriptBridge.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWebViewJavascriptBridge.a; sourceTree = BUILT_PRODUCTS_DIR; }; 3D0FE4751AE2886500BB4104 /* WebViewJavascriptBridgeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WebViewJavascriptBridgeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3D0FE47B1AE2886500BB4104 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3D99867D1AE2A3B2001DDA2C /* echo.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = echo.html; path = WebViewJavascriptBridgeTests/echo.html; sourceTree = SOURCE_ROOT; }; 3D9E5F2B1AE2888D009D1C36 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = ""; }; 3D9E5F2C1AE2888D009D1C36 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = ""; }; 3D9E5F2E1AE288E5009D1C36 /* BridgeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BridgeTests.m; sourceTree = ""; }; @@ -148,6 +150,7 @@ 3DCCF7D81AE28C2900CE7C51 /* Supporting Files */ = { isa = PBXGroup; children = ( + 3D99867D1AE2A3B2001DDA2C /* echo.html */, 3DCCF7D91AE28C2900CE7C51 /* Info.plist */, 3DCCF7DA1AE28C2900CE7C51 /* main.m */, 3D9E5F301AE28A5E009D1C36 /* WebViewJavascriptBridge.js.txt */, @@ -273,6 +276,7 @@ buildActionMask = 2147483647; files = ( 3DCCF8001AE28FF600CE7C51 /* WebViewJavascriptBridge.js.txt in Resources */, + 3D99867E1AE2A3B2001DDA2C /* echo.html in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/WebViewJavascriptBridgeTests/BridgeTests.m b/WebViewJavascriptBridgeTests/BridgeTests.m index b589b728..2c4db8e9 100644 --- a/WebViewJavascriptBridgeTests/BridgeTests.m +++ b/WebViewJavascriptBridgeTests/BridgeTests.m @@ -8,15 +8,101 @@ #import +#import "WebViewJavascriptBridge.h" +#import "AppDelegate.h" + +static NSString *const echoHandler = @"echoHandler"; +static const WVJBHandler nullHandler = ^(id data, WVJBResponseCallback callback) {}; + @interface BridgeTests : XCTestCase @end -@implementation BridgeTests +@implementation BridgeTests { + UIWebView *_webView; +} + +- (void)setUp +{ + [super setUp]; + + UIViewController *rootVC = [[(AppDelegate *)[[UIApplication sharedApplication] delegate] window] rootViewController]; + _webView = [[UIWebView alloc] initWithFrame:rootVC.view.bounds]; + [rootVC.view addSubview:_webView]; +} + +- (void)tearDown +{ + [super tearDown]; + [_webView removeFromSuperview]; +} + +static void loadEchoSample(UIWebView *webView) +{ + NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"echo" withExtension:@"html"]]; + [webView loadRequest:request]; +} + +- (void)testInitialization +{ + XCTestExpectation *startup = [self expectationWithDescription:@"Startup completed"]; + WebViewJavascriptBridge *bridge = [WebViewJavascriptBridge bridgeForWebView:_webView handler:^(id data, WVJBResponseCallback responseCallback) { + XCTAssertEqualObjects(data, @"Hello world"); + [startup fulfill]; + }]; + XCTAssertNotNil(bridge); + + loadEchoSample(_webView); + [self waitForExpectationsWithTimeout:10 handler:NULL]; +} + +- (void)testResponseHandler +{ + WebViewJavascriptBridge *bridge = [WebViewJavascriptBridge bridgeForWebView:_webView handler:nullHandler]; + + XCTestExpectation *callbackInvoked = [self expectationWithDescription:@"Callback invoked"]; + [bridge send:@"testResponseHandler" responseCallback:^(id responseData) { + XCTAssertEqualObjects(responseData, @"testResponseHandler"); + [callbackInvoked fulfill]; + }]; + + loadEchoSample(_webView); + [self waitForExpectationsWithTimeout:10 handler:NULL]; +} -- (void)testInit +- (void)testEchoHandler { - XCTAssert(YES); + WebViewJavascriptBridge *bridge = [WebViewJavascriptBridge bridgeForWebView:_webView handler:nullHandler]; + + XCTestExpectation *callbackInvocked = [self expectationWithDescription:@"Callback invoked"]; + [bridge callHandler:echoHandler data:@"testEchoHandler" responseCallback:^(id responseData) { + XCTAssertEqualObjects(responseData, @"testEchoHandler"); + [callbackInvocked fulfill]; + }]; + + loadEchoSample(_webView); + [self waitForExpectationsWithTimeout:10 handler:NULL]; +} + +- (void)testObjectEncoding +{ + WebViewJavascriptBridge *bridge = [WebViewJavascriptBridge bridgeForWebView:_webView handler:nullHandler]; + + void (^echoObject)(id) = ^void(id object) { + XCTestExpectation *callbackInvocked = [self expectationWithDescription:@"Callback invoked"]; + [bridge callHandler:echoHandler data:object responseCallback:^(id responseData) { + XCTAssertEqualObjects(responseData, object); + [callbackInvocked fulfill]; + }]; + }; + + echoObject(@"A string sent over the wire"); + echoObject(@"A string with '\"'/\\"); + echoObject(@[ @1, @2, @3 ]); + echoObject(@{ @"a" : @1, @"b" : @2 }); + + loadEchoSample(_webView); + [self waitForExpectationsWithTimeout:10 handler:NULL]; } @end diff --git a/WebViewJavascriptBridgeTests/echo.html b/WebViewJavascriptBridgeTests/echo.html new file mode 100644 index 00000000..4e44f2d1 --- /dev/null +++ b/WebViewJavascriptBridgeTests/echo.html @@ -0,0 +1,29 @@ + + + +

WebViewJavascriptBridgeTests - echo.html

+ + From c619b65d6ef45fa1fc27fc8f4117d0bfa9435bc1 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Sat, 18 Apr 2015 15:42:34 +0100 Subject: [PATCH 004/158] Travis CI support --- .travis.yml | 6 + README.md | 2 + .../project.pbxproj | 4 +- .../WebViewJavascriptBridge.xcscheme | 110 ++++++++++++++++++ 4 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 .travis.yml create mode 100644 WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..b620ea76 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: objective-c +before_script: + - brew update + - brew upgrade xctool || true +script: + - xctool -project WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge -configuration Release -sdk iphonesimulator test diff --git a/README.md b/README.md index 7bdd0299..a57a95e8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ WebViewJavascriptBridge ======================= +[![Build Status](https://travis-ci.org/marcuswestin/WebViewJavascriptBridge.svg)](https://travis-ci.org/marcuswestin/WebViewJavascriptBridge) + An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews. If you like WebViewJavascriptBridge you may also want to check out [WebViewProxy](https://github.com/marcuswestin/WebViewProxy). diff --git a/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/WebViewJavascriptBridge.xcodeproj/project.pbxproj index 318ebd36..d7ed6682 100644 --- a/WebViewJavascriptBridge.xcodeproj/project.pbxproj +++ b/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -359,7 +359,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.3; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -395,7 +395,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.3; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; diff --git a/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme b/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme new file mode 100644 index 00000000..cef4e0ff --- /dev/null +++ b/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 343355f47b46276dfe6aab91e97a06e48358cfa1 Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Thu, 23 Apr 2015 10:50:31 -0400 Subject: [PATCH 005/158] The Javascript source string constant is now always built into the .m file. --- .../ExampleApp-OSX.xcodeproj/project.pbxproj | 8 +- .../ExampleApp-iOS.xcodeproj/project.pbxproj | 8 +- .../WebViewJavascriptBridge.h | 2 +- .../WebViewJavascriptBridge.js.h | 124 ++++++++++++++++++ .../WebViewJavascriptBridge.js.txt | 117 ----------------- .../WebViewJavascriptBridge.m | 33 ++--- 6 files changed, 146 insertions(+), 146 deletions(-) create mode 100644 WebViewJavascriptBridge/WebViewJavascriptBridge.js.h delete mode 100644 WebViewJavascriptBridge/WebViewJavascriptBridge.js.txt diff --git a/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj index 0e947166..d35d1ee7 100644 --- a/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj @@ -14,7 +14,7 @@ 2C136A3817641106004C7401 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C136A3717641106004C7401 /* AppDelegate.m */; }; 2C136A4217641236004C7401 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C136A4117641236004C7401 /* WebKit.framework */; }; 2C136A5A17642704004C7401 /* ExampleApp.html in Resources */ = {isa = PBXBuildFile; fileRef = 2C136A5917642704004C7401 /* ExampleApp.html */; }; - 2C1562C5176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt */; }; + 2C1562C5176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.h in Resources */ = {isa = PBXBuildFile; fileRef = 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.h */; }; 2C1562C6176BA9FF00B4AE50 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */; }; 2CF17F5317D8AACF006E828B /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2CF17F5217D8AACF006E828B /* MainMenu.xib */; }; /* End PBXBuildFile section */ @@ -35,7 +35,7 @@ 2C136A4117641236004C7401 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; 2C136A5917642704004C7401 /* ExampleApp.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ExampleApp.html; sourceTree = SOURCE_ROOT; }; 2C1562C2176BA9FF00B4AE50 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = ""; }; - 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = ""; }; + 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.js.h; sourceTree = ""; }; 2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = ""; }; 2CF17F5217D8AACF006E828B /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = ""; }; /* End PBXFileReference section */ @@ -119,7 +119,7 @@ isa = PBXGroup; children = ( 2C1562C2176BA9FF00B4AE50 /* WebViewJavascriptBridge.h */, - 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt */, + 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.h */, 2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */, ); name = WebViewJavascriptBridge; @@ -177,7 +177,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2C1562C5176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */, + 2C1562C5176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.h in Resources */, 2C136A2F17641106004C7401 /* InfoPlist.strings in Resources */, 2C136A3517641106004C7401 /* Credits.rtf in Resources */, 2C136A5A17642704004C7401 /* ExampleApp.html in Resources */, diff --git a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj index 4834adaf..1e33172d 100644 --- a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj @@ -7,7 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - 2C1562B5176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */; }; + 2C1562B5176B9F8400B4AE50 /* WebViewJavascriptBridge.js.h in Resources */ = {isa = PBXBuildFile; fileRef = 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.h */; }; 2C1562C0176BA63500B4AE50 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */; }; 2C45CA2C1884AD520002A4E2 /* ExampleAppViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C45CA2B1884AD520002A4E2 /* ExampleAppViewController.m */; }; 2CA045BF17117439006DEE8B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2CA045B717117439006DEE8B /* InfoPlist.strings */; }; @@ -23,7 +23,7 @@ /* Begin PBXFileReference section */ 2C1562A8176B9F6200B4AE50 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = ""; }; 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = ""; }; - 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = ""; }; + 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.js.h; sourceTree = ""; }; 2C45CA2A1884AD520002A4E2 /* ExampleAppViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleAppViewController.h; sourceTree = ""; }; 2C45CA2B1884AD520002A4E2 /* ExampleAppViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleAppViewController.m; sourceTree = ""; }; 2CA045B817117439006DEE8B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -57,7 +57,7 @@ 2C1562A7176B9F5400B4AE50 /* WebViewJavascriptBridge */ = { isa = PBXGroup; children = ( - 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */, + 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.h */, 2C1562A8176B9F6200B4AE50 /* WebViewJavascriptBridge.h */, 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */, ); @@ -169,7 +169,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2C1562B5176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */, + 2C1562B5176B9F8400B4AE50 /* WebViewJavascriptBridge.js.h in Resources */, 2CA045BF17117439006DEE8B /* InfoPlist.strings in Resources */, 2CA0465C1711AC8E006DEE8B /* ExampleApp.html in Resources */, 2CAB869B1727684300BD9ED1 /* Default-568h@2x.png in Resources */, diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.h index 9e90829f..a80c2b14 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.h @@ -30,7 +30,6 @@ typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback); + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView handler:(WVJBHandler)handler; + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler; -+ (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler resourceBundle:(NSBundle*)bundle; + (void)enableLogging; - (void)send:(id)message; @@ -40,4 +39,5 @@ typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback); - (void)callHandler:(NSString*)handlerName data:(id)data; - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; ++ (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler resourceBundle:(NSBundle*)bundle __attribute__((deprecated)); @end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.js.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.js.h new file mode 100644 index 00000000..0cfad707 --- /dev/null +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.js.h @@ -0,0 +1,124 @@ +#ifdef _______STRINGIFY +#error _______STRINGIFY already defined! +#endif +#define _______STRINGIFY(x) #x +_______STRINGIFY( +;(function() { + if (window.WebViewJavascriptBridge) { return; } + var messagingIframe; + var sendMessageQueue = []; + var receiveMessageQueue = []; + var messageHandlers = {}; + + var CUSTOM_PROTOCOL_SCHEME = 'wvjbscheme'; + var QUEUE_HAS_MESSAGE = '__WVJB_QUEUE_MESSAGE__'; + + var responseCallbacks = {}; + var uniqueId = 1; + + function _createQueueReadyIframe(doc) { + messagingIframe = doc.createElement('iframe'); + messagingIframe.style.display = 'none'; + messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE; + doc.documentElement.appendChild(messagingIframe); + } + + function init(messageHandler) { + if (WebViewJavascriptBridge._messageHandler) { throw new Error('WebViewJavascriptBridge.init called twice'); } + WebViewJavascriptBridge._messageHandler = messageHandler; + var receivedMessages = receiveMessageQueue; + receiveMessageQueue = null; + for (var i=0; i)webViewDelegate handler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle{ +- (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(id)webViewDelegate handler:(WVJBHandler)messageHandler{ _messageHandler = messageHandler; _webView = webView; _webViewDelegate = webViewDelegate; _messageHandlers = [NSMutableDictionary dictionary]; _webView.delegate = self; - _resourceBundle = bundle; } - (void) _platformSpecificDealloc { @@ -343,10 +339,7 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView { _numRequestsLoading--; if (_numRequestsLoading == 0 && ![[webView stringByEvaluatingJavaScriptFromString:@"typeof WebViewJavascriptBridge == 'object'"] isEqualToString:@"true"]) { - NSBundle *bundle = _resourceBundle ? _resourceBundle : [NSBundle mainBundle]; - NSString *filePath = [bundle pathForResource:@"WebViewJavascriptBridge.js" ofType:@"txt"]; - NSString *js = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; - [webView stringByEvaluatingJavaScriptFromString:js]; + NSLog(@"%@", [webView stringByEvaluatingJavaScriptFromString:WebViewJavascriptBridge_js]); } if (_startupMessageQueue) { From b3c4689aca1caf5de8ed165dbea86a9c8912c56b Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Thu, 23 Apr 2015 10:54:26 -0400 Subject: [PATCH 006/158] Added pragma to suppress warning. --- WebViewJavascriptBridge/WebViewJavascriptBridge.m | 1 + 1 file changed, 1 insertion(+) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index 32aac54f..e94a06af 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -53,6 +53,7 @@ + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WV + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)_ { + #pragma unused(_) return [self bridgeForWebView:webView webViewDelegate:webViewDelegate handler:messageHandler]; } From 676f783b24f0416dfa83c8c3e9c65a5cf36cfe7c Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Thu, 23 Apr 2015 10:57:48 -0400 Subject: [PATCH 007/158] Fixed tabbing. --- .../WebViewJavascriptBridge.js.h | 122 +++++++++--------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.js.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.js.h index 0cfad707..8efffafe 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.js.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.js.h @@ -9,108 +9,108 @@ _______STRINGIFY( var sendMessageQueue = []; var receiveMessageQueue = []; var messageHandlers = {}; - - var CUSTOM_PROTOCOL_SCHEME = 'wvjbscheme'; - var QUEUE_HAS_MESSAGE = '__WVJB_QUEUE_MESSAGE__'; - + + var CUSTOM_PROTOCOL_SCHEME = 'wvjbscheme'; + var QUEUE_HAS_MESSAGE = '__WVJB_QUEUE_MESSAGE__'; + var responseCallbacks = {}; var uniqueId = 1; - - function _createQueueReadyIframe(doc) { + + function _createQueueReadyIframe(doc) { messagingIframe = doc.createElement('iframe'); - messagingIframe.style.display = 'none'; + messagingIframe.style.display = 'none'; messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE; doc.documentElement.appendChild(messagingIframe); - } + } - function init(messageHandler) { + function init(messageHandler) { if (WebViewJavascriptBridge._messageHandler) { throw new Error('WebViewJavascriptBridge.init called twice'); } WebViewJavascriptBridge._messageHandler = messageHandler; var receivedMessages = receiveMessageQueue; receiveMessageQueue = null; - for (var i=0; i Date: Thu, 23 Apr 2015 11:33:36 -0400 Subject: [PATCH 008/158] Removed accidental logs --- WebViewJavascriptBridge/WebViewJavascriptBridge.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index e94a06af..927203d4 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -256,7 +256,7 @@ - (void)webView:(WebView *)webView didFinishLoadForFrame:(WebFrame *)frame if (webView != _webView) { return; } if (![[webView stringByEvaluatingJavaScriptFromString:@"typeof WebViewJavascriptBridge == 'object'"] isEqualToString:@"true"]) { - NSLog(@"%@", [webView stringByEvaluatingJavaScriptFromString:WebViewJavascriptBridge_js]); + [webView stringByEvaluatingJavaScriptFromString:WebViewJavascriptBridge_js]; } if (_startupMessageQueue) { @@ -340,7 +340,7 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView { _numRequestsLoading--; if (_numRequestsLoading == 0 && ![[webView stringByEvaluatingJavaScriptFromString:@"typeof WebViewJavascriptBridge == 'object'"] isEqualToString:@"true"]) { - NSLog(@"%@", [webView stringByEvaluatingJavaScriptFromString:WebViewJavascriptBridge_js]); + [webView stringByEvaluatingJavaScriptFromString:WebViewJavascriptBridge_js]; } if (_startupMessageQueue) { From 09e8e28a090647f07254e672f81cdf2695ac9fb8 Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Thu, 23 Apr 2015 11:33:56 -0400 Subject: [PATCH 009/158] Added note about the importance of ending lines with semicolons. --- WebViewJavascriptBridge/WebViewJavascriptBridge.js.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.js.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.js.h index 8efffafe..63594a28 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.js.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.js.h @@ -1,6 +1,9 @@ #ifdef _______STRINGIFY #error _______STRINGIFY already defined! #endif + +// The preprocessor will remove line-endings so you MUST use semi-colons to denote the end of a line. + #define _______STRINGIFY(x) #x _______STRINGIFY( ;(function() { From e57ae96b5a6be7e19aef3ab4f288ebb5a334e7e4 Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Thu, 23 Apr 2015 14:26:22 -0400 Subject: [PATCH 010/158] Removed resource from pod spec. Made private header more explicit. --- WebViewJavascriptBridge.podspec | 2 +- .../{ => Private}/WebViewJavascriptBridge.js.h | 0 WebViewJavascriptBridge/WebViewJavascriptBridge.m | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename WebViewJavascriptBridge/{ => Private}/WebViewJavascriptBridge.js.h (100%) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index fbb16a8b..2c1d962f 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.osx.platform = :osx s.ios.source_files = 'WebViewJavascriptBridge/*.{h,m}' s.osx.source_files = 'WebViewJavascriptBridge/*.{h,m}' - s.resource = 'WebViewJavascriptBridge/WebViewJavascriptBridge.js.txt' + s.private_header_files = "WebViewJavascriptBridge/Private/WebViewJavascriptBridge.js.h" s.ios.framework = 'UIKit' s.osx.framework = 'WebKit' end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.js.h b/WebViewJavascriptBridge/Private/WebViewJavascriptBridge.js.h similarity index 100% rename from WebViewJavascriptBridge/WebViewJavascriptBridge.js.h rename to WebViewJavascriptBridge/Private/WebViewJavascriptBridge.js.h diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index 927203d4..167b66d2 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -9,7 +9,7 @@ #import "WebViewJavascriptBridge.h" static NSString * WebViewJavascriptBridge_js = @ -#include "WebViewJavascriptBridge.js.h" +#include "Private/WebViewJavascriptBridge.js.h" ; #if __has_feature(objc_arc_weak) From d3341c7b931b01ea385f992fd54266004deb838f Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Thu, 23 Apr 2015 15:09:20 -0400 Subject: [PATCH 011/158] Tightened up the Javascript Source String Generation. --- .../ExampleApp-OSX.xcodeproj/project.pbxproj | 10 +++++---- .../ExampleApp-iOS.xcodeproj/project.pbxproj | 10 +++++---- WebViewJavascriptBridge.podspec | 2 +- .../WebViewJavascriptBridge.m | 9 +++----- .../WebViewJavascriptBridge_Private.h | 3 +++ ...js.h => WebViewJavascriptBridge_Private.m} | 22 +++++++++++++------ 6 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 WebViewJavascriptBridge/WebViewJavascriptBridge_Private.h rename WebViewJavascriptBridge/{Private/WebViewJavascriptBridge.js.h => WebViewJavascriptBridge_Private.m} (93%) diff --git a/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj index d35d1ee7..c25aa4e6 100644 --- a/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj @@ -14,9 +14,9 @@ 2C136A3817641106004C7401 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C136A3717641106004C7401 /* AppDelegate.m */; }; 2C136A4217641236004C7401 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C136A4117641236004C7401 /* WebKit.framework */; }; 2C136A5A17642704004C7401 /* ExampleApp.html in Resources */ = {isa = PBXBuildFile; fileRef = 2C136A5917642704004C7401 /* ExampleApp.html */; }; - 2C1562C5176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.h in Resources */ = {isa = PBXBuildFile; fileRef = 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.h */; }; 2C1562C6176BA9FF00B4AE50 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */; }; 2CF17F5317D8AACF006E828B /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2CF17F5217D8AACF006E828B /* MainMenu.xib */; }; + AA9B44271AE979A800E48BA0 /* WebViewJavascriptBridge_Private.m in Sources */ = {isa = PBXBuildFile; fileRef = AA9B44261AE979A800E48BA0 /* WebViewJavascriptBridge_Private.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -35,9 +35,10 @@ 2C136A4117641236004C7401 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; 2C136A5917642704004C7401 /* ExampleApp.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ExampleApp.html; sourceTree = SOURCE_ROOT; }; 2C1562C2176BA9FF00B4AE50 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = ""; }; - 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.js.h; sourceTree = ""; }; 2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = ""; }; 2CF17F5217D8AACF006E828B /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = ""; }; + AA9B44251AE979A800E48BA0 /* WebViewJavascriptBridge_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge_Private.h; sourceTree = ""; }; + AA9B44261AE979A800E48BA0 /* WebViewJavascriptBridge_Private.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge_Private.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -119,8 +120,9 @@ isa = PBXGroup; children = ( 2C1562C2176BA9FF00B4AE50 /* WebViewJavascriptBridge.h */, - 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.h */, 2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */, + AA9B44251AE979A800E48BA0 /* WebViewJavascriptBridge_Private.h */, + AA9B44261AE979A800E48BA0 /* WebViewJavascriptBridge_Private.m */, ); name = WebViewJavascriptBridge; path = ../../WebViewJavascriptBridge; @@ -177,7 +179,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2C1562C5176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.h in Resources */, 2C136A2F17641106004C7401 /* InfoPlist.strings in Resources */, 2C136A3517641106004C7401 /* Credits.rtf in Resources */, 2C136A5A17642704004C7401 /* ExampleApp.html in Resources */, @@ -193,6 +194,7 @@ buildActionMask = 2147483647; files = ( 2C136A3117641106004C7401 /* main.m in Sources */, + AA9B44271AE979A800E48BA0 /* WebViewJavascriptBridge_Private.m in Sources */, 2C1562C6176BA9FF00B4AE50 /* WebViewJavascriptBridge.m in Sources */, 2C136A3817641106004C7401 /* AppDelegate.m in Sources */, ); diff --git a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj index 1e33172d..0bda1cb7 100644 --- a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 2C1562B5176B9F8400B4AE50 /* WebViewJavascriptBridge.js.h in Resources */ = {isa = PBXBuildFile; fileRef = 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.h */; }; 2C1562C0176BA63500B4AE50 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */; }; 2C45CA2C1884AD520002A4E2 /* ExampleAppViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C45CA2B1884AD520002A4E2 /* ExampleAppViewController.m */; }; 2CA045BF17117439006DEE8B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2CA045B717117439006DEE8B /* InfoPlist.strings */; }; @@ -18,12 +17,12 @@ 2CEB3EC01602563600548120 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EBF1602563600548120 /* UIKit.framework */; }; 2CEB3EC21602563600548120 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EC11602563600548120 /* Foundation.framework */; }; 2CEB3EC41602563600548120 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EC31602563600548120 /* CoreGraphics.framework */; }; + AA9B44241AE9761700E48BA0 /* WebViewJavascriptBridge_Private.m in Sources */ = {isa = PBXBuildFile; fileRef = AA9B44221AE9761700E48BA0 /* WebViewJavascriptBridge_Private.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 2C1562A8176B9F6200B4AE50 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = ""; }; 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = ""; }; - 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.js.h; sourceTree = ""; }; 2C45CA2A1884AD520002A4E2 /* ExampleAppViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleAppViewController.h; sourceTree = ""; }; 2C45CA2B1884AD520002A4E2 /* ExampleAppViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleAppViewController.m; sourceTree = ""; }; 2CA045B817117439006DEE8B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -38,6 +37,8 @@ 2CEB3EBF1602563600548120 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 2CEB3EC11602563600548120 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 2CEB3EC31602563600548120 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + AA9B44221AE9761700E48BA0 /* WebViewJavascriptBridge_Private.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge_Private.m; sourceTree = ""; }; + AA9B44231AE9761700E48BA0 /* WebViewJavascriptBridge_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge_Private.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -57,9 +58,10 @@ 2C1562A7176B9F5400B4AE50 /* WebViewJavascriptBridge */ = { isa = PBXGroup; children = ( - 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.h */, 2C1562A8176B9F6200B4AE50 /* WebViewJavascriptBridge.h */, 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */, + AA9B44221AE9761700E48BA0 /* WebViewJavascriptBridge_Private.m */, + AA9B44231AE9761700E48BA0 /* WebViewJavascriptBridge_Private.h */, ); name = WebViewJavascriptBridge; path = ../../WebViewJavascriptBridge; @@ -169,7 +171,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2C1562B5176B9F8400B4AE50 /* WebViewJavascriptBridge.js.h in Resources */, 2CA045BF17117439006DEE8B /* InfoPlist.strings in Resources */, 2CA0465C1711AC8E006DEE8B /* ExampleApp.html in Resources */, 2CAB869B1727684300BD9ED1 /* Default-568h@2x.png in Resources */, @@ -183,6 +184,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + AA9B44241AE9761700E48BA0 /* WebViewJavascriptBridge_Private.m in Sources */, 2C1562C0176BA63500B4AE50 /* WebViewJavascriptBridge.m in Sources */, 2C45CA2C1884AD520002A4E2 /* ExampleAppViewController.m in Sources */, 2CA045C217117439006DEE8B /* ExampleAppDelegate.m in Sources */, diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 2c1d962f..ec9f6650 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.osx.platform = :osx s.ios.source_files = 'WebViewJavascriptBridge/*.{h,m}' s.osx.source_files = 'WebViewJavascriptBridge/*.{h,m}' - s.private_header_files = "WebViewJavascriptBridge/Private/WebViewJavascriptBridge.js.h" + s.private_header_files = 'WebViewJavascriptBridge/*_Private.h' s.ios.framework = 'UIKit' s.osx.framework = 'WebKit' end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index 167b66d2..1d864f3c 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -7,10 +7,7 @@ // #import "WebViewJavascriptBridge.h" - -static NSString * WebViewJavascriptBridge_js = @ -#include "Private/WebViewJavascriptBridge.js.h" -; +#import "WebViewJavascriptBridge_Private.h" #if __has_feature(objc_arc_weak) #define WVJB_WEAK __weak @@ -256,7 +253,7 @@ - (void)webView:(WebView *)webView didFinishLoadForFrame:(WebFrame *)frame if (webView != _webView) { return; } if (![[webView stringByEvaluatingJavaScriptFromString:@"typeof WebViewJavascriptBridge == 'object'"] isEqualToString:@"true"]) { - [webView stringByEvaluatingJavaScriptFromString:WebViewJavascriptBridge_js]; + [webView stringByEvaluatingJavaScriptFromString:WebViewJavascriptBridge_js()]; } if (_startupMessageQueue) { @@ -340,7 +337,7 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView { _numRequestsLoading--; if (_numRequestsLoading == 0 && ![[webView stringByEvaluatingJavaScriptFromString:@"typeof WebViewJavascriptBridge == 'object'"] isEqualToString:@"true"]) { - [webView stringByEvaluatingJavaScriptFromString:WebViewJavascriptBridge_js]; + [webView stringByEvaluatingJavaScriptFromString:WebViewJavascriptBridge_js()]; } if (_startupMessageQueue) { diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_Private.h b/WebViewJavascriptBridge/WebViewJavascriptBridge_Private.h new file mode 100644 index 00000000..1d9577fd --- /dev/null +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_Private.h @@ -0,0 +1,3 @@ +#import + +NSString * WebViewJavascriptBridge_js(); diff --git a/WebViewJavascriptBridge/Private/WebViewJavascriptBridge.js.h b/WebViewJavascriptBridge/WebViewJavascriptBridge_Private.m similarity index 93% rename from WebViewJavascriptBridge/Private/WebViewJavascriptBridge.js.h rename to WebViewJavascriptBridge/WebViewJavascriptBridge_Private.m index 63594a28..3d84737d 100644 --- a/WebViewJavascriptBridge/Private/WebViewJavascriptBridge.js.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_Private.m @@ -1,11 +1,14 @@ -#ifdef _______STRINGIFY -#error _______STRINGIFY already defined! -#endif + +#import "WebViewJavascriptBridge_Private.h" + +NSString * WebViewJavascriptBridge_js() { +// Create a unique preprocessor symbol that last only the duration of this function +#define __func__(x) #x // The preprocessor will remove line-endings so you MUST use semi-colons to denote the end of a line. + +static NSString * source = @__func__( -#define _______STRINGIFY(x) #x -_______STRINGIFY( ;(function() { if (window.WebViewJavascriptBridge) { return; } var messagingIframe; @@ -123,5 +126,10 @@ _______STRINGIFY( readyEvent.bridge = WebViewJavascriptBridge; doc.dispatchEvent(readyEvent); })(); -) -#undef _______STRINGIFY + +); + +#undef __func__ + + return source; +}; From 71649ae32ec60812f2e810bdf2ba584004fcbe86 Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Thu, 6 Aug 2015 09:04:22 -0400 Subject: [PATCH 012/158] Moved the Javascript implementation to a file ending in "_JS.(h/m). Added explanation to _JS.m file. --- WebViewJavascriptBridge.podspec | 2 +- WebViewJavascriptBridge/WebViewJavascriptBridge.m | 2 +- ...tBridge_Private.h => WebViewJavascriptBridge_JS.h} | 0 ...tBridge_Private.m => WebViewJavascriptBridge_JS.m} | 11 ++++++++++- 4 files changed, 12 insertions(+), 3 deletions(-) rename WebViewJavascriptBridge/{WebViewJavascriptBridge_Private.h => WebViewJavascriptBridge_JS.h} (100%) rename WebViewJavascriptBridge/{WebViewJavascriptBridge_Private.m => WebViewJavascriptBridge_JS.m} (86%) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index ec9f6650..919c9c81 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.osx.platform = :osx s.ios.source_files = 'WebViewJavascriptBridge/*.{h,m}' s.osx.source_files = 'WebViewJavascriptBridge/*.{h,m}' - s.private_header_files = 'WebViewJavascriptBridge/*_Private.h' + s.private_header_files = 'WebViewJavascriptBridge/*_JS.h' s.ios.framework = 'UIKit' s.osx.framework = 'WebKit' end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index 1d864f3c..4779eb3e 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -7,7 +7,7 @@ // #import "WebViewJavascriptBridge.h" -#import "WebViewJavascriptBridge_Private.h" +#import "WebViewJavascriptBridge_JS.h" #if __has_feature(objc_arc_weak) #define WVJB_WEAK __weak diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_Private.h b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h similarity index 100% rename from WebViewJavascriptBridge/WebViewJavascriptBridge_Private.h rename to WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_Private.m b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m similarity index 86% rename from WebViewJavascriptBridge/WebViewJavascriptBridge_Private.m rename to WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m index 3d84737d..a3e1c733 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge_Private.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m @@ -1,5 +1,14 @@ +// This file contains the source for the Javascript side of the +// WebViewJavascriptBridge. It is plaintext, but converted to an NSString +// via some preprocessor tricks. +// +// Previous implementations of WebViewJavascriptBridge loaded the javascript source +// from a resource. This worked fine for app developers, but library developers who +// included the bridge into their library, awkwardly had to ask consumers of their +// library to include the resource, violating their encapsulation. By including the +// Javascript as a string resource, the encapsulation of the library is maintained. -#import "WebViewJavascriptBridge_Private.h" +#import "WebViewJavascriptBridge_JS.h" NSString * WebViewJavascriptBridge_js() { // Create a unique preprocessor symbol that last only the duration of this function From 0edbfe6e05f29b96c9893c806368d94b6a56d750 Mon Sep 17 00:00:00 2001 From: Hugo Schouman Date: Fri, 7 Aug 2015 16:43:51 +0200 Subject: [PATCH 013/158] fix bundle for iOS 9 frameworks --- WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index 3717eb7d..cfce7e85 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -116,7 +116,7 @@ - (void)flushMessageQueue:(NSString *)messageQueueString{ - (void)injectJavascriptFile:(BOOL)shouldInject { if(shouldInject){ - NSBundle *bundle = _resourceBundle ? _resourceBundle : [NSBundle mainBundle]; + NSBundle *bundle = _resourceBundle ? _resourceBundle : [NSBundle bundleForClass:[self class]]; NSString *filePath = [bundle pathForResource:@"WebViewJavascriptBridge.js" ofType:@"txt"]; NSString *js = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; [self _evaluateJavascript:js]; From 722ddf0de63033003bb8beaf1d76aa92af275f48 Mon Sep 17 00:00:00 2001 From: Joey Pereira Date: Thu, 13 Aug 2015 22:27:34 -0400 Subject: [PATCH 014/158] added podfile documentation --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index aaecaae5..11f9ff2f 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,18 @@ WebViewJavascriptBridge is used by a range of companies and projects. This list Setup & Examples (iOS & OSX) ---------------------------- +### Installation with CocoaPods + +[CocoaPods](http://cocoapods.org) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like WebViewJavascriptBridge in your projects. See the following [Getting Started](https://guides.cocoapods.org/using/getting-started.html) page for CocoaPods for more information. + +#### Podfile +Add the following to your podfile to add this library to your project. Run `pod install` to install them afterwards. +```ruby +`pod 'WebViewJavascriptBridge', '~> 4.1.4'` +``` + +## Other Usage + Start with the Example Apps/ folder. Open either the iOS or OSX project and hit run to see it in action. To use a WebViewJavascriptBridge in your own project: From 8dadad6dd0db1c7de5f2bf2362d648af6a1a20bd Mon Sep 17 00:00:00 2001 From: Morton Fox Date: Fri, 21 Aug 2015 14:28:30 -0400 Subject: [PATCH 015/158] Update Imbed link. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c5c103d1..f33991b3 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ WebViewJavascriptBridge is used by a range of companies and projects. This list - [Sush.io](http://www.sush.io) - Flutterby Labs - JD Media's [鼎盛中华](https://itunes.apple.com/us/app/ding-sheng-zhong-hua/id537273940?mt=8) -- Dojo4's [Imbed](http://dojo4.github.io/imbed/) +- Dojo4's [Imbed](http://imbed.github.io/) - [CareZone](https://carezone.com) - [Hemlig](http://www.hemlig.co) - [FRIL](https://fril.jp) From 79df14f67532020c5639278d98e21740e6bb2f9b Mon Sep 17 00:00:00 2001 From: CashLee Date: Mon, 23 Nov 2015 18:21:16 +0800 Subject: [PATCH 016/158] [mod]use 'decisionHandler(WKNavigationActionPolicyCancel)' to replace '[webView stopLoading]' --- WebViewJavascriptBridge/WKWebViewJavascriptBridge.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index a8fb107c..3cf5488d 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -127,7 +127,7 @@ - (void)webView:(WKWebView *)webView } else { [_base logUnkownMessage:url]; } - [webView stopLoading]; + decisionHandler(WKNavigationActionPolicyCancel) } if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)]) { From f5e92dd1d49c67724719491ae0f7696026dff9c1 Mon Sep 17 00:00:00 2001 From: CashLee Date: Mon, 23 Nov 2015 18:34:14 +0800 Subject: [PATCH 017/158] Add semicolon Add semicolon after decisionHandler --- WebViewJavascriptBridge/WKWebViewJavascriptBridge.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index 3cf5488d..ee298dbe 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -127,7 +127,7 @@ - (void)webView:(WKWebView *)webView } else { [_base logUnkownMessage:url]; } - decisionHandler(WKNavigationActionPolicyCancel) + decisionHandler(WKNavigationActionPolicyCancel); } if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)]) { From 3fc36dfa405601d3914628053a3756a96e031886 Mon Sep 17 00:00:00 2001 From: kingiol Date: Tue, 24 Nov 2015 18:13:52 +0800 Subject: [PATCH 018/158] add support for internet offline fail call --- WebViewJavascriptBridge/WKWebViewJavascriptBridge.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index a8fb107c..39417b49 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -162,6 +162,17 @@ - (void)webView:(WKWebView *)webView } } +- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error { + if (webView != _webView) { return; } + + _base.numRequestsLoading--; + + __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; + if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didFailProvisionalNavigation:withError:)]) { + [strongDelegate webView:webView didFailProvisionalNavigation:navigation withError:error]; + } +} + - (NSString*) _evaluateJavascript:(NSString*)javascriptCommand { [_webView evaluateJavaScript:javascriptCommand completionHandler:nil]; From 0e64a1782b27f9c6e94989089a3cd03ba33f1c99 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 23 Dec 2015 17:31:26 -0500 Subject: [PATCH 019/158] Add roadmap, including plans for #149, #126, #84, #143, #155, #167, #128, #151, #129, #138, #160, #140, #106, #133, #132, #146, #157, #168, #163, #170, #172, #156, #153, #158, #159, #144, #137, #134, #131, #120, #173, #171, #169, #162, #119, #118, #103, #104, #123, #124. --- Roadmap.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Roadmap.md diff --git a/Roadmap.md b/Roadmap.md new file mode 100644 index 00000000..d98e91c5 --- /dev/null +++ b/Roadmap.md @@ -0,0 +1,63 @@ +Roadmap +======= + +v4.1.4/5 +-------- + +- [ ] 4.1.4 or 4.1.5? +- [ ] Add WKWebView support to podspec file? (#149) +- [ ] iOS8 WKWebView support? (#126) +- [ ] WKWebView issue in OSX? (#84) +- [ ] Release new version (#143, #155, #167) + +v4.1.6 +------ + +Pull requests: + +- [ ] Dev env / docs + - [ ] Automated tests (PR #128, I #151) + - [ ] Embed js in objc source (PR #129) + - [ ] Also fixes PR #138, I #160 + - [ ] Docs for podfile installation (PR #140) +- [ ] Features & fixes to consider + - [ ] Message response timeout (PR #106) + - [ ] Optional alert-unsafe message speedup (PR #133, I #132) + - [ ] Remove or fix numRequestsLoading (PR #146, PR #157) +- [ ] Net load fixes + - [ ] Fix `[webView stopLoading]` (PR #168, I #163) + - [ ] Detect offline failed requests (PR #170) + - [ ] Handle redirects (PR #172) + - [ ] Bridge never initiates without a didLoad (I #156) + +v4.1.7 +------ +- [ ] Swift and WKWebView (#153, #158) +- [ ] Misc fixes + - [ ] Crash on _deserializeMessageJSON (I #159) + - [ ] Memory leak? (I #144) + - [ ] Pictures/_dispatchMessage queue issue? (I #137) + - [ ] Consider making webpage reloads easier (I #134) + - [ ] Fix use in $(document).ready (I #131) + - [ ] Error message on missing handler (I #120) +v4.2.x +------ + +- [ ] Swift + - [ ] Swift examples (I #173) +- [ ] Javascript + - [ ] Cookie set in client is not sent (I #171) + - [ ] Form submission error (I #169) +- [ ] React Native + - [ ] Example app (I #162) +- [ ] New features to consider + - [ ] Multiple handlers: pubsub (I #119) + - [ ] Remove handlers (I #118) +- [ ] Other platforms to consider + - [ ] Android - partly done by @fangj (#103) + - [ ] Chrome - partly done by @fangj (#104) + +Pending bug repro/info +---------------------- +- [ ] #123: unity3d and WebViewJavascriptBridge unrecognized selector sent to instance +- [ ] #124: Getting an exception during _flushMessageQueue From f9ba8d2903e0185330cc3226bbbd85543c5389ed Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 23 Dec 2015 17:57:37 -0500 Subject: [PATCH 020/158] Scripts to document common procedures --- scripts/publish.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 scripts/publish.sh diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 00000000..f09a226f --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,6 @@ +set -e +cd $(cd `dirname ${BASH_SOURCE[0]}` && pwd -P) +cd .. + +# pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' +pod trunk push --verbose WebViewJavascriptBridge.podspec \ No newline at end of file From 5a91baca0da8368883961dd781bd78281cab31b5 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 23 Dec 2015 18:04:54 -0500 Subject: [PATCH 021/158] v4.1.5 --- Roadmap.md | 11 +++++------ WebViewJavascriptBridge.podspec | 2 +- scripts/publish.sh | 3 ++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Roadmap.md b/Roadmap.md index d98e91c5..104fefd8 100644 --- a/Roadmap.md +++ b/Roadmap.md @@ -1,20 +1,18 @@ Roadmap ======= -v4.1.4/5 +v4.1.6 -------- -- [ ] 4.1.4 or 4.1.5? - [ ] Add WKWebView support to podspec file? (#149) - [ ] iOS8 WKWebView support? (#126) - [ ] WKWebView issue in OSX? (#84) - [ ] Release new version (#143, #155, #167) -v4.1.6 +v4.1.7 ------ Pull requests: - - [ ] Dev env / docs - [ ] Automated tests (PR #128, I #151) - [ ] Embed js in objc source (PR #129) @@ -29,8 +27,9 @@ Pull requests: - [ ] Detect offline failed requests (PR #170) - [ ] Handle redirects (PR #172) - [ ] Bridge never initiates without a didLoad (I #156) +- [ ] Fix OSX lint warnings (`pod spec lint`) -v4.1.7 +v4.1.8 ------ - [ ] Swift and WKWebView (#153, #158) - [ ] Misc fixes @@ -40,9 +39,9 @@ v4.1.7 - [ ] Consider making webpage reloads easier (I #134) - [ ] Fix use in $(document).ready (I #131) - [ ] Error message on missing handler (I #120) + v4.2.x ------ - - [ ] Swift - [ ] Swift examples (I #173) - [ ] Javascript diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index fbb16a8b..196223fa 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '4.1.4' + s.version = '4.1.5' s.summary = 'An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } diff --git a/scripts/publish.sh b/scripts/publish.sh index f09a226f..3e301236 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -3,4 +3,5 @@ cd $(cd `dirname ${BASH_SOURCE[0]}` && pwd -P) cd .. # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' -pod trunk push --verbose WebViewJavascriptBridge.podspec \ No newline at end of file +pod trunk push --allow-warnings --verbose WebViewJavascriptBridge.podspec +echo "WVJB publish.sh TODO: Remove --allow-warnings" \ No newline at end of file From 9da6b781b9b4689cdf9e6b39a526ed8e7dfc0b47 Mon Sep 17 00:00:00 2001 From: Vontio Date: Fri, 25 Dec 2015 10:48:04 +0800 Subject: [PATCH 022/158] pretty print json add pretty param to _serializeMessage --- WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index 3717eb7d..cb47871c 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -178,7 +178,7 @@ - (void)_queueMessage:(WVJBMessage*)message { } - (void)_dispatchMessage:(WVJBMessage*)message { - NSString *messageJSON = [self _serializeMessage:message]; + NSString *messageJSON = [self _serializeMessage:message pretty:NO]; [self _log:@"SEND" json:messageJSON]; messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"]; messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]; @@ -200,8 +200,8 @@ - (void)_dispatchMessage:(WVJBMessage*)message { } } -- (NSString *)_serializeMessage:(id)message { - return [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:message options:0 error:nil] encoding:NSUTF8StringEncoding]; +- (NSString *)_serializeMessage:(id)message pretty:(BOOL)pretty{ + return [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:message options:(NSJSONWritingOptions)(pretty ? NSJSONWritingPrettyPrinted : 0) error:nil] encoding:NSUTF8StringEncoding]; } - (NSArray*)_deserializeMessageJSON:(NSString *)messageJSON { @@ -211,7 +211,7 @@ - (NSArray*)_deserializeMessageJSON:(NSString *)messageJSON { - (void)_log:(NSString *)action json:(id)json { if (!logging) { return; } if (![json isKindOfClass:[NSString class]]) { - json = [self _serializeMessage:json]; + json = [self _serializeMessage:json pretty:YES]; } if ([json length] > 500) { NSLog(@"WVJB %@: %@ [...]", action, [json substringToIndex:500]); From 76533fd262a0841baecccbee7b324f79fd05c04b Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Fri, 25 Dec 2015 10:28:59 -0500 Subject: [PATCH 023/158] Changelog for 9da6b781b --- Changelog | 3 +++ Roadmap.md | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index a7fb8544..9d82f5b9 100644 --- a/Changelog +++ b/Changelog @@ -17,6 +17,9 @@ Intended v5.0.0 + Removed `WebViewJavascriptBridge -reset`. It should never have been exposed as a public API. + Fixed compilation in C99 mode +Next version ++ Pretty-print json in log messages + v4.1.4 + Improve how WVJB handles the case when there is no ObjC handler for a message received from js. + If an objc handler throws and exception, let it bubble up to the webkit engine instead of catching it in WVJB. diff --git a/Roadmap.md b/Roadmap.md index 104fefd8..86669730 100644 --- a/Roadmap.md +++ b/Roadmap.md @@ -15,8 +15,9 @@ v4.1.7 Pull requests: - [ ] Dev env / docs - [ ] Automated tests (PR #128, I #151) + - [ ] Travis? https://github.com/integrations/feature/code - [ ] Embed js in objc source (PR #129) - - [ ] Also fixes PR #138, I #160 + - [ ] Also fixes PR #138, I #160, I #108 - [ ] Docs for podfile installation (PR #140) - [ ] Features & fixes to consider - [ ] Message response timeout (PR #106) From 821bba59a361152c748270702f2bcd768f862b0e Mon Sep 17 00:00:00 2001 From: Vontio Date: Sat, 26 Dec 2015 19:45:18 +0800 Subject: [PATCH 024/158] add log length add setLogMaxLength method --- WebViewJavascriptBridge/WebViewJavascriptBridge.h | 1 + WebViewJavascriptBridge/WebViewJavascriptBridge.m | 1 + WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h | 1 + WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m | 6 ++++-- 4 files changed, 7 insertions(+), 2 deletions(-) mode change 100644 => 100755 WebViewJavascriptBridge/WebViewJavascriptBridge.h mode change 100644 => 100755 WebViewJavascriptBridge/WebViewJavascriptBridge.m mode change 100644 => 100755 WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h mode change 100644 => 100755 WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.h old mode 100644 new mode 100755 index 513118f1..c8e29d1c --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.h @@ -29,6 +29,7 @@ + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler; + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler resourceBundle:(NSBundle*)bundle; + (void)enableLogging; ++ (void)setLogMaxLength:(int)length; - (void)send:(id)message; - (void)send:(id)message responseCallback:(WVJBResponseCallback)responseCallback; diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m old mode 100644 new mode 100755 index b41b7c26..c152602b --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -29,6 +29,7 @@ @implementation WebViewJavascriptBridge { *****/ + (void)enableLogging { [WebViewJavascriptBridgeBase enableLogging]; } ++ (void)setLogMaxLength:(int)length { [WebViewJavascriptBridgeBase setLogMaxLength:length]; } + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView handler:(WVJBHandler)handler { return [self bridgeForWebView:webView webViewDelegate:nil handler:handler]; diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h old mode 100644 new mode 100755 index b61e6ee9..315f5d62 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -29,6 +29,7 @@ typedef NSDictionary WVJBMessage; @property NSUInteger numRequestsLoading; + (void)enableLogging; ++ (void)setLogMaxLength:(int)length; - (id)initWithHandler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle; - (void)reset; - (void)sendData:(id)data responseCallback:(WVJBResponseCallback)responseCallback handlerName:(NSString*)handlerName; diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m old mode 100644 new mode 100755 index cb47871c..139e5bdf --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -15,8 +15,10 @@ @implementation WebViewJavascriptBridgeBase { } static bool logging = false; +static int logMaxLength = 500; + (void)enableLogging { logging = true; } ++ (void)setLogMaxLength:(int)length { logMaxLength = length;} -(id)initWithHandler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle { @@ -213,8 +215,8 @@ - (void)_log:(NSString *)action json:(id)json { if (![json isKindOfClass:[NSString class]]) { json = [self _serializeMessage:json pretty:YES]; } - if ([json length] > 500) { - NSLog(@"WVJB %@: %@ [...]", action, [json substringToIndex:500]); + if ([json length] > logMaxLength) { + NSLog(@"WVJB %@: %@ [...]", action, [json substringToIndex:logMaxLength]); } else { NSLog(@"WVJB %@: %@", action, json); } From 627aa47fc2aaf17de94cbbca79484187b15d79a7 Mon Sep 17 00:00:00 2001 From: raxcat Date: Wed, 30 Dec 2015 00:23:08 +0800 Subject: [PATCH 025/158] Call policy handler with WKNavigationActionPolicyCancel instead of stopping whole WKWebView. --- WebViewJavascriptBridge/WKWebViewJavascriptBridge.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index a8fb107c..ee298dbe 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -127,7 +127,7 @@ - (void)webView:(WKWebView *)webView } else { [_base logUnkownMessage:url]; } - [webView stopLoading]; + decisionHandler(WKNavigationActionPolicyCancel); } if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)]) { From ed398e9b3af75656bfd4423ff8f3ef736905e290 Mon Sep 17 00:00:00 2001 From: yirenjun Date: Tue, 5 Jan 2016 16:36:09 +0800 Subject: [PATCH 026/158] Print a log instead raising an exception in @select(flushMessageQueue:) --- WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index 139e5bdf..8c5307f0 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -108,7 +108,8 @@ - (void)flushMessageQueue:(NSString *)messageQueueString{ } if (!handler) { - [NSException raise:@"WVJBNoHandlerException" format:@"No handler for message from JS: %@", message]; + NSLog(@"WVJBNoHandlerException, No handler for message from JS: %@", message); + continue; } handler(message[@"data"], responseCallback); From 68ff03788a03fe36693a73c7bae3c283da7ae97c Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 28 Jan 2016 10:44:37 -0500 Subject: [PATCH 027/158] Clarify and improve documentation --- README.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 1c3333ba..0078a932 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,6 @@ WebViewJavascriptBridge An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews. -If you like WebViewJavascriptBridge you may also want to check out [WebViewProxy](https://github.com/marcuswestin/WebViewProxy). - In the Wild ----------- WebViewJavascriptBridge is used by a range of companies and projects. This list is incomplete, but feel free to add your's and send a PR. @@ -23,30 +21,33 @@ WebViewJavascriptBridge is used by a range of companies and projects. This list - [Hemlig](http://www.hemlig.co) - [FRIL](https://fril.jp) -Setup & Examples (iOS & OSX) ----------------------------- +Installation (iOS & OSX) +------------------------ ### Installation with CocoaPods +Add this to your [podfile](https://guides.cocoapods.org/using/getting-started.html) and run `pod install` to install: -[CocoaPods](http://cocoapods.org) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like WebViewJavascriptBridge in your projects. See the following [Getting Started](https://guides.cocoapods.org/using/getting-started.html) page for CocoaPods for more information. - -#### Podfile -Add the following to your podfile to add this library to your project. Run `pod install` to install them afterwards. ```ruby `pod 'WebViewJavascriptBridge', '~> 4.1.4'` ``` -## Other Usage +### Manual installation + +Drag the `WebViewJavascriptBridge` folder into your project. + +In the dialog that appears, uncheck "Copy items into destination group's folder" and select "Create groups for any folders". + +Examples +-------- -Start with the Example Apps/ folder. Open either the iOS or OSX project and hit run to see it in action. +See the `Example Apps/` folder. Open either the iOS or OSX project and hit run to see it in action. To use a WebViewJavascriptBridge in your own project: -1) Drag the `WebViewJavascriptBridge` folder into your project. +Usage +----- - - In the dialog that appears, uncheck "Copy items into destination group's folder" and select "Create groups for any folders" - -2) Import the header file and declare an ivar property: +1) Import the header file and declare an ivar property: ```objc #import "WebViewJavascriptBridge.h" @@ -58,7 +59,7 @@ To use a WebViewJavascriptBridge in your own project: @property WebViewJavascriptBridge* bridge; ``` -3) Instantiate WebViewJavascriptBridge with a UIWebView (iOS) or WebView (OSX): +2) Instantiate WebViewJavascriptBridge with a UIWebView (iOS) or WebView (OSX): ```objc self.bridge = [WebViewJavascriptBridge bridgeForWebView:webView handler:^(id data, WVJBResponseCallback responseCallback) { @@ -67,7 +68,7 @@ self.bridge = [WebViewJavascriptBridge bridgeForWebView:webView handler:^(id dat }]; ``` -4) Go ahead and send some messages from ObjC to javascript: +3) Go ahead and send some messages from ObjC to javascript: ```objc [self.bridge send:@"Well hello there"]; From c1ec77b17f4f937465a156dddb5cce5df5fef234 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 28 Jan 2016 12:52:39 -0500 Subject: [PATCH 028/158] Merge in @mbishop-fiksus very clever inlining of the javascript code via a preprocessor macro. This eliminates the need to include WebViewJavascriptBridge.js.txt as a resouce. --- .../ExampleApp-OSX.xcodeproj/project.pbxproj | 10 +++++---- .../ExampleApp-iOS.xcodeproj/project.pbxproj | 10 +++++---- .../WKWebViewJavascriptBridge.h | 4 +++- .../WKWebViewJavascriptBridge.m | 15 ++++++------- .../WebViewJavascriptBridge.h | 4 +++- .../WebViewJavascriptBridge.m | 19 ++++++++-------- .../WebViewJavascriptBridgeBase.h | 2 +- .../WebViewJavascriptBridgeBase.m | 12 ++++------ .../WebViewJavascriptBridge_JS.h | 3 +++ ...ge.js.txt => WebViewJavascriptBridge_JS.m} | 22 +++++++++++++++++++ 10 files changed, 64 insertions(+), 37 deletions(-) create mode 100644 WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h rename WebViewJavascriptBridge/{WebViewJavascriptBridge.js.txt => WebViewJavascriptBridge_JS.m} (79%) diff --git a/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj index 087ea21f..410ce82c 100644 --- a/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj @@ -16,8 +16,8 @@ 2C136A3817641106004C7401 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C136A3717641106004C7401 /* AppDelegate.m */; }; 2C136A4217641236004C7401 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C136A4117641236004C7401 /* WebKit.framework */; }; 2C136A5A17642704004C7401 /* ExampleApp.html in Resources */ = {isa = PBXBuildFile; fileRef = 2C136A5917642704004C7401 /* ExampleApp.html */; }; - 2C1562C5176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt */; }; 2C1562C6176BA9FF00B4AE50 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */; }; + 2C3E7C491C5A8B8D00A1E322 /* WebViewJavascriptBridge_JS.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3E7C481C5A8B8D00A1E322 /* WebViewJavascriptBridge_JS.m */; }; 2CF17F5317D8AACF006E828B /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2CF17F5217D8AACF006E828B /* MainMenu.xib */; }; /* End PBXBuildFile section */ @@ -41,8 +41,9 @@ 2C136A4117641236004C7401 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; 2C136A5917642704004C7401 /* ExampleApp.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ExampleApp.html; sourceTree = SOURCE_ROOT; }; 2C1562C2176BA9FF00B4AE50 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = ""; }; - 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = ""; }; 2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = ""; }; + 2C3E7C471C5A8B8D00A1E322 /* WebViewJavascriptBridge_JS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge_JS.h; sourceTree = ""; }; + 2C3E7C481C5A8B8D00A1E322 /* WebViewJavascriptBridge_JS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge_JS.m; sourceTree = ""; }; 2CF17F5217D8AACF006E828B /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = ""; }; /* End PBXFileReference section */ @@ -124,12 +125,13 @@ 2C1562C1176BA9FF00B4AE50 /* WebViewJavascriptBridge */ = { isa = PBXGroup; children = ( + 2C3E7C471C5A8B8D00A1E322 /* WebViewJavascriptBridge_JS.h */, + 2C3E7C481C5A8B8D00A1E322 /* WebViewJavascriptBridge_JS.m */, 0ECB01451A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.h */, 0ECB01461A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.m */, 0ECB01471A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.h */, 0ECB01481A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.m */, 2C1562C2176BA9FF00B4AE50 /* WebViewJavascriptBridge.h */, - 2C1562C3176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt */, 2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */, ); name = WebViewJavascriptBridge; @@ -187,7 +189,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2C1562C5176BA9FF00B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */, 2C136A2F17641106004C7401 /* InfoPlist.strings in Resources */, 2C136A3517641106004C7401 /* Credits.rtf in Resources */, 2C136A5A17642704004C7401 /* ExampleApp.html in Resources */, @@ -204,6 +205,7 @@ files = ( 0ECB01491A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.m in Sources */, 0ECB014A1A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.m in Sources */, + 2C3E7C491C5A8B8D00A1E322 /* WebViewJavascriptBridge_JS.m in Sources */, 2C136A3117641106004C7401 /* main.m in Sources */, 2C1562C6176BA9FF00B4AE50 /* WebViewJavascriptBridge.m in Sources */, 2C136A3817641106004C7401 /* AppDelegate.m in Sources */, diff --git a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj index e2dd2089..c1039a80 100644 --- a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj @@ -11,8 +11,8 @@ 0E50601C1A01B442000BEEEA /* WebViewJavascriptBridgeBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 0E50601B1A01B442000BEEEA /* WebViewJavascriptBridgeBase.m */; }; 0E8082DB19EDC32300479452 /* WKWebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 0E8082DA19EDC32300479452 /* WKWebViewJavascriptBridge.m */; }; 0ECB01441A0EE1F20037FF4E /* ExampleWKWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0ECB01431A0EE1F20037FF4E /* ExampleWKWebViewController.m */; }; - 2C1562B5176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */; }; 2C1562C0176BA63500B4AE50 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */; }; + 2C3E7C461C5A890A00A1E322 /* WebViewJavascriptBridge_JS.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3E7C451C5A890A00A1E322 /* WebViewJavascriptBridge_JS.m */; }; 2C45CA2C1884AD520002A4E2 /* ExampleUIWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C45CA2B1884AD520002A4E2 /* ExampleUIWebViewController.m */; }; 2CA045BF17117439006DEE8B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2CA045B717117439006DEE8B /* InfoPlist.strings */; }; 2CA045C217117439006DEE8B /* ExampleAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CA045BD17117439006DEE8B /* ExampleAppDelegate.m */; }; @@ -34,7 +34,8 @@ 0ECB01431A0EE1F20037FF4E /* ExampleWKWebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleWKWebViewController.m; sourceTree = ""; }; 2C1562A8176B9F6200B4AE50 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = ""; }; 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = ""; }; - 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = ""; }; + 2C3E7C441C5A890A00A1E322 /* WebViewJavascriptBridge_JS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge_JS.h; sourceTree = ""; }; + 2C3E7C451C5A890A00A1E322 /* WebViewJavascriptBridge_JS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge_JS.m; sourceTree = ""; }; 2C45CA2A1884AD520002A4E2 /* ExampleUIWebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleUIWebViewController.h; sourceTree = ""; }; 2C45CA2B1884AD520002A4E2 /* ExampleUIWebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleUIWebViewController.m; sourceTree = ""; }; 2CA045B817117439006DEE8B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -69,7 +70,8 @@ 2C1562A7176B9F5400B4AE50 /* WebViewJavascriptBridge */ = { isa = PBXGroup; children = ( - 2C1562B4176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt */, + 2C3E7C441C5A890A00A1E322 /* WebViewJavascriptBridge_JS.h */, + 2C3E7C451C5A890A00A1E322 /* WebViewJavascriptBridge_JS.m */, 2C1562A8176B9F6200B4AE50 /* WebViewJavascriptBridge.h */, 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */, 0E8082DA19EDC32300479452 /* WKWebViewJavascriptBridge.m */, @@ -188,7 +190,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2C1562B5176B9F8400B4AE50 /* WebViewJavascriptBridge.js.txt in Resources */, 2CA045BF17117439006DEE8B /* InfoPlist.strings in Resources */, 2CA0465C1711AC8E006DEE8B /* ExampleApp.html in Resources */, 2CAB869B1727684300BD9ED1 /* Default-568h@2x.png in Resources */, @@ -202,6 +203,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 2C3E7C461C5A890A00A1E322 /* WebViewJavascriptBridge_JS.m in Sources */, 2C1562C0176BA63500B4AE50 /* WebViewJavascriptBridge.m in Sources */, 0E8082DB19EDC32300479452 /* WKWebViewJavascriptBridge.m in Sources */, 2C45CA2C1884AD520002A4E2 /* ExampleUIWebViewController.m in Sources */, diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h index 2ed75d24..6600b82c 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h @@ -19,7 +19,6 @@ + (instancetype)bridgeForWebView:(WKWebView*)webView handler:(WVJBHandler)handler; + (instancetype)bridgeForWebView:(WKWebView*)webView webViewDelegate:(NSObject*)webViewDelegate handler:(WVJBHandler)handler; -+ (instancetype)bridgeForWebView:(WKWebView*)webView webViewDelegate:(NSObject*)webViewDelegate handler:(WVJBHandler)handler resourceBundle:(NSBundle*)bundle; + (void)enableLogging; - (void)send:(id)message; @@ -30,6 +29,9 @@ - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; - (void)reset; +// Deprecated ++ (instancetype)bridgeForWebView:(WKWebView*)webView webViewDelegate:(NSObject*)webViewDelegate handler:(WVJBHandler)handler resourceBundle:(NSBundle*)bundle __attribute__((deprecated("resourceBundle is no longer required. Use bridgeForWebView:webViewDelegate:handler: instead"))); + @end #endif \ No newline at end of file diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index a8fb107c..0c0361f6 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -27,17 +27,16 @@ + (instancetype)bridgeForWebView:(WKWebView*)webView handler:(WVJBHandler)handle } + (instancetype)bridgeForWebView:(WKWebView*)webView webViewDelegate:(NSObject*)webViewDelegate handler:(WVJBHandler)messageHandler { - return [self bridgeForWebView:webView webViewDelegate:webViewDelegate handler:messageHandler resourceBundle:nil]; -} - -+ (instancetype)bridgeForWebView:(WKWebView*)webView webViewDelegate:(NSObject*)webViewDelegate handler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle -{ WKWebViewJavascriptBridge* bridge = [[self alloc] init]; - [bridge _setupInstance:webView webViewDelegate:webViewDelegate handler:messageHandler resourceBundle:bundle]; + [bridge _setupInstance:webView webViewDelegate:webViewDelegate handler:messageHandler]; [bridge reset]; return bridge; } ++ (instancetype)bridgeForWebView:(WKWebView*)webView webViewDelegate:(NSObject*)webViewDelegate handler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle { + return [self bridgeForWebView:webView webViewDelegate:webViewDelegate handler:messageHandler]; +} + - (void)send:(id)data { [self send:data responseCallback:nil]; } @@ -80,11 +79,11 @@ - (void)dealloc { /* WKWebView Specific Internals ******************************/ -- (void) _setupInstance:(WKWebView*)webView webViewDelegate:(id)webViewDelegate handler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle{ +- (void) _setupInstance:(WKWebView*)webView webViewDelegate:(id)webViewDelegate handler:(WVJBHandler)messageHandler { _webView = webView; _webViewDelegate = webViewDelegate; _webView.navigationDelegate = self; - _base = [[WebViewJavascriptBridgeBase alloc] initWithHandler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle]; + _base = [[WebViewJavascriptBridgeBase alloc] initWithHandler:(WVJBHandler)messageHandler]; _base.delegate = self; } diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.h index c8e29d1c..00bbdcf5 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.h @@ -27,7 +27,6 @@ + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView handler:(WVJBHandler)handler; + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler; -+ (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler resourceBundle:(NSBundle*)bundle; + (void)enableLogging; + (void)setLogMaxLength:(int)length; @@ -38,4 +37,7 @@ - (void)callHandler:(NSString*)handlerName data:(id)data; - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; +// Deprecated ++ (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler resourceBundle:(NSBundle*)bundle __attribute__((deprecated("resourceBundle is no longer required. Use bridgeForWebView:webViewDelegate:handler: instead"))); + @end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index c152602b..ec99a8b3 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -36,16 +36,15 @@ + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView handler:(WVJBHandle } + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)messageHandler { - return [self bridgeForWebView:webView webViewDelegate:webViewDelegate handler:messageHandler resourceBundle:nil]; -} - -+ (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle -{ WebViewJavascriptBridge* bridge = [[self alloc] init]; - [bridge _platformSpecificSetup:webView webViewDelegate:webViewDelegate handler:messageHandler resourceBundle:bundle]; + [bridge _platformSpecificSetup:webView webViewDelegate:webViewDelegate handler:messageHandler]; return bridge; } ++ (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)messageHandler resourceBundle:(NSBundle *)bundle { + return [self bridgeForWebView:webView webViewDelegate:webViewDelegate handler:messageHandler]; +} + - (void)send:(id)data { [self send:data responseCallback:nil]; } @@ -89,7 +88,7 @@ - (NSString*) _evaluateJavascript:(NSString*)javascriptCommand **********************************/ #if defined WVJB_PLATFORM_OSX -- (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle{ +- (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)messageHandler { _webView = webView; _webViewDelegate = webViewDelegate; @@ -97,7 +96,7 @@ - (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJ _webView.resourceLoadDelegate = self; _webView.policyDelegate = self; - _base = [[WebViewJavascriptBridgeBase alloc] initWithHandler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle]; + _base = [[WebViewJavascriptBridgeBase alloc] initWithHandler:(WVJBHandler)messageHandler]; _base.delegate = self; } @@ -174,11 +173,11 @@ - (NSURLRequest *)webView:(WebView *)webView resource:(id)identifier willSendReq **********************************/ #elif defined WVJB_PLATFORM_IOS -- (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(id)webViewDelegate handler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle{ +- (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(id)webViewDelegate handler:(WVJBHandler)messageHandler { _webView = webView; _webView.delegate = self; _webViewDelegate = webViewDelegate; - _base = [[WebViewJavascriptBridgeBase alloc] initWithHandler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle]; + _base = [[WebViewJavascriptBridgeBase alloc] initWithHandler:(WVJBHandler)messageHandler]; _base.delegate = self; } diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h index 315f5d62..06ec5304 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -30,7 +30,7 @@ typedef NSDictionary WVJBMessage; + (void)enableLogging; + (void)setLogMaxLength:(int)length; -- (id)initWithHandler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle; +- (id)initWithHandler:(WVJBHandler)messageHandler; - (void)reset; - (void)sendData:(id)data responseCallback:(WVJBResponseCallback)responseCallback handlerName:(NSString*)handlerName; - (void)flushMessageQueue:(NSString *)messageQueueString; diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index 421b741e..4cba5236 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -7,11 +7,11 @@ #import #import "WebViewJavascriptBridgeBase.h" +#import "WebViewJavascriptBridge_JS.h" @implementation WebViewJavascriptBridgeBase { id _webViewDelegate; long _uniqueId; - NSBundle *_resourceBundle; } static bool logging = false; @@ -20,10 +20,8 @@ @implementation WebViewJavascriptBridgeBase { + (void)enableLogging { logging = true; } + (void)setLogMaxLength:(int)length { logMaxLength = length;} --(id)initWithHandler:(WVJBHandler)messageHandler resourceBundle:(NSBundle*)bundle -{ +-(id)initWithHandler:(WVJBHandler)messageHandler { self = [super init]; - _resourceBundle = bundle; self.messageHandler = messageHandler; self.messageHandlers = [NSMutableDictionary dictionary]; self.startupMessageQueue = [NSMutableArray array]; @@ -117,10 +115,8 @@ - (void)flushMessageQueue:(NSString *)messageQueueString{ } - (void)injectJavascriptFile:(BOOL)shouldInject { - if(shouldInject){ - NSBundle *bundle = _resourceBundle ? _resourceBundle : [NSBundle bundleForClass:[self class]]; - NSString *filePath = [bundle pathForResource:@"WebViewJavascriptBridge.js" ofType:@"txt"]; - NSString *js = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; + if (shouldInject){ + NSString *js = WebViewJavascriptBridge_js(); [self _evaluateJavascript:js]; [self dispatchStartUpMessageQueue]; } diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h new file mode 100644 index 00000000..6cb1cb95 --- /dev/null +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h @@ -0,0 +1,3 @@ +#import + +NSString * WebViewJavascriptBridge_js(); \ No newline at end of file diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.js.txt b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m similarity index 79% rename from WebViewJavascriptBridge/WebViewJavascriptBridge.js.txt rename to WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m index 007fba05..2e0c3854 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.js.txt +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m @@ -1,3 +1,20 @@ +// This file contains the source for the Javascript side of the +// WebViewJavascriptBridge. It is plaintext, but converted to an NSString +// via some preprocessor tricks. +// +// Previous implementations of WebViewJavascriptBridge loaded the javascript source +// from a resource. This worked fine for app developers, but library developers who +// included the bridge into their library, awkwardly had to ask consumers of their +// library to include the resource, violating their encapsulation. By including the +// Javascript as a string resource, the encapsulation of the library is maintained. + +#import "WebViewJavascriptBridge_JS.h" + +NSString * WebViewJavascriptBridge_js() { + #define __wvjb_js_func__(x) #x + + // BEGIN preprocessorJSCode + static NSString * preprocessorJSCode = @__wvjb_js_func__( ;(function() { if (window.WebViewJavascriptBridge) { return; @@ -121,3 +138,8 @@ function _handleMessageFromObjC(messageJSON) { readyEvent.bridge = WebViewJavascriptBridge; doc.dispatchEvent(readyEvent); })(); + ); // END preprocessorJSCode + + #undef __wvjb_js_func__ + return preprocessorJSCode; +}; \ No newline at end of file From 34d961310f16757cbc15f2149641bb5e21702656 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 28 Jan 2016 12:53:00 -0500 Subject: [PATCH 029/158] Fix layout for iPhone 4-size --- Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m | 6 +++--- Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m b/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m index cbbf9451..d77a713f 100644 --- a/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m +++ b/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m @@ -60,7 +60,7 @@ - (void)renderButtons:(UIWebView*)webView { [messageButton setTitle:@"Send message" forState:UIControlStateNormal]; [messageButton addTarget:self action:@selector(sendMessage:) forControlEvents:UIControlEventTouchUpInside]; [self.view insertSubview:messageButton aboveSubview:webView]; - messageButton.frame = CGRectMake(10, 414, 100, 35); + messageButton.frame = CGRectMake(10, 400, 100, 35); messageButton.titleLabel.font = font; messageButton.backgroundColor = [UIColor colorWithWhite:1 alpha:0.75]; @@ -68,14 +68,14 @@ - (void)renderButtons:(UIWebView*)webView { [callbackButton setTitle:@"Call handler" forState:UIControlStateNormal]; [callbackButton addTarget:self action:@selector(callHandler:) forControlEvents:UIControlEventTouchUpInside]; [self.view insertSubview:callbackButton aboveSubview:webView]; - callbackButton.frame = CGRectMake(110, 414, 100, 35); + callbackButton.frame = CGRectMake(110, 400, 100, 35); callbackButton.titleLabel.font = font; UIButton* reloadButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [reloadButton setTitle:@"Reload webview" forState:UIControlStateNormal]; [reloadButton addTarget:webView action:@selector(reload) forControlEvents:UIControlEventTouchUpInside]; [self.view insertSubview:reloadButton aboveSubview:webView]; - reloadButton.frame = CGRectMake(210, 414, 100, 35); + reloadButton.frame = CGRectMake(210, 400, 100, 35); reloadButton.titleLabel.font = font; } diff --git a/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m b/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m index 167530d6..c265b2ea 100644 --- a/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m +++ b/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m @@ -63,7 +63,7 @@ - (void)renderButtons:(WKWebView*)webView { [messageButton setTitle:@"Send message" forState:UIControlStateNormal]; [messageButton addTarget:self action:@selector(sendMessage:) forControlEvents:UIControlEventTouchUpInside]; [self.view insertSubview:messageButton aboveSubview:webView]; - messageButton.frame = CGRectMake(10, 414, 100, 35); + messageButton.frame = CGRectMake(10, 400, 100, 35); messageButton.titleLabel.font = font; messageButton.backgroundColor = [UIColor colorWithWhite:1 alpha:0.75]; @@ -71,14 +71,14 @@ - (void)renderButtons:(WKWebView*)webView { [callbackButton setTitle:@"Call handler" forState:UIControlStateNormal]; [callbackButton addTarget:self action:@selector(callHandler:) forControlEvents:UIControlEventTouchUpInside]; [self.view insertSubview:callbackButton aboveSubview:webView]; - callbackButton.frame = CGRectMake(110, 414, 100, 35); + callbackButton.frame = CGRectMake(110, 400, 100, 35); callbackButton.titleLabel.font = font; UIButton* reloadButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [reloadButton setTitle:@"Reload webview" forState:UIControlStateNormal]; [reloadButton addTarget:webView action:@selector(reload) forControlEvents:UIControlEventTouchUpInside]; [self.view insertSubview:reloadButton aboveSubview:webView]; - reloadButton.frame = CGRectMake(210, 414, 100, 35); + reloadButton.frame = CGRectMake(210, 400, 100, 35); reloadButton.titleLabel.font = font; } From b3a5da528ef2e98645c02b79d8af557a06422e83 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 28 Jan 2016 13:03:14 -0500 Subject: [PATCH 030/158] Fix test build - use new inlined javascript WebViewJavascriptBridge_JS instead of including the WebViewJavascriptBridge.js.txt resource --- WebViewJavascriptBridge.xcodeproj/project.pbxproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/WebViewJavascriptBridge.xcodeproj/project.pbxproj index 81405e0c..238cd6f2 100644 --- a/WebViewJavascriptBridge.xcodeproj/project.pbxproj +++ b/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -8,16 +8,15 @@ /* Begin PBXBuildFile section */ 2C35E9761C5A7F8E0093FB29 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2C35E9751C5A7F8E0093FB29 /* Default-568h@2x.png */; }; - 2C35E9811C5A7FC30093FB29 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 2C35E97B1C5A7FC30093FB29 /* WebViewJavascriptBridge.js.txt */; }; 2C35E9821C5A7FC30093FB29 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C35E97C1C5A7FC30093FB29 /* WebViewJavascriptBridge.m */; }; 2C35E9831C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C35E97E1C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.m */; }; 2C35E9841C5A7FC30093FB29 /* WKWebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C35E9801C5A7FC30093FB29 /* WKWebViewJavascriptBridge.m */; }; + 2C3E7C591C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3E7C581C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.m */; }; 3D0FE4761AE2886500BB4104 /* libWebViewJavascriptBridge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D0FE46A1AE2886400BB4104 /* libWebViewJavascriptBridge.a */; }; 3D99867E1AE2A3B2001DDA2C /* echo.html in Resources */ = {isa = PBXBuildFile; fileRef = 3D99867D1AE2A3B2001DDA2C /* echo.html */; }; 3D9E5F2F1AE288E5009D1C36 /* BridgeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D9E5F2E1AE288E5009D1C36 /* BridgeTests.m */; }; 3DCCF7DB1AE28C2900CE7C51 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DCCF7DA1AE28C2900CE7C51 /* main.m */; }; 3DCCF7DE1AE28C2900CE7C51 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DCCF7DD1AE28C2900CE7C51 /* AppDelegate.m */; }; - 3DCCF8001AE28FF600CE7C51 /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 3D9E5F301AE28A5E009D1C36 /* WebViewJavascriptBridge.js.txt */; }; 3DCCF8021AE2911100CE7C51 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DCCF8011AE2911100CE7C51 /* UIKit.framework */; }; /* End PBXBuildFile section */ @@ -53,12 +52,13 @@ /* Begin PBXFileReference section */ 2C35E9751C5A7F8E0093FB29 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 2C35E97A1C5A7FC30093FB29 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = ""; }; - 2C35E97B1C5A7FC30093FB29 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = ""; }; 2C35E97C1C5A7FC30093FB29 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = ""; }; 2C35E97D1C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridgeBase.h; sourceTree = ""; }; 2C35E97E1C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeBase.m; sourceTree = ""; }; 2C35E97F1C5A7FC30093FB29 /* WKWebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewJavascriptBridge.h; sourceTree = ""; }; 2C35E9801C5A7FC30093FB29 /* WKWebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WKWebViewJavascriptBridge.m; sourceTree = ""; }; + 2C3E7C571C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge_JS.h; sourceTree = ""; }; + 2C3E7C581C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge_JS.m; sourceTree = ""; }; 3D0FE46A1AE2886400BB4104 /* libWebViewJavascriptBridge.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWebViewJavascriptBridge.a; sourceTree = BUILT_PRODUCTS_DIR; }; 3D0FE4751AE2886500BB4104 /* WebViewJavascriptBridgeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WebViewJavascriptBridgeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3D0FE47B1AE2886500BB4104 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -103,8 +103,9 @@ 2C35E9791C5A7FC30093FB29 /* WebViewJavascriptBridge */ = { isa = PBXGroup; children = ( + 2C3E7C571C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.h */, + 2C3E7C581C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.m */, 2C35E97A1C5A7FC30093FB29 /* WebViewJavascriptBridge.h */, - 2C35E97B1C5A7FC30093FB29 /* WebViewJavascriptBridge.js.txt */, 2C35E97C1C5A7FC30093FB29 /* WebViewJavascriptBridge.m */, 2C35E97D1C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.h */, 2C35E97E1C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.m */, @@ -284,7 +285,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2C35E9811C5A7FC30093FB29 /* WebViewJavascriptBridge.js.txt in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -292,7 +292,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 3DCCF8001AE28FF600CE7C51 /* WebViewJavascriptBridge.js.txt in Resources */, 3D99867E1AE2A3B2001DDA2C /* echo.html in Resources */, 2C35E9761C5A7F8E0093FB29 /* Default-568h@2x.png in Resources */, ); @@ -316,6 +315,7 @@ 2C35E9841C5A7FC30093FB29 /* WKWebViewJavascriptBridge.m in Sources */, 2C35E9831C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.m in Sources */, 2C35E9821C5A7FC30093FB29 /* WebViewJavascriptBridge.m in Sources */, + 2C3E7C591C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From eb35cc607a5f22ec703edcbb6f3f71d28dc6293b Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 28 Jan 2016 13:31:35 -0500 Subject: [PATCH 031/158] Move automated tests into Tests/ folder --- .travis.yml | 2 +- .../Default-568h@2x.png | Bin .../project.pbxproj | 146 ++++-------------- .../WebViewJavascriptBridge.xcscheme | 0 .../AppDelegate.h | 0 .../AppDelegate.m | 0 .../Info.plist | 0 .../WebViewJavascriptBridgeTestHost}/main.m | 0 .../BridgeTests.m | 0 .../WebViewJavascriptBridgeTests}/Info.plist | 0 .../WebViewJavascriptBridgeTests}/echo.html | 0 11 files changed, 29 insertions(+), 119 deletions(-) rename Default-568h@2x.png => Tests/Default-568h@2x.png (100%) rename {WebViewJavascriptBridge.xcodeproj => Tests/WebViewJavascriptBridge.xcodeproj}/project.pbxproj (77%) rename {WebViewJavascriptBridge.xcodeproj => Tests/WebViewJavascriptBridge.xcodeproj}/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme (100%) rename {WebViewJavascriptBridgeTestHost => Tests/WebViewJavascriptBridgeTestHost}/AppDelegate.h (100%) rename {WebViewJavascriptBridgeTestHost => Tests/WebViewJavascriptBridgeTestHost}/AppDelegate.m (100%) rename {WebViewJavascriptBridgeTestHost => Tests/WebViewJavascriptBridgeTestHost}/Info.plist (100%) rename {WebViewJavascriptBridgeTestHost => Tests/WebViewJavascriptBridgeTestHost}/main.m (100%) rename {WebViewJavascriptBridgeTests => Tests/WebViewJavascriptBridgeTests}/BridgeTests.m (100%) rename {WebViewJavascriptBridgeTests => Tests/WebViewJavascriptBridgeTests}/Info.plist (100%) rename {WebViewJavascriptBridgeTests => Tests/WebViewJavascriptBridgeTests}/echo.html (100%) diff --git a/.travis.yml b/.travis.yml index b620ea76..5146a10b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,4 @@ before_script: - brew update - brew upgrade xctool || true script: - - xctool -project WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge -configuration Release -sdk iphonesimulator test + - xctool -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge -configuration Release -sdk iphonesimulator test \ No newline at end of file diff --git a/Default-568h@2x.png b/Tests/Default-568h@2x.png similarity index 100% rename from Default-568h@2x.png rename to Tests/Default-568h@2x.png diff --git a/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj similarity index 77% rename from WebViewJavascriptBridge.xcodeproj/project.pbxproj rename to Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj index 238cd6f2..9cefaa2f 100644 --- a/WebViewJavascriptBridge.xcodeproj/project.pbxproj +++ b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -8,11 +8,10 @@ /* Begin PBXBuildFile section */ 2C35E9761C5A7F8E0093FB29 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2C35E9751C5A7F8E0093FB29 /* Default-568h@2x.png */; }; - 2C35E9821C5A7FC30093FB29 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C35E97C1C5A7FC30093FB29 /* WebViewJavascriptBridge.m */; }; - 2C35E9831C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C35E97E1C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.m */; }; - 2C35E9841C5A7FC30093FB29 /* WKWebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C35E9801C5A7FC30093FB29 /* WKWebViewJavascriptBridge.m */; }; - 2C3E7C591C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3E7C581C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.m */; }; - 3D0FE4761AE2886500BB4104 /* libWebViewJavascriptBridge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D0FE46A1AE2886400BB4104 /* libWebViewJavascriptBridge.a */; }; + 2C3E7C631C5A928700A1E322 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3E7C5C1C5A928700A1E322 /* WebViewJavascriptBridge.m */; }; + 2C3E7C641C5A928700A1E322 /* WebViewJavascriptBridge_JS.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3E7C5E1C5A928700A1E322 /* WebViewJavascriptBridge_JS.m */; }; + 2C3E7C651C5A928700A1E322 /* WebViewJavascriptBridgeBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3E7C601C5A928700A1E322 /* WebViewJavascriptBridgeBase.m */; }; + 2C3E7C661C5A928700A1E322 /* WKWebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3E7C621C5A928700A1E322 /* WKWebViewJavascriptBridge.m */; }; 3D99867E1AE2A3B2001DDA2C /* echo.html in Resources */ = {isa = PBXBuildFile; fileRef = 3D99867D1AE2A3B2001DDA2C /* echo.html */; }; 3D9E5F2F1AE288E5009D1C36 /* BridgeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D9E5F2E1AE288E5009D1C36 /* BridgeTests.m */; }; 3DCCF7DB1AE28C2900CE7C51 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DCCF7DA1AE28C2900CE7C51 /* main.m */; }; @@ -21,13 +20,6 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 3D0FE4771AE2886500BB4104 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 3D0FE4621AE2886400BB4104 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 3D0FE4691AE2886400BB4104; - remoteInfo = WebViewJavascriptBridge; - }; 3DCCF7FC1AE28C3B00CE7C51 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 3D0FE4621AE2886400BB4104 /* Project object */; @@ -37,29 +29,16 @@ }; /* End PBXContainerItemProxy section */ -/* Begin PBXCopyFilesBuildPhase section */ - 3D0FE4681AE2886400BB4104 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ 2C35E9751C5A7F8E0093FB29 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; - 2C35E97A1C5A7FC30093FB29 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = ""; }; - 2C35E97C1C5A7FC30093FB29 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = ""; }; - 2C35E97D1C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridgeBase.h; sourceTree = ""; }; - 2C35E97E1C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeBase.m; sourceTree = ""; }; - 2C35E97F1C5A7FC30093FB29 /* WKWebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewJavascriptBridge.h; sourceTree = ""; }; - 2C35E9801C5A7FC30093FB29 /* WKWebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WKWebViewJavascriptBridge.m; sourceTree = ""; }; - 2C3E7C571C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge_JS.h; sourceTree = ""; }; - 2C3E7C581C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge_JS.m; sourceTree = ""; }; - 3D0FE46A1AE2886400BB4104 /* libWebViewJavascriptBridge.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWebViewJavascriptBridge.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 2C3E7C5B1C5A928700A1E322 /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = ""; }; + 2C3E7C5C1C5A928700A1E322 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = ""; }; + 2C3E7C5D1C5A928700A1E322 /* WebViewJavascriptBridge_JS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge_JS.h; sourceTree = ""; }; + 2C3E7C5E1C5A928700A1E322 /* WebViewJavascriptBridge_JS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge_JS.m; sourceTree = ""; }; + 2C3E7C5F1C5A928700A1E322 /* WebViewJavascriptBridgeBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridgeBase.h; sourceTree = ""; }; + 2C3E7C601C5A928700A1E322 /* WebViewJavascriptBridgeBase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeBase.m; sourceTree = ""; }; + 2C3E7C611C5A928700A1E322 /* WKWebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewJavascriptBridge.h; sourceTree = ""; }; + 2C3E7C621C5A928700A1E322 /* WKWebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WKWebViewJavascriptBridge.m; sourceTree = ""; }; 3D0FE4751AE2886500BB4104 /* WebViewJavascriptBridgeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WebViewJavascriptBridgeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3D0FE47B1AE2886500BB4104 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 3D99867D1AE2A3B2001DDA2C /* echo.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = echo.html; path = WebViewJavascriptBridgeTests/echo.html; sourceTree = SOURCE_ROOT; }; @@ -74,18 +53,10 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 3D0FE4671AE2886400BB4104 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; 3D0FE4721AE2886500BB4104 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 3D0FE4761AE2886500BB4104 /* libWebViewJavascriptBridge.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -100,26 +71,27 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 2C35E9791C5A7FC30093FB29 /* WebViewJavascriptBridge */ = { + 2C3E7C5A1C5A928700A1E322 /* WebViewJavascriptBridge */ = { isa = PBXGroup; children = ( - 2C3E7C571C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.h */, - 2C3E7C581C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.m */, - 2C35E97A1C5A7FC30093FB29 /* WebViewJavascriptBridge.h */, - 2C35E97C1C5A7FC30093FB29 /* WebViewJavascriptBridge.m */, - 2C35E97D1C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.h */, - 2C35E97E1C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.m */, - 2C35E97F1C5A7FC30093FB29 /* WKWebViewJavascriptBridge.h */, - 2C35E9801C5A7FC30093FB29 /* WKWebViewJavascriptBridge.m */, + 2C3E7C5B1C5A928700A1E322 /* WebViewJavascriptBridge.h */, + 2C3E7C5C1C5A928700A1E322 /* WebViewJavascriptBridge.m */, + 2C3E7C5D1C5A928700A1E322 /* WebViewJavascriptBridge_JS.h */, + 2C3E7C5E1C5A928700A1E322 /* WebViewJavascriptBridge_JS.m */, + 2C3E7C5F1C5A928700A1E322 /* WebViewJavascriptBridgeBase.h */, + 2C3E7C601C5A928700A1E322 /* WebViewJavascriptBridgeBase.m */, + 2C3E7C611C5A928700A1E322 /* WKWebViewJavascriptBridge.h */, + 2C3E7C621C5A928700A1E322 /* WKWebViewJavascriptBridge.m */, ); - path = WebViewJavascriptBridge; + name = WebViewJavascriptBridge; + path = ../WebViewJavascriptBridge; sourceTree = ""; }; 3D0FE4611AE2886400BB4104 = { isa = PBXGroup; children = ( 2C35E9751C5A7F8E0093FB29 /* Default-568h@2x.png */, - 2C35E9791C5A7FC30093FB29 /* WebViewJavascriptBridge */, + 2C3E7C5A1C5A928700A1E322 /* WebViewJavascriptBridge */, 3D0FE4791AE2886500BB4104 /* WebViewJavascriptBridgeTests */, 3DCCF7D71AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost */, 3D0FE46B1AE2886400BB4104 /* Products */, @@ -129,7 +101,6 @@ 3D0FE46B1AE2886400BB4104 /* Products */ = { isa = PBXGroup; children = ( - 3D0FE46A1AE2886400BB4104 /* libWebViewJavascriptBridge.a */, 3D0FE4751AE2886500BB4104 /* WebViewJavascriptBridgeTests.xctest */, 3DCCF7D61AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost.app */, ); @@ -186,23 +157,6 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 3D0FE4691AE2886400BB4104 /* WebViewJavascriptBridge */ = { - isa = PBXNativeTarget; - buildConfigurationList = 3D0FE47E1AE2886500BB4104 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridge" */; - buildPhases = ( - 3D0FE4661AE2886400BB4104 /* Sources */, - 3D0FE4671AE2886400BB4104 /* Frameworks */, - 3D0FE4681AE2886400BB4104 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = WebViewJavascriptBridge; - productName = WebViewJavascriptBridge; - productReference = 3D0FE46A1AE2886400BB4104 /* libWebViewJavascriptBridge.a */; - productType = "com.apple.product-type.library.static"; - }; 3D0FE4741AE2886500BB4104 /* WebViewJavascriptBridgeTests */ = { isa = PBXNativeTarget; buildConfigurationList = 3D0FE4811AE2886500BB4104 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridgeTests" */; @@ -214,7 +168,6 @@ buildRules = ( ); dependencies = ( - 3D0FE4781AE2886500BB4104 /* PBXTargetDependency */, 3DCCF7FD1AE28C3B00CE7C51 /* PBXTargetDependency */, ); name = WebViewJavascriptBridgeTests; @@ -248,9 +201,6 @@ LastUpgradeCheck = 0720; ORGANIZATIONNAME = marcuswestin; TargetAttributes = { - 3D0FE4691AE2886400BB4104 = { - CreatedOnToolsVersion = 6.3; - }; 3D0FE4741AE2886500BB4104 = { CreatedOnToolsVersion = 6.3; TestTargetID = 3DCCF7D51AE28C2900CE7C51; @@ -273,7 +223,6 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 3D0FE4691AE2886400BB4104 /* WebViewJavascriptBridge */, 3D0FE4741AE2886500BB4104 /* WebViewJavascriptBridgeTests */, 3DCCF7D51AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost */, ); @@ -300,22 +249,15 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - 3D0FE4661AE2886400BB4104 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; 3D0FE4711AE2886500BB4104 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 2C3E7C651C5A928700A1E322 /* WebViewJavascriptBridgeBase.m in Sources */, + 2C3E7C661C5A928700A1E322 /* WKWebViewJavascriptBridge.m in Sources */, 3D9E5F2F1AE288E5009D1C36 /* BridgeTests.m in Sources */, - 2C35E9841C5A7FC30093FB29 /* WKWebViewJavascriptBridge.m in Sources */, - 2C35E9831C5A7FC30093FB29 /* WebViewJavascriptBridgeBase.m in Sources */, - 2C35E9821C5A7FC30093FB29 /* WebViewJavascriptBridge.m in Sources */, - 2C3E7C591C5A8ECA00A1E322 /* WebViewJavascriptBridge_JS.m in Sources */, + 2C3E7C631C5A928700A1E322 /* WebViewJavascriptBridge.m in Sources */, + 2C3E7C641C5A928700A1E322 /* WebViewJavascriptBridge_JS.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -331,11 +273,6 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 3D0FE4781AE2886500BB4104 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 3D0FE4691AE2886400BB4104 /* WebViewJavascriptBridge */; - targetProxy = 3D0FE4771AE2886500BB4104 /* PBXContainerItemProxy */; - }; 3DCCF7FD1AE28C3B00CE7C51 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 3DCCF7D51AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost */; @@ -423,24 +360,6 @@ }; name = Release; }; - 3D0FE47F1AE2886500BB4104 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 3D0FE4801AE2886500BB4104 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Release; - }; 3D0FE4821AE2886500BB4104 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -515,15 +434,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 3D0FE47E1AE2886500BB4104 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridge" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 3D0FE47F1AE2886500BB4104 /* Debug */, - 3D0FE4801AE2886500BB4104 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; 3D0FE4811AE2886500BB4104 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridgeTests" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme b/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme similarity index 100% rename from WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme rename to Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme diff --git a/WebViewJavascriptBridgeTestHost/AppDelegate.h b/Tests/WebViewJavascriptBridgeTestHost/AppDelegate.h similarity index 100% rename from WebViewJavascriptBridgeTestHost/AppDelegate.h rename to Tests/WebViewJavascriptBridgeTestHost/AppDelegate.h diff --git a/WebViewJavascriptBridgeTestHost/AppDelegate.m b/Tests/WebViewJavascriptBridgeTestHost/AppDelegate.m similarity index 100% rename from WebViewJavascriptBridgeTestHost/AppDelegate.m rename to Tests/WebViewJavascriptBridgeTestHost/AppDelegate.m diff --git a/WebViewJavascriptBridgeTestHost/Info.plist b/Tests/WebViewJavascriptBridgeTestHost/Info.plist similarity index 100% rename from WebViewJavascriptBridgeTestHost/Info.plist rename to Tests/WebViewJavascriptBridgeTestHost/Info.plist diff --git a/WebViewJavascriptBridgeTestHost/main.m b/Tests/WebViewJavascriptBridgeTestHost/main.m similarity index 100% rename from WebViewJavascriptBridgeTestHost/main.m rename to Tests/WebViewJavascriptBridgeTestHost/main.m diff --git a/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m similarity index 100% rename from WebViewJavascriptBridgeTests/BridgeTests.m rename to Tests/WebViewJavascriptBridgeTests/BridgeTests.m diff --git a/WebViewJavascriptBridgeTests/Info.plist b/Tests/WebViewJavascriptBridgeTests/Info.plist similarity index 100% rename from WebViewJavascriptBridgeTests/Info.plist rename to Tests/WebViewJavascriptBridgeTests/Info.plist diff --git a/WebViewJavascriptBridgeTests/echo.html b/Tests/WebViewJavascriptBridgeTests/echo.html similarity index 100% rename from WebViewJavascriptBridgeTests/echo.html rename to Tests/WebViewJavascriptBridgeTests/echo.html From c6eac77f8c6c2cd3962dde00d170f1563d22ac62 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 28 Jan 2016 13:36:43 -0500 Subject: [PATCH 032/158] Create a Makefile with common commands, and remove scripts/* --- Makefile | 7 +++++++ scripts/publish.sh | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 Makefile delete mode 100755 scripts/publish.sh diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..b80cd3af --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +test: + brew install xctool || true + xctool -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge -configuration Release -sdk iphonesimulator test + +publish-pod: + # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' + pod trunk push --allow-warnings --verbose WebViewJavascriptBridge.podspec diff --git a/scripts/publish.sh b/scripts/publish.sh deleted file mode 100755 index 3e301236..00000000 --- a/scripts/publish.sh +++ /dev/null @@ -1,7 +0,0 @@ -set -e -cd $(cd `dirname ${BASH_SOURCE[0]}` && pwd -P) -cd .. - -# pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' -pod trunk push --allow-warnings --verbose WebViewJavascriptBridge.podspec -echo "WVJB publish.sh TODO: Remove --allow-warnings" \ No newline at end of file From 77ebd37214ec120ea3f0c3a9892f8111464283d6 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 28 Jan 2016 13:37:15 -0500 Subject: [PATCH 033/158] Fix podfile with new WebViewJavascriptBridge/WebViewJavascriptBridge_JS.* --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 196223fa..27ef284f 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.osx.platform = :osx s.ios.source_files = 'WebViewJavascriptBridge/*.{h,m}' s.osx.source_files = 'WebViewJavascriptBridge/*.{h,m}' - s.resource = 'WebViewJavascriptBridge/WebViewJavascriptBridge.js.txt' + s.private_header_files = 'WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h' s.ios.framework = 'UIKit' s.osx.framework = 'WebKit' end From 475bc7ecfdd31b6ea5b24183d72c4824cf1a007a Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 28 Jan 2016 13:37:22 -0500 Subject: [PATCH 034/158] Changelog --- Changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog b/Changelog index 9d82f5b9..5442b290 100644 --- a/Changelog +++ b/Changelog @@ -16,6 +16,9 @@ Version History Intended v5.0.0 + Removed `WebViewJavascriptBridge -reset`. It should never have been exposed as a public API. + Fixed compilation in C99 mode ++ Inline JS source code. WVJB no longer requires `WebViewJavascriptBridge.js.txt` to be included as a resource. ++ Automated testing: see `make test` ++ Added Makefile with common commands Next version + Pretty-print json in log messages From 2dbc87f05b18f1f128f38f9255e5561fb6fdae69 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 28 Jan 2016 13:46:25 -0500 Subject: [PATCH 035/158] Update roadmap --- Roadmap.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Roadmap.md b/Roadmap.md index 86669730..84ecd768 100644 --- a/Roadmap.md +++ b/Roadmap.md @@ -14,11 +14,11 @@ v4.1.7 Pull requests: - [ ] Dev env / docs - - [ ] Automated tests (PR #128, I #151) + - [X] Automated tests (PR #128, I #151) - [ ] Travis? https://github.com/integrations/feature/code - - [ ] Embed js in objc source (PR #129) - - [ ] Also fixes PR #138, I #160, I #108 - - [ ] Docs for podfile installation (PR #140) + - [X] Embed js in objc source (PR #129) + - [X] Also fixes PR #138, I #160, I #108 + - [X] Docs for podfile installation (PR #140) - [ ] Features & fixes to consider - [ ] Message response timeout (PR #106) - [ ] Optional alert-unsafe message speedup (PR #133, I #132) From bfa50767abf4681a65d267f2fb5caaafae92e790 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 28 Jan 2016 19:58:21 -0500 Subject: [PATCH 036/158] Significantly simplify page load detection logic! Do away with numRequestsLoading and replace it with additional logic in the "embed snippet" on the webpage side. The way things work now, the webpage includes a snippet code which: 1) checks if WVJB has already been loaded, in case we proceed immediately 2) or else stores the callback in `window.WVJBCallbacks`. 3) waits for the wvjb js code to be injected/loaded, at which point all load callbacks are called --- Example Apps/ExampleApp.html | 25 ++++++++------- README.md | 25 ++++++++------- .../project.pbxproj | 2 -- Tests/WebViewJavascriptBridgeTests/echo.html | 32 +++++++++---------- .../WKWebViewJavascriptBridge.m | 16 ++-------- .../WebViewJavascriptBridge.m | 30 ++++------------- .../WebViewJavascriptBridgeBase.h | 8 ++--- .../WebViewJavascriptBridgeBase.m | 19 +++++------ .../WebViewJavascriptBridge_JS.m | 26 +++++++-------- 9 files changed, 78 insertions(+), 105 deletions(-) diff --git a/Example Apps/ExampleApp.html b/Example Apps/ExampleApp.html index 4278a8ad..7d532222 100644 --- a/Example Apps/ExampleApp.html +++ b/Example Apps/ExampleApp.html @@ -13,18 +13,19 @@

WebViewJavascriptBridge Demo

window.onerror = function(err) { log('window.onerror: ' + err) } - - function connectWebViewJavascriptBridge(callback) { - if (window.WebViewJavascriptBridge) { - callback(WebViewJavascriptBridge) - } else { - document.addEventListener('WebViewJavascriptBridgeReady', function() { - callback(WebViewJavascriptBridge) - }, false) - } - } - - connectWebViewJavascriptBridge(function(bridge) { + + function setupWebViewJavascriptBridge(callback) { + if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); } + if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); } + window.WVJBCallbacks = [callback]; + var WVJBIframe = document.createElement('iframe'); + WVJBIframe.style.display = 'none'; + WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__'; + document.documentElement.appendChild(WVJBIframe); + setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) + } + + setupWebViewJavascriptBridge(function(bridge) { var uniqueId = 1 function log(message, data) { var log = document.getElementById('log') diff --git a/README.md b/README.md index d957bcbe..216a7937 100644 --- a/README.md +++ b/README.md @@ -83,26 +83,27 @@ self.bridge = [WebViewJavascriptBridge bridgeForWebView:webView handler:^(id dat 4) Finally, set up the javascript side: ```javascript -function connectWebViewJavascriptBridge(callback) { - if (window.WebViewJavascriptBridge) { - callback(WebViewJavascriptBridge) - } else { - document.addEventListener('WebViewJavascriptBridgeReady', function() { - callback(WebViewJavascriptBridge) - }, false) - } +function setupWebViewJavascriptBridge(callback) { + if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); } + if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); } + window.WVJBCallbacks = [callback]; + var WVJBIframe = document.createElement('iframe'); + WVJBIframe.style.display = 'none'; + WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__'; + document.documentElement.appendChild(WVJBIframe); + setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) } -connectWebViewJavascriptBridge(function(bridge) { - - /* Init your app here */ - +setupWebViewJavascriptBridge(function(bridge) { bridge.init(function(message, responseCallback) { alert('Received message: ' + message) if (responseCallback) { responseCallback("Right back atcha") } }) + + /* Initialize your app here */ + bridge.send('Hello from the javascript') bridge.send('Please respond to this', function responseCallback(responseData) { console.log("Javascript got its response", responseData) diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj index 9cefaa2f..99a2562f 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj +++ b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -43,7 +43,6 @@ 3D0FE47B1AE2886500BB4104 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 3D99867D1AE2A3B2001DDA2C /* echo.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = echo.html; path = WebViewJavascriptBridgeTests/echo.html; sourceTree = SOURCE_ROOT; }; 3D9E5F2E1AE288E5009D1C36 /* BridgeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BridgeTests.m; sourceTree = ""; }; - 3D9E5F301AE28A5E009D1C36 /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebViewJavascriptBridge.js.txt; path = ../WebViewJavascriptBridge/WebViewJavascriptBridge.js.txt; sourceTree = ""; }; 3DCCF7D61AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WebViewJavascriptBridgeTestHost.app; sourceTree = BUILT_PRODUCTS_DIR; }; 3DCCF7D91AE28C2900CE7C51 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 3DCCF7DA1AE28C2900CE7C51 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -141,7 +140,6 @@ 3D99867D1AE2A3B2001DDA2C /* echo.html */, 3DCCF7D91AE28C2900CE7C51 /* Info.plist */, 3DCCF7DA1AE28C2900CE7C51 /* main.m */, - 3D9E5F301AE28A5E009D1C36 /* WebViewJavascriptBridge.js.txt */, ); name = "Supporting Files"; sourceTree = ""; diff --git a/Tests/WebViewJavascriptBridgeTests/echo.html b/Tests/WebViewJavascriptBridgeTests/echo.html index 4e44f2d1..3ba34c82 100644 --- a/Tests/WebViewJavascriptBridgeTests/echo.html +++ b/Tests/WebViewJavascriptBridgeTests/echo.html @@ -3,25 +3,25 @@

WebViewJavascriptBridgeTests - echo.html

From d1f3522283eb31ab1bb5b0af535523a93bb6254b Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 2 Feb 2016 10:59:04 -0500 Subject: [PATCH 060/158] Update roadmap with misc todos --- Roadmap.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Roadmap.md b/Roadmap.md index 5eaa9c2b..df297357 100644 --- a/Roadmap.md +++ b/Roadmap.md @@ -4,7 +4,9 @@ Roadmap Issues ------ -- [ ] Add WKWebView support to podspec file? (#149) +- [ ] `make test` fails becuase the command line invocation can't find WebKit framework. Fix. +- [ ] Sometimes tests randomly fail! Race condition... +- [X] Add WKWebView support to podspec file? (#149) - [ ] iOS8 WKWebView support? (#126) - [ ] WKWebView issue in OSX? (#84) - [ ] Release new version (#143, #155, #167) From 14059650e85ed457ccb8464af42df7e104399ad4 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 2 Feb 2016 10:59:16 -0500 Subject: [PATCH 061/158] Decrease max timeout to a reasonable amount --- Tests/WebViewJavascriptBridgeTests/BridgeTests.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m index 6c5beb1b..3c59accd 100644 --- a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m @@ -48,7 +48,7 @@ static void loadEchoSample(id webView) { - (void)testInitialization { [self classSpecificTestInitialization:[WebViewJavascriptBridge class] webView:_uiWebView]; [self classSpecificTestInitialization:[WKWebViewJavascriptBridge class] webView:_wkWebView]; - [self waitForExpectationsWithTimeout:10 handler:NULL]; + [self waitForExpectationsWithTimeout:3 handler:NULL]; } - (void)classSpecificTestInitialization:(Class)cls webView:(id)webView { XCTestExpectation *startup = [self expectationWithDescription:@"Startup completed"]; @@ -65,7 +65,7 @@ - (void)classSpecificTestInitialization:(Class)cls webView:(id)webView { - (void)testEchoHandler { [self classSpecificTestEchoHandler:[WebViewJavascriptBridge class] webView:_uiWebView]; [self classSpecificTestEchoHandler:[WKWebViewJavascriptBridge class] webView:_wkWebView]; - [self waitForExpectationsWithTimeout:10 handler:NULL]; + [self waitForExpectationsWithTimeout:3 handler:NULL]; } - (void)classSpecificTestEchoHandler:(Class)cls webView:(id)webView { WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; @@ -82,7 +82,7 @@ - (void)classSpecificTestEchoHandler:(Class)cls webView:(id)webView { - (void)testEchoHandlerAfterSetup { [self classSpecificTestEchoHandlerAfterSetup:[WebViewJavascriptBridge class] webView:_uiWebView]; [self classSpecificTestEchoHandlerAfterSetup:[WKWebViewJavascriptBridge class] webView:_wkWebView]; - [self waitForExpectationsWithTimeout:10 handler:NULL]; + [self waitForExpectationsWithTimeout:3 handler:NULL]; } - (void)classSpecificTestEchoHandlerAfterSetup:(Class)cls webView:(id)webView { WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; @@ -100,7 +100,7 @@ - (void)classSpecificTestEchoHandlerAfterSetup:(Class)cls webView:(id)webView { - (void)testObjectEncoding { [self classSpecificTestObjectEncoding:[WebViewJavascriptBridge class] webView:_uiWebView]; [self classSpecificTestObjectEncoding:[WKWebViewJavascriptBridge class] webView:_wkWebView]; - [self waitForExpectationsWithTimeout:10 handler:NULL]; + [self waitForExpectationsWithTimeout:3 handler:NULL]; } - (void)classSpecificTestObjectEncoding:(Class)cls webView:(id)webView { WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; From 0d726223369e3f98b346e74f5ad6f65ac7fe6ab7 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 2 Feb 2016 11:23:39 -0500 Subject: [PATCH 062/158] Fix command-line invocation of tests, and eliminate xctool dependency --- .travis.yml | 5 +---- Makefile | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5146a10b..0503bac4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,3 @@ language: objective-c -before_script: - - brew update - - brew upgrade xctool || true script: - - xctool -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge -configuration Release -sdk iphonesimulator test \ No newline at end of file + - make test \ No newline at end of file diff --git a/Makefile b/Makefile index 68c079fa..20d9b620 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ test: - brew install xctool || true - xctool -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge -configuration Release -sdk iphonesimulator test + xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge -destination 'platform=iOS Simulator,name=iPhone 4s' publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' From b530416493bfc403bbe1c33e574ff17039c14665 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 2 Feb 2016 11:29:03 -0500 Subject: [PATCH 063/158] Update roadmap --- Roadmap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Roadmap.md b/Roadmap.md index df297357..a2c1aced 100644 --- a/Roadmap.md +++ b/Roadmap.md @@ -4,7 +4,7 @@ Roadmap Issues ------ -- [ ] `make test` fails becuase the command line invocation can't find WebKit framework. Fix. +- [X] `make test` fails becuase the command line invocation can't find WebKit framework. Fix. - [ ] Sometimes tests randomly fail! Race condition... - [X] Add WKWebView support to podspec file? (#149) - [ ] iOS8 WKWebView support? (#126) From dd1fefca8846104e7bbbea65f5ee1f0d73d491db Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 2 Feb 2016 11:30:04 -0500 Subject: [PATCH 064/158] Allow for calling handlers from JS with just a handler name and responseCallback function (#184) --- WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m index e2e080e0..68f673e8 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m @@ -41,6 +41,10 @@ function registerHandler(handlerName, handler) { } function callHandler(handlerName, data, responseCallback) { + if (arguments.length == 2 && typeof data == 'function') { + responseCallback = data + data = null + } _doSend({ handlerName:handlerName, data:data }, responseCallback); } From 540825221eadab18a4870d3c80af067fb8169237 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 2 Feb 2016 11:30:29 -0500 Subject: [PATCH 065/158] v5.0.3 --- Changelog | 4 ++++ WebViewJavascriptBridge.podspec | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 88e25add..0f7b917e 100644 --- a/Changelog +++ b/Changelog @@ -16,6 +16,10 @@ Version History Next version + Pretty-print json in log messages +v5.0.3 ++ Run all tests for both UIWebView and WKWebView webviews/bridges. ++ Allow for calling handlers from JS with just a handler name and responseCallback function (#184). + v5.0.2 + Fix bug that could cause a crash if the webview loads a new page immediately after JS sends a message. diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index fda67c17..5840aac4 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '5.0.2' + s.version = '5.0.3' s.summary = 'An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 23c7a98327024666534d71f6d0fd116d4becdff9 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 2 Feb 2016 11:34:49 -0500 Subject: [PATCH 066/158] Revert broken patch --- WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m | 4 ---- 1 file changed, 4 deletions(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m index 68f673e8..e2e080e0 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m @@ -41,10 +41,6 @@ function registerHandler(handlerName, handler) { } function callHandler(handlerName, data, responseCallback) { - if (arguments.length == 2 && typeof data == 'function') { - responseCallback = data - data = null - } _doSend({ handlerName:handlerName, data:data }, responseCallback); } From c56345329ca3e21124791915f91dc2d69bcd6522 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 2 Feb 2016 11:35:36 -0500 Subject: [PATCH 067/158] v5.0.4 - fix broken 5.0.3 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 5840aac4..4b8bd7f8 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '5.0.3' + s.version = '5.0.4' s.summary = 'An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 6a83f582955f0432f4fe5d48502f844958c056db Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 2 Feb 2016 11:50:38 -0500 Subject: [PATCH 068/158] Allow for calling handlers from JS with just a handler name and responseCallback function. --- WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m index e2e080e0..3a494dd4 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m @@ -41,6 +41,10 @@ function registerHandler(handlerName, handler) { } function callHandler(handlerName, data, responseCallback) { + if (arguments.length == 2 && typeof data == 'function') { + responseCallback = data; + data = null; + } _doSend({ handlerName:handlerName, data:data }, responseCallback); } From a8845c7b2726768676d5653e6798c26292e4c115 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 2 Feb 2016 11:50:43 -0500 Subject: [PATCH 069/158] Changelog --- Changelog | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 0f7b917e..362f9fdd 100644 --- a/Changelog +++ b/Changelog @@ -16,10 +16,13 @@ Version History Next version + Pretty-print json in log messages -v5.0.3 +v5.0.5 + Run all tests for both UIWebView and WKWebView webviews/bridges. + Allow for calling handlers from JS with just a handler name and responseCallback function (#184). +v5.0.3 & v5.0.4 ++ Recalled builds :) + v5.0.2 + Fix bug that could cause a crash if the webview loads a new page immediately after JS sends a message. From 14e4dc840cbf64c78a95807601a80d3104fe2aae Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 2 Feb 2016 11:51:04 -0500 Subject: [PATCH 070/158] v5.0.5 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 4b8bd7f8..acb5c269 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '5.0.4' + s.version = '5.0.5' s.summary = 'An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 997262103db5fa1402d1abba94ddcf9147130e0b Mon Sep 17 00:00:00 2001 From: coderyi Date: Wed, 24 Feb 2016 12:04:18 +0800 Subject: [PATCH 071/158] fix readme error --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ab7af42b..a4c6f881 100644 --- a/README.md +++ b/README.md @@ -204,8 +204,8 @@ bridge.registerHandler("getCurrentPageUrl", function(data, responseCallback) { ``` -##### `bridge.callHander("handlerName", data)` -##### `bridge.callHander("handlerName", data, function responseCallback(responseData) { ... })` +##### `bridge.callHandler("handlerName", data)` +##### `bridge.callHandler("handlerName", data, function responseCallback(responseData) { ... })` Call an ObjC handler called `handlerName`. If a `responseCallback` function is given the ObjC handler can respond. From 0c57ee0d63e08de59c3bdd30dba4a6c192c4e4ae Mon Sep 17 00:00:00 2001 From: ddovod Date: Tue, 29 Mar 2016 12:32:17 +0300 Subject: [PATCH 072/158] Adding info about ARC support in non-ARC projects --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index a4c6f881..e354af53 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,15 @@ WebViewJavascriptBridge supports [WKWebView](http://nshipster.com/wkwebkit/) for WKWebViewJavascriptBridge* bridge = [WKWebViewJavascriptBridge bridgeForWebView:webView]; ``` +Automatic reference counting (ARC) +---------------------------------- +This library relies on ARC, so if you use ARC in you project, all works fine. +But if your project have no ARC support, be sure to do next steps: +1) In your Xcode project open project settings -> 'Build Phases' +2) Expand 'Compile Sources' header and find all *.m files which are belongs to this library. Make attention on the 'Compiler Flags' in front of each source file in this list +3) For each file add '-fobjc-arc' flag +Now all WVJB files will be compiled with ARC support. + Contributors & Forks -------------------- Contributors: https://github.com/marcuswestin/WebViewJavascriptBridge/graphs/contributors From 79f6f4077f944164223cb60a9855576b5d5bc904 Mon Sep 17 00:00:00 2001 From: ddovod Date: Tue, 29 Mar 2016 12:34:50 +0300 Subject: [PATCH 073/158] Fixing markdown layout --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e354af53..84035b0b 100644 --- a/README.md +++ b/README.md @@ -134,9 +134,13 @@ Automatic reference counting (ARC) ---------------------------------- This library relies on ARC, so if you use ARC in you project, all works fine. But if your project have no ARC support, be sure to do next steps: + 1) In your Xcode project open project settings -> 'Build Phases' + 2) Expand 'Compile Sources' header and find all *.m files which are belongs to this library. Make attention on the 'Compiler Flags' in front of each source file in this list + 3) For each file add '-fobjc-arc' flag + Now all WVJB files will be compiled with ARC support. Contributors & Forks From 66626b0b71b300a2a1ffdb45417c66ac83ab13ac Mon Sep 17 00:00:00 2001 From: CJ Lin Date: Wed, 11 May 2016 23:46:39 +0800 Subject: [PATCH 074/158] add WKNavigationDelegate webView:didReceiveAuthenticationChallenge:completionHandler: support --- WebViewJavascriptBridge/WKWebViewJavascriptBridge.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index 88679fb4..c6839d06 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -102,6 +102,15 @@ - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigat } } +- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler +{ + if (webView != _webView) { return; } + + __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; + if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didReceiveAuthenticationChallenge:completionHandler:)]) { + [strongDelegate webView:webView didReceiveAuthenticationChallenge:challenge completionHandler:completionHandler]; + } +} - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction From 42114c8e81d3b0d1076cf925ddc32b0979c1a79e Mon Sep 17 00:00:00 2001 From: yiplee Date: Fri, 20 May 2016 18:32:11 +0800 Subject: [PATCH 075/158] weak pointers --- WebViewJavascriptBridge/WKWebViewJavascriptBridge.m | 2 +- WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index 88679fb4..137185b5 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -11,7 +11,7 @@ #if defined(supportsWKWebKit) @implementation WKWebViewJavascriptBridge { - WKWebView* _webView; + __weak WKWebView* _webView; id _webViewDelegate; long _uniqueId; WebViewJavascriptBridgeBase *_base; diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h index 16b23c79..898958a0 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -22,7 +22,7 @@ typedef NSDictionary WVJBMessage; @interface WebViewJavascriptBridgeBase : NSObject -@property (assign) id delegate; +@property (weak, assign) id delegate; @property (strong, nonatomic) NSMutableArray* startupMessageQueue; @property (strong, nonatomic) NSMutableDictionary* responseCallbacks; @property (strong, nonatomic) NSMutableDictionary* messageHandlers; From 30ea57a7bbac82d5797b91441f3ba2c0fdcffc10 Mon Sep 17 00:00:00 2001 From: yiplee Date: Fri, 20 May 2016 18:36:22 +0800 Subject: [PATCH 076/158] weak pointer --- WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h index 898958a0..a17e9d4b 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -22,7 +22,7 @@ typedef NSDictionary WVJBMessage; @interface WebViewJavascriptBridgeBase : NSObject -@property (weak, assign) id delegate; +@property (weak, nonatomic) id delegate; @property (strong, nonatomic) NSMutableArray* startupMessageQueue; @property (strong, nonatomic) NSMutableDictionary* responseCallbacks; @property (strong, nonatomic) NSMutableDictionary* messageHandlers; From 8c7d3bd800fbb79fee8062ba908f11661690ac04 Mon Sep 17 00:00:00 2001 From: yiplee Date: Tue, 24 May 2016 16:09:36 +0800 Subject: [PATCH 077/158] weak pointers --- WebViewJavascriptBridge/WKWebViewJavascriptBridge.m | 2 +- WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index 137185b5..2f095091 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -12,7 +12,7 @@ @implementation WKWebViewJavascriptBridge { __weak WKWebView* _webView; - id _webViewDelegate; + __weak id _webViewDelegate; long _uniqueId; WebViewJavascriptBridgeBase *_base; } diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index f290a48d..c4ef2038 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -10,7 +10,7 @@ #import "WebViewJavascriptBridge_JS.h" @implementation WebViewJavascriptBridgeBase { - id _webViewDelegate; + __weak id _webViewDelegate; long _uniqueId; } From f887f15b4eb18dd14ac8048dd42da1ae58fcf71d Mon Sep 17 00:00:00 2001 From: EuanChan Date: Tue, 14 Jun 2016 22:52:08 +0800 Subject: [PATCH 078/158] Fix unwanted stopLoading when the web is still fetching page. once there is a web request 1, response 200 and the the page is only for submit form data, we call the submit request 'request 2', before the 'request 2' response, if the wkjsBridge js inject, it result `[webView stopLoading]` task to stop the `request 2` --- WebViewJavascriptBridge/WKWebViewJavascriptBridge.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index a8fb107c..ee298dbe 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -127,7 +127,7 @@ - (void)webView:(WKWebView *)webView } else { [_base logUnkownMessage:url]; } - [webView stopLoading]; + decisionHandler(WKNavigationActionPolicyCancel); } if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)]) { From 9c2bdd0239853337ce5fb60f003b8fdbf2eab594 Mon Sep 17 00:00:00 2001 From: Vontio Date: Wed, 15 Jun 2016 03:17:56 +0800 Subject: [PATCH 079/158] Master (#193) * show js error msg and line number if use try catch, user will not know what cause error * show js error msg and line number * fix indent,alert to console.log * notify which js handler response easier for debug --- .../WebViewJavascriptBridgeBase.h | 3 ++- .../WebViewJavascriptBridgeBase.m | 3 ++- .../WebViewJavascriptBridge_JS.m | 20 +++++++++++-------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h index a17e9d4b..d39cfd66 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -10,6 +10,7 @@ #define kCustomProtocolScheme @"wvjbscheme" #define kQueueHasMessage @"__WVJB_QUEUE_MESSAGE__" #define kBridgeLoaded @"__BRIDGE_LOADED__" +#define kJavascriptResponse @"__JAVASCRIPT_RESPONSE__" typedef void (^WVJBResponseCallback)(id responseData); typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback); @@ -41,4 +42,4 @@ typedef NSDictionary WVJBMessage; - (NSString *)webViewJavascriptCheckCommand; - (NSString *)webViewJavascriptFetchQueyCommand; -@end \ No newline at end of file +@end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index c4ef2038..9b7f4a64 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -76,6 +76,7 @@ - (void)flushMessageQueue:(NSString *)messageQueueString{ NSString* responseId = message[@"responseId"]; if (responseId) { + [[NSNotificationCenter defaultCenter] postNotificationName: kJavascriptResponse object: self userInfo:message]; WVJBResponseCallback responseCallback = _responseCallbacks[responseId]; responseCallback(message[@"responseData"]); [self.responseCallbacks removeObjectForKey:responseId]; @@ -211,4 +212,4 @@ - (void)_log:(NSString *)action json:(id)json { } } -@end \ No newline at end of file +@end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m index 3a494dd4..0a6d8b7d 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m @@ -19,6 +19,12 @@ if (window.WebViewJavascriptBridge) { return; } + + if (!window.onerror) { + window.onerror = function(msg, url, line) { + console.log("WebViewJavascriptBridge: ERROR:" + msg + "@" + url + ":" + line); + } + } window.WebViewJavascriptBridge = { registerHandler: registerHandler, callHandler: callHandler, @@ -81,25 +87,23 @@ function _dispatchMessageFromObjC(messageJSON) { if (message.callbackId) { var callbackResponseId = message.callbackId; responseCallback = function(responseData) { - _doSend({ responseId:callbackResponseId, responseData:responseData }); + _doSend({handlerName:message.handlerName, responseId:callbackResponseId, responseData:responseData }); }; } var handler = messageHandlers[message.handlerName]; - try { - handler(message.data, responseCallback); - } catch(exception) { - console.log("WebViewJavascriptBridge: WARNING: javascript handler threw.", message, exception); - } if (!handler) { console.log("WebViewJavascriptBridge: WARNING: no handler for message from ObjC:", message); + }else + { + handler(message.data, responseCallback); } } }); } function _handleMessageFromObjC(messageJSON) { - _dispatchMessageFromObjC(messageJSON); + _dispatchMessageFromObjC(messageJSON); } messagingIframe = document.createElement('iframe'); @@ -120,4 +124,4 @@ function _callWVJBCallbacks() { #undef __wvjb_js_func__ return preprocessorJSCode; -}; \ No newline at end of file +}; From e7fb2c79aa3546aa9b91dd4607b5cc9f9035fe39 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 14 Jun 2016 15:21:01 -0400 Subject: [PATCH 080/158] Remove kJavascriptResponse notification on default notification center. If we are going to publish notifications, then they should be published for all events and not just for responses. @vontio, feel free to create another PR with notifications for responses, events, etc --- WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h | 1 - WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m | 1 - 2 files changed, 2 deletions(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h index d39cfd66..b7df990e 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -10,7 +10,6 @@ #define kCustomProtocolScheme @"wvjbscheme" #define kQueueHasMessage @"__WVJB_QUEUE_MESSAGE__" #define kBridgeLoaded @"__BRIDGE_LOADED__" -#define kJavascriptResponse @"__JAVASCRIPT_RESPONSE__" typedef void (^WVJBResponseCallback)(id responseData); typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback); diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index 9b7f4a64..0790c0b1 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -76,7 +76,6 @@ - (void)flushMessageQueue:(NSString *)messageQueueString{ NSString* responseId = message[@"responseId"]; if (responseId) { - [[NSNotificationCenter defaultCenter] postNotificationName: kJavascriptResponse object: self userInfo:message]; WVJBResponseCallback responseCallback = _responseCallbacks[responseId]; responseCallback(message[@"responseData"]); [self.responseCallbacks removeObjectForKey:responseId]; From f6b21547f9021d38f1a8ff531f9b1f5205cd1174 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 14 Jun 2016 15:24:24 -0400 Subject: [PATCH 081/158] Whitespace fixes for 9c2bdd023985 --- WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m index 0a6d8b7d..9df21c57 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m @@ -87,15 +87,14 @@ function _dispatchMessageFromObjC(messageJSON) { if (message.callbackId) { var callbackResponseId = message.callbackId; responseCallback = function(responseData) { - _doSend({handlerName:message.handlerName, responseId:callbackResponseId, responseData:responseData }); + _doSend({ handlerName:message.handlerName, responseId:callbackResponseId, responseData:responseData }); }; } var handler = messageHandlers[message.handlerName]; if (!handler) { console.log("WebViewJavascriptBridge: WARNING: no handler for message from ObjC:", message); - }else - { + } else { handler(message.data, responseCallback); } } @@ -103,7 +102,7 @@ function _dispatchMessageFromObjC(messageJSON) { } function _handleMessageFromObjC(messageJSON) { - _dispatchMessageFromObjC(messageJSON); + _dispatchMessageFromObjC(messageJSON); } messagingIframe = document.createElement('iframe'); From 9c18c905d47c702851af54e6a415456fa3932c31 Mon Sep 17 00:00:00 2001 From: Matt Eaton Date: Tue, 14 Jun 2016 14:24:42 -0500 Subject: [PATCH 082/158] Update README.md (#202) Edited README example to make sure that the JavaScript callHandler (in #5) is able to send data to the objective-c registerHandler (in #3). This is for the handler "ObjC Echo." --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 84035b0b..d02caf97 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ setupWebViewJavascriptBridge(function(bridge) { console.log("JS Echo called with:", data) responseCallback(data) }) - bridge.callHandler('ObjC Echo', function responseCallback(responseData) { + bridge.callHandler('ObjC Echo', {'key':'value'}, function responseCallback(responseData) { console.log("JS received response:", responseData) }) }) From f8640a0fffed34ed19ec55d2cf6f943116c290e1 Mon Sep 17 00:00:00 2001 From: eJamesLin Date: Wed, 15 Jun 2016 03:25:45 +0800 Subject: [PATCH 083/158] Fix WKNavigationDelegate methods in ExampleApp-iOS (#206) * setting ExampleUIWebViewController as UIWebViewDelegate in example * fix WKNavigationDelegate method name, set ExampleWKWebViewController as WKNavigationDelegate --- Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m | 1 + Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m b/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m index d94f501a..720877d5 100644 --- a/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m +++ b/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m @@ -24,6 +24,7 @@ - (void)viewWillAppear:(BOOL)animated { [WebViewJavascriptBridge enableLogging]; _bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; + [_bridge setWebViewDelegate:self]; [_bridge registerHandler:@"testObjcCallback" handler:^(id data, WVJBResponseCallback responseCallback) { NSLog(@"testObjcCallback called: %@", data); diff --git a/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m b/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m index 60df23e8..01aaa10f 100644 --- a/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m +++ b/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m @@ -25,6 +25,7 @@ - (void)viewWillAppear:(BOOL)animated { [self.view addSubview:webView]; [WKWebViewJavascriptBridge enableLogging]; _bridge = [WKWebViewJavascriptBridge bridgeForWebView:webView]; + [_bridge setWebViewDelegate:self]; [_bridge registerHandler:@"testObjcCallback" handler:^(id data, WVJBResponseCallback responseCallback) { NSLog(@"testObjcCallback called: %@", data); @@ -37,11 +38,11 @@ - (void)viewWillAppear:(BOOL)animated { [self loadExamplePage:webView]; } -- (void)webViewDidStartLoad:(UIWebView *)webView { +- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation { NSLog(@"webViewDidStartLoad"); } -- (void)webViewDidFinishLoad:(UIWebView *)webView { +- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { NSLog(@"webViewDidFinishLoad"); } From 63d55ef5a0413cf800bb38389db9d59c60bea3ff Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 14 Jun 2016 16:24:43 -0400 Subject: [PATCH 084/158] Thirdiron feature/unsafe for alert speedup (#215) Add `disableJavscriptAlertBoxSafetyTimeout` feature by @jordanpwood. --- .../ExampleUIWebViewController.m | 17 +++++++++++++--- README.md | 19 ++++++++++++++++++ .../BridgeTests.m | 20 +++++++++++++++++++ .../WKWebViewJavascriptBridge.h | 1 + .../WKWebViewJavascriptBridge.m | 4 ++++ .../WebViewJavascriptBridge.h | 2 ++ .../WebViewJavascriptBridge.m | 5 +++++ .../WebViewJavascriptBridgeBase.h | 1 + .../WebViewJavascriptBridgeBase.m | 4 ++++ .../WebViewJavascriptBridge_JS.m | 17 ++++++++++++++-- 10 files changed, 85 insertions(+), 5 deletions(-) diff --git a/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m b/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m index 720877d5..f988a014 100644 --- a/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m +++ b/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m @@ -46,21 +46,32 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView { } - (void)renderButtons:(UIWebView*)webView { - UIFont* font = [UIFont fontWithName:@"HelveticaNeue" size:12.0]; + UIFont* font = [UIFont fontWithName:@"HelveticaNeue" size:11.0]; UIButton *callbackButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [callbackButton setTitle:@"Call handler" forState:UIControlStateNormal]; [callbackButton addTarget:self action:@selector(callHandler:) forControlEvents:UIControlEventTouchUpInside]; [self.view insertSubview:callbackButton aboveSubview:webView]; - callbackButton.frame = CGRectMake(10, 400, 100, 35); + callbackButton.frame = CGRectMake(0, 400, 100, 35); callbackButton.titleLabel.font = font; UIButton* reloadButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [reloadButton setTitle:@"Reload webview" forState:UIControlStateNormal]; [reloadButton addTarget:webView action:@selector(reload) forControlEvents:UIControlEventTouchUpInside]; [self.view insertSubview:reloadButton aboveSubview:webView]; - reloadButton.frame = CGRectMake(110, 400, 100, 35); + reloadButton.frame = CGRectMake(90, 400, 100, 35); reloadButton.titleLabel.font = font; + + UIButton* safetyTimeoutButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + [safetyTimeoutButton setTitle:@"Disable safety timeout" forState:UIControlStateNormal]; + [safetyTimeoutButton addTarget:self action:@selector(disableSafetyTimeout) forControlEvents:UIControlEventTouchUpInside]; + [self.view insertSubview:safetyTimeoutButton aboveSubview:webView]; + safetyTimeoutButton.frame = CGRectMake(190, 400, 120, 35); + safetyTimeoutButton.titleLabel.font = font; +} + +- (void)disableSafetyTimeout { + [self.bridge disableJavscriptAlertBoxSafetyTimeout]; } - (void)callHandler:(id)sender { diff --git a/README.md b/README.md index d02caf97..512360f0 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ WebViewJavascriptBridge is used by a range of companies and projects. This is a - [鼎盛中华](https://itunes.apple.com/us/app/ding-sheng-zhong-hua/id537273940?mt=8) - [FRIL](https://fril.jp) - [留白·WHITE](http://liubaiapp.com) +- [BrowZine](http://thirdiron.com/browzine/) Installation (iOS & OSX) ------------------------ @@ -198,6 +199,13 @@ Example: Optionally, set a `UIWebViewDelegate` if you need to respond to the [web view's lifecycle events](http://developer.apple.com/library/ios/documentation/uikit/reference/UIWebViewDelegate_Protocol/Reference/Reference.html). +##### `[bridge disableJavscriptAlertBoxSafetyTimeout]` + +UNSAFE. Speed up bridge message passing by disabling the setTimeout safety check. It is only safe to disable this safety check if you do not call any of the javascript popup box functions (alert, confirm, and prompt). If you call any of these functions from the bridged javascript code, the app will hang. + +Example: + + [self.bridge disableJavscriptAlertBoxSafetyTimeout]; @@ -230,3 +238,14 @@ bridge.callHandler("getScreenHeight", null, function(response) { alert('Screen height:' + response) }) ``` + + +##### `bridge.disableJavscriptAlertBoxSafetyTimeout()` + +Calling `bridge.disableJavscriptAlertBoxSafetyTimeout()` has the same effect as calling `[bridge disableJavscriptAlertBoxSafetyTimeout];` in ObjC. + +Example: + +```javascript +bridge.disableJavscriptAlertBoxSafetyTimeout() +``` \ No newline at end of file diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m index 3c59accd..1dac85aa 100644 --- a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m @@ -139,6 +139,26 @@ - (void)classSpecificTestJavascriptReceiveResponse:(Class)cls webView:(id)webVie }]; } +- (void)testJavascriptReceiveResponseWithoutSafetyTimeout { + [self classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:[WebViewJavascriptBridge class] webView:_uiWebView]; + [self classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:[WKWebViewJavascriptBridge class] webView:_wkWebView]; + [self waitForExpectationsWithTimeout:3 handler:NULL]; +} +- (void)classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:(Class)cls webView:(id)webView { + WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; + [bridge disableJavscriptAlertBoxSafetyTimeout]; + loadEchoSample(webView); + XCTestExpectation *callbackInvocked = [self expectationWithDescription:@"Callback invoked"]; + [bridge registerHandler:@"objcEchoToJs" handler:^(id data, WVJBResponseCallback responseCallback) { + responseCallback(data); + }]; + [bridge callHandler:@"jsRcvResponseTest" data:nil responseCallback:^(id responseData) { + XCTAssertEqualObjects(responseData, @"Response from JS"); + [callbackInvocked fulfill]; + }]; +} + + - (WebViewJavascriptBridge*)bridgeForCls:(Class)cls webView:(id)webView { if (cls == [WebViewJavascriptBridge class]) { return [WebViewJavascriptBridge bridgeForWebView:webView]; diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h index 99859f00..5136f8d3 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h @@ -26,6 +26,7 @@ - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; - (void)reset; - (void)setWebViewDelegate:(id)webViewDelegate; +- (void)disableJavscriptAlertBoxSafetyTimeout; @end diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index c91a154b..31dd8c55 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -61,6 +61,10 @@ - (void)setWebViewDelegate:(id)webViewDelegate { _webViewDelegate = webViewDelegate; } +- (void)disableJavscriptAlertBoxSafetyTimeout { + [_base disableJavscriptAlertBoxSafetyTimeout]; +} + /* Internals ***********/ diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.h index aff05531..0996944d 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.h @@ -34,4 +34,6 @@ - (void)callHandler:(NSString*)handlerName data:(id)data; - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; - (void)setWebViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate; +- (void)disableJavscriptAlertBoxSafetyTimeout; + @end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index 20e88d4f..68a6964b 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -61,6 +61,11 @@ - (void)registerHandler:(NSString *)handlerName handler:(WVJBHandler)handler { _base.messageHandlers[handlerName] = [handler copy]; } +- (void)disableJavscriptAlertBoxSafetyTimeout { + [_base disableJavscriptAlertBoxSafetyTimeout]; +} + + /* Platform agnostic internals *****************************/ diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h index b7df990e..3cf5a31c 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -40,5 +40,6 @@ typedef NSDictionary WVJBMessage; - (void)logUnkownMessage:(NSURL*)url; - (NSString *)webViewJavascriptCheckCommand; - (NSString *)webViewJavascriptFetchQueyCommand; +- (void)disableJavscriptAlertBoxSafetyTimeout; @end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index 0790c0b1..2711914e 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -153,6 +153,10 @@ -(NSString *)webViewJavascriptFetchQueyCommand { return @"WebViewJavascriptBridge._fetchQueue();"; } +- (void)disableJavscriptAlertBoxSafetyTimeout { + [self sendData:nil responseCallback:nil handlerName:@"_disableJavascriptAlertBoxSafetyTimeout"]; +} + // Private // ------------------------------------------- diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m index 9df21c57..c99b7e6a 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m @@ -28,6 +28,7 @@ window.WebViewJavascriptBridge = { registerHandler: registerHandler, callHandler: callHandler, + disableJavscriptAlertBoxSafetyTimeout: disableJavscriptAlertBoxSafetyTimeout, _fetchQueue: _fetchQueue, _handleMessageFromObjC: _handleMessageFromObjC }; @@ -41,6 +42,7 @@ var responseCallbacks = {}; var uniqueId = 1; + var dispatchMessagesWithTimeoutSafety = true; function registerHandler(handlerName, handler) { messageHandlers[handlerName] = handler; @@ -53,6 +55,9 @@ function callHandler(handlerName, data, responseCallback) { } _doSend({ handlerName:handlerName, data:data }, responseCallback); } + function disableJavscriptAlertBoxSafetyTimeout() { + dispatchMessagesWithTimeoutSafety = false; + } function _doSend(message, responseCallback) { if (responseCallback) { @@ -71,7 +76,13 @@ function _fetchQueue() { } function _dispatchMessageFromObjC(messageJSON) { - setTimeout(function _timeoutDispatchMessageFromObjC() { + if (dispatchMessagesWithTimeoutSafety) { + setTimeout(_doDispatchMessageFromObjC); + } else { + _doDispatchMessageFromObjC(); + } + + function _doDispatchMessageFromObjC() { var message = JSON.parse(messageJSON); var messageHandler; var responseCallback; @@ -98,7 +109,7 @@ function _dispatchMessageFromObjC(messageJSON) { handler(message.data, responseCallback); } } - }); + } } function _handleMessageFromObjC(messageJSON) { @@ -110,6 +121,8 @@ function _handleMessageFromObjC(messageJSON) { messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE; document.documentElement.appendChild(messagingIframe); + registerHandler("_disableJavascriptAlertBoxSafetyTimeout", disableJavscriptAlertBoxSafetyTimeout); + setTimeout(_callWVJBCallbacks, 0); function _callWVJBCallbacks() { var callbacks = window.WVJBCallbacks; From 9c1e39200d9a3fdc4437b7a4897d5c7f1212dd36 Mon Sep 17 00:00:00 2001 From: Max Campolo Date: Tue, 13 Dec 2016 10:27:55 -0500 Subject: [PATCH 085/158] Add default completion handler for authentication challenge to handle case where no _webViewDelegate exists (#218) --- WebViewJavascriptBridge/WKWebViewJavascriptBridge.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index 31dd8c55..e548d6b6 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -113,6 +113,8 @@ - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAut __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didReceiveAuthenticationChallenge:completionHandler:)]) { [strongDelegate webView:webView didReceiveAuthenticationChallenge:challenge completionHandler:completionHandler]; + } else { + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); } } From 18f32481b3859b8c3d18a90428047c80416b8927 Mon Sep 17 00:00:00 2001 From: imrazor Date: Tue, 13 Dec 2016 09:28:21 -0600 Subject: [PATCH 086/158] Update WKWebViewJavascriptBridge.m (#219) Add method:- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler --- .../WKWebViewJavascriptBridge.m | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index e548d6b6..a0e95462 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -106,6 +106,20 @@ - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigat } } + +- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler +{ + if (webView != _webView) { return; } + + __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; + if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationResponse:decisionHandler:)]) { + [strongDelegate webView:webView decidePolicyForNavigationResponse:navigationResponse decisionHandler:decisionHandler]; + } + else { + decisionHandler(WKNavigationResponsePolicyAllow); + } +} + - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler { if (webView != _webView) { return; } From cf5db049cea0d3ea0d3bb3d1bead9b4b3eeaad6d Mon Sep 17 00:00:00 2001 From: Terrillo Walls Date: Tue, 13 Dec 2016 09:28:50 -0600 Subject: [PATCH 087/158] Added 'baseURL' to OSX views (#226) --- Example Apps/ExampleApp-OSX/AppDelegate.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Example Apps/ExampleApp-OSX/AppDelegate.m b/Example Apps/ExampleApp-OSX/AppDelegate.m index 970c64d1..a9f68fb4 100644 --- a/Example Apps/ExampleApp-OSX/AppDelegate.m +++ b/Example Apps/ExampleApp-OSX/AppDelegate.m @@ -56,7 +56,8 @@ - (void)_configureWebview { // Load Page NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"ExampleApp" ofType:@"html"]; NSString* html = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil]; - [[_webView mainFrame] loadHTMLString:html baseURL:nil]; + NSURL *baseURL = [NSURL fileURLWithPath:htmlPath] + [[_webView mainFrame] loadHTMLString:html baseURL: baseURL]; } @@ -89,7 +90,8 @@ - (void)_configureWKWebview { // Load Page NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"ExampleApp" ofType:@"html"]; NSString* html = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil]; - [_WKWebView loadHTMLString:html baseURL:nil]; + NSURL *baseURL = [NSURL fileURLWithPath:htmlPath]; + [_WKWebView loadHTMLString:html baseURL:baseURL]; } -(void)_toggleExample { From a8cc869801f65cc088fef5b55e554d17f98cc7e6 Mon Sep 17 00:00:00 2001 From: SmallRookieJian Date: Tue, 13 Dec 2016 23:29:53 +0800 Subject: [PATCH 088/158] brackets completion (#238) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 512360f0..4954a123 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ Example: }]; ``` -#### `[bridge setWebViewDelegate:UIWebViewDelegate*)webViewDelegate]` +#### `[bridge setWebViewDelegate:(UIWebViewDelegate*)webViewDelegate]` Optionally, set a `UIWebViewDelegate` if you need to respond to the [web view's lifecycle events](http://developer.apple.com/library/ios/documentation/uikit/reference/UIWebViewDelegate_Protocol/Reference/Reference.html). @@ -248,4 +248,4 @@ Example: ```javascript bridge.disableJavscriptAlertBoxSafetyTimeout() -``` \ No newline at end of file +``` From 04f4e4dc3ce6662d927e35cb0940fa41d91dd9bc Mon Sep 17 00:00:00 2001 From: SmallRookieJian Date: Tue, 13 Dec 2016 23:31:15 +0800 Subject: [PATCH 089/158] New branch (#239) * brackets completion * modify some modifying word --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4954a123..db4577bd 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ Example: }]; ``` -#### `[bridge setWebViewDelegate:(UIWebViewDelegate*)webViewDelegate]` +#### `[bridge setWebViewDelegate:(NSObject *)webViewDelegate]` Optionally, set a `UIWebViewDelegate` if you need to respond to the [web view's lifecycle events](http://developer.apple.com/library/ios/documentation/uikit/reference/UIWebViewDelegate_Protocol/Reference/Reference.html). From b2f374112356a56f619f2cdf82a0cd5257593d18 Mon Sep 17 00:00:00 2001 From: Liszt Date: Tue, 13 Dec 2016 23:32:07 +0800 Subject: [PATCH 090/158] Update Roadmap.md (#250) --- Roadmap.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Roadmap.md b/Roadmap.md index a2c1aced..00e0e353 100644 --- a/Roadmap.md +++ b/Roadmap.md @@ -1,5 +1,6 @@ Roadmap ======= +###通过使用该库可以轻松实现JS与原生交互。 Issues ------ @@ -101,4 +102,4 @@ You could also create a PR with an example in `Example Apps` with the problem yo I'll close this in the meantime since there's nothing I can do. Feel free to reopen with a repro or more information. -Cheers! \ No newline at end of file +Cheers! From d8289804db8fb5fe8413d46ca28a062e0ec07e9f Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 13 Dec 2016 11:10:49 -0500 Subject: [PATCH 091/158] Update to test on iPhone 5s --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 20d9b620..524cfb58 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ test: - xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge -destination 'platform=iOS Simulator,name=iPhone 4s' + xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge -destination 'platform=iOS Simulator,name=iPhone 5s' publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' From 2c8b7362d259b82d62b98be35ab7a311d76a108a Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 13 Dec 2016 11:12:34 -0500 Subject: [PATCH 092/158] Add note to remember to create tag --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 524cfb58..3a97b284 100644 --- a/Makefile +++ b/Makefile @@ -3,4 +3,5 @@ test: publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' + # First, create tag: `git tag -a "v5.0.X" -m "Tag v5.0.X" && git push --tags` pod trunk push --verbose WebViewJavascriptBridge.podspec From 1c335450000e4c139dd91bc0a58f072ac8c61f08 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 13 Dec 2016 11:13:45 -0500 Subject: [PATCH 093/158] Add note to remember version bump and tag push; Create variable for test timeout duration. --- Makefile | 2 +- Tests/WebViewJavascriptBridgeTests/BridgeTests.m | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 3a97b284..9d133a0b 100644 --- a/Makefile +++ b/Makefile @@ -3,5 +3,5 @@ test: publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' - # First, create tag: `git tag -a "v5.0.X" -m "Tag v5.0.X" && git push --tags` + # First, bump podspec version, then commit & create tag: `git tag -a "v5.0.X" -m "Tag v5.0.X" && git push --tags` pod trunk push --verbose WebViewJavascriptBridge.podspec diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m index 1dac85aa..7224e72b 100644 --- a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m @@ -45,10 +45,12 @@ static void loadEchoSample(id webView) { [(UIWebView*)webView loadRequest:request]; } +const NSTimeInterval timeoutSec = 100; + - (void)testInitialization { [self classSpecificTestInitialization:[WebViewJavascriptBridge class] webView:_uiWebView]; [self classSpecificTestInitialization:[WKWebViewJavascriptBridge class] webView:_wkWebView]; - [self waitForExpectationsWithTimeout:3 handler:NULL]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; } - (void)classSpecificTestInitialization:(Class)cls webView:(id)webView { XCTestExpectation *startup = [self expectationWithDescription:@"Startup completed"]; @@ -65,7 +67,7 @@ - (void)classSpecificTestInitialization:(Class)cls webView:(id)webView { - (void)testEchoHandler { [self classSpecificTestEchoHandler:[WebViewJavascriptBridge class] webView:_uiWebView]; [self classSpecificTestEchoHandler:[WKWebViewJavascriptBridge class] webView:_wkWebView]; - [self waitForExpectationsWithTimeout:3 handler:NULL]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; } - (void)classSpecificTestEchoHandler:(Class)cls webView:(id)webView { WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; @@ -82,7 +84,7 @@ - (void)classSpecificTestEchoHandler:(Class)cls webView:(id)webView { - (void)testEchoHandlerAfterSetup { [self classSpecificTestEchoHandlerAfterSetup:[WebViewJavascriptBridge class] webView:_uiWebView]; [self classSpecificTestEchoHandlerAfterSetup:[WKWebViewJavascriptBridge class] webView:_wkWebView]; - [self waitForExpectationsWithTimeout:3 handler:NULL]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; } - (void)classSpecificTestEchoHandlerAfterSetup:(Class)cls webView:(id)webView { WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; @@ -100,7 +102,7 @@ - (void)classSpecificTestEchoHandlerAfterSetup:(Class)cls webView:(id)webView { - (void)testObjectEncoding { [self classSpecificTestObjectEncoding:[WebViewJavascriptBridge class] webView:_uiWebView]; [self classSpecificTestObjectEncoding:[WKWebViewJavascriptBridge class] webView:_wkWebView]; - [self waitForExpectationsWithTimeout:3 handler:NULL]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; } - (void)classSpecificTestObjectEncoding:(Class)cls webView:(id)webView { WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; @@ -124,7 +126,7 @@ - (void)classSpecificTestObjectEncoding:(Class)cls webView:(id)webView { - (void)testJavascriptReceiveResponse { [self classSpecificTestJavascriptReceiveResponse:[WebViewJavascriptBridge class] webView:_uiWebView]; [self classSpecificTestJavascriptReceiveResponse:[WKWebViewJavascriptBridge class] webView:_wkWebView]; - [self waitForExpectationsWithTimeout:3 handler:NULL]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; } - (void)classSpecificTestJavascriptReceiveResponse:(Class)cls webView:(id)webView { WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; @@ -142,7 +144,7 @@ - (void)classSpecificTestJavascriptReceiveResponse:(Class)cls webView:(id)webVie - (void)testJavascriptReceiveResponseWithoutSafetyTimeout { [self classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:[WebViewJavascriptBridge class] webView:_uiWebView]; [self classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:[WKWebViewJavascriptBridge class] webView:_wkWebView]; - [self waitForExpectationsWithTimeout:3 handler:NULL]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; } - (void)classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:(Class)cls webView:(id)webView { WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; From ec0413e2cfeb707d086cb2e65044cabcb104894f Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 13 Dec 2016 12:26:53 -0500 Subject: [PATCH 094/158] Update to latest xcode recommended settings --- .../WebViewJavascriptBridge.xcodeproj/project.pbxproj | 10 +++++++--- .../xcschemes/WebViewJavascriptBridge.xcscheme | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj index 153bfd24..3224ac83 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj +++ b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -200,7 +200,7 @@ 3D0FE4621AE2886400BB4104 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0720; + LastUpgradeCheck = 0810; ORGANIZATIONNAME = marcuswestin; TargetAttributes = { 3D0FE4741AE2886500BB4104 = { @@ -296,8 +296,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; @@ -319,7 +321,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 6.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -339,8 +341,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; @@ -355,7 +359,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 6.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme b/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme index af2a0875..ea9272cf 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme +++ b/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme @@ -1,6 +1,6 @@ Date: Tue, 13 Dec 2016 12:27:28 -0500 Subject: [PATCH 095/158] v5.0.6 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index acb5c269..f113190b 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '5.0.5' + s.version = '5.0.6' s.summary = 'An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From f00d6f7bb18cb803cdbffe416c1a43c380580615 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 13 Dec 2016 12:47:58 -0500 Subject: [PATCH 096/158] Fix #201 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index db4577bd..d490fcd9 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ self.bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; NSLog(@"ObjC Echo called with: %@", data); responseCallback(data); }]; -[self.bridge callHandler:@"JS Echo" responseCallback:^(id responseData) { +[self.bridge callHandler:@"JS Echo" data:nil responseCallback:^(id responseData) { NSLog(@"ObjC received response: %@", responseData); }]; ``` From c23352f5b9f40e6009a0cd6a9399c63ac9ea5a77 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 13 Dec 2016 13:17:31 -0500 Subject: [PATCH 097/158] Update to latest recommended xcode settings for example apps --- .../ExampleApp-OSX.xcodeproj/project.pbxproj | 21 +++++++++- Example Apps/ExampleApp-OSX/AppDelegate.m | 2 +- .../ExampleApp-OSX/ExampleApp-OSX-Info.plist | 2 +- .../ExampleApp-iOS.xcodeproj/project.pbxproj | 39 ++++++++++++++++--- .../ExampleApp-iOS/ExampleApp-iOS-Info.plist | 2 +- 5 files changed, 57 insertions(+), 9 deletions(-) diff --git a/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj index 410ce82c..d08ca0ab 100644 --- a/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj @@ -164,7 +164,7 @@ 2C136A1917641106004C7401 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0510; + LastUpgradeCheck = 0810; ORGANIZATIONNAME = "Marcus Westin"; }; buildConfigurationList = 2C136A1C17641106004C7401 /* Build configuration list for PBXProject "ExampleApp-OSX" */; @@ -241,15 +241,22 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -258,7 +265,9 @@ GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; ONLY_ACTIVE_ARCH = YES; @@ -273,18 +282,26 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; SDKROOT = macosx; @@ -299,6 +316,7 @@ GCC_PREFIX_HEADER = "ExampleApp-OSX/ExampleApp-OSX-Prefix.pch"; INFOPLIST_FILE = "ExampleApp-OSX/ExampleApp-OSX-Info.plist"; MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_BUNDLE_IDENTIFIER = "WebViewJavascriptBridge.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -312,6 +330,7 @@ GCC_PREFIX_HEADER = "ExampleApp-OSX/ExampleApp-OSX-Prefix.pch"; INFOPLIST_FILE = "ExampleApp-OSX/ExampleApp-OSX-Info.plist"; MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_BUNDLE_IDENTIFIER = "WebViewJavascriptBridge.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; diff --git a/Example Apps/ExampleApp-OSX/AppDelegate.m b/Example Apps/ExampleApp-OSX/AppDelegate.m index a9f68fb4..0f5dc641 100644 --- a/Example Apps/ExampleApp-OSX/AppDelegate.m +++ b/Example Apps/ExampleApp-OSX/AppDelegate.m @@ -56,7 +56,7 @@ - (void)_configureWebview { // Load Page NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"ExampleApp" ofType:@"html"]; NSString* html = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil]; - NSURL *baseURL = [NSURL fileURLWithPath:htmlPath] + NSURL *baseURL = [NSURL fileURLWithPath:htmlPath]; [[_webView mainFrame] loadHTMLString:html baseURL: baseURL]; } diff --git a/Example Apps/ExampleApp-OSX/ExampleApp-OSX-Info.plist b/Example Apps/ExampleApp-OSX/ExampleApp-OSX-Info.plist index 846d4e33..b9f1feaa 100644 --- a/Example Apps/ExampleApp-OSX/ExampleApp-OSX-Info.plist +++ b/Example Apps/ExampleApp-OSX/ExampleApp-OSX-Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile CFBundleIdentifier - WebViewJavascriptBridge.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj index c1039a80..c959164e 100644 --- a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj @@ -165,7 +165,7 @@ 2CEB3EB21602563600548120 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0500; + LastUpgradeCheck = 0810; ORGANIZATIONNAME = "Marcus Westin"; }; buildConfigurationList = 2CEB3EB51602563600548120 /* Build configuration list for PBXProject "ExampleApp-iOS" */; @@ -235,21 +235,35 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 6.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; @@ -262,14 +276,27 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 6.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; @@ -282,7 +309,8 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "ExampleApp-iOS/ExampleApp-iOS-Prefix.pch"; INFOPLIST_FILE = "ExampleApp-iOS/ExampleApp-iOS-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.1; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.example.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "ExampleApp-iOS"; WRAPPER_EXTENSION = app; }; @@ -294,7 +322,8 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "ExampleApp-iOS/ExampleApp-iOS-Prefix.pch"; INFOPLIST_FILE = "ExampleApp-iOS/ExampleApp-iOS-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 7.1; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.example.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "ExampleApp-iOS"; WRAPPER_EXTENSION = app; }; diff --git a/Example Apps/ExampleApp-iOS/ExampleApp-iOS-Info.plist b/Example Apps/ExampleApp-iOS/ExampleApp-iOS-Info.plist index 81d25998..3eb70251 100644 --- a/Example Apps/ExampleApp-iOS/ExampleApp-iOS-Info.plist +++ b/Example Apps/ExampleApp-iOS/ExampleApp-iOS-Info.plist @@ -9,7 +9,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - com.example.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName From bb9a2bd8d8a66f7f5bb30ea30481509e5c7f2b5f Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 13 Dec 2016 13:21:01 -0500 Subject: [PATCH 098/158] Update settings to point to 8.0 and remove unneeded frameworks --- Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj | 4 ---- Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj index c959164e..6f608b26 100644 --- a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj @@ -20,8 +20,6 @@ 2CA0465C1711AC8E006DEE8B /* ExampleApp.html in Resources */ = {isa = PBXBuildFile; fileRef = 2CA0465B1711AC8D006DEE8B /* ExampleApp.html */; }; 2CAB869B1727684300BD9ED1 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2CAB869A1727684300BD9ED1 /* Default-568h@2x.png */; }; 2CEB3EC01602563600548120 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EBF1602563600548120 /* UIKit.framework */; }; - 2CEB3EC21602563600548120 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EC11602563600548120 /* Foundation.framework */; }; - 2CEB3EC41602563600548120 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EC31602563600548120 /* CoreGraphics.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -59,8 +57,6 @@ files = ( 0E4E9D4C1A101E0B00043087 /* WebKit.framework in Frameworks */, 2CEB3EC01602563600548120 /* UIKit.framework in Frameworks */, - 2CEB3EC21602563600548120 /* Foundation.framework in Frameworks */, - 2CEB3EC41602563600548120 /* CoreGraphics.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj index 3224ac83..cb653385 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj +++ b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -411,6 +411,7 @@ "$(inherited)", ); INFOPLIST_FILE = WebViewJavascriptBridgeTestHost/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswestin.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -422,6 +423,7 @@ buildSettings = { "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; INFOPLIST_FILE = WebViewJavascriptBridgeTestHost/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswestin.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; From de8e064f2e1d594e99e9df3ce8aa35959ecdcd55 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 13 Dec 2016 13:21:36 -0500 Subject: [PATCH 099/158] v5.0.7 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index f113190b..1fc63372 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '5.0.6' + s.version = '5.0.7' s.summary = 'An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From a174cb6064bb93a7fb3f995fb1391c8ee4528ee9 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 13 Dec 2016 16:00:03 -0500 Subject: [PATCH 100/158] Use http:// instead of wvjbscheme and lowercase URL parts, as suggested in #233 --- Example Apps/ExampleApp.html | 2 +- README.md | 2 +- Tests/WebViewJavascriptBridgeTests/echo.html | 2 +- WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h | 6 +++--- WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m | 2 +- WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Example Apps/ExampleApp.html b/Example Apps/ExampleApp.html index 646806a5..cc690a3c 100644 --- a/Example Apps/ExampleApp.html +++ b/Example Apps/ExampleApp.html @@ -20,7 +20,7 @@

WebViewJavascriptBridge Demo

window.WVJBCallbacks = [callback]; var WVJBIframe = document.createElement('iframe'); WVJBIframe.style.display = 'none'; - WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__'; + WVJBIframe.src = 'http://__bridge_loaded__'; document.documentElement.appendChild(WVJBIframe); setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) } diff --git a/README.md b/README.md index d490fcd9..92f525e0 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ function setupWebViewJavascriptBridge(callback) { window.WVJBCallbacks = [callback]; var WVJBIframe = document.createElement('iframe'); WVJBIframe.style.display = 'none'; - WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__'; + WVJBIframe.src = 'http://__bridge_loaded__'; document.documentElement.appendChild(WVJBIframe); setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) } diff --git a/Tests/WebViewJavascriptBridgeTests/echo.html b/Tests/WebViewJavascriptBridgeTests/echo.html index 809de438..76808c8f 100644 --- a/Tests/WebViewJavascriptBridgeTests/echo.html +++ b/Tests/WebViewJavascriptBridgeTests/echo.html @@ -9,7 +9,7 @@ window.WVJBCallbacks = [callback]; var WVJBIframe = document.createElement('iframe'); WVJBIframe.style.display = 'none'; - WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__'; + WVJBIframe.src = 'http://__bridge_loaded__'; document.documentElement.appendChild(WVJBIframe); setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) } diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h index 3cf5a31c..fa645f1b 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -7,9 +7,9 @@ #import -#define kCustomProtocolScheme @"wvjbscheme" -#define kQueueHasMessage @"__WVJB_QUEUE_MESSAGE__" -#define kBridgeLoaded @"__BRIDGE_LOADED__" +#define kCustomProtocolScheme @"http" +#define kQueueHasMessage @"__wvjb_queue_message__" +#define kBridgeLoaded @"__bridge_loaded__" typedef void (^WVJBResponseCallback)(id responseData); typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback); diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index 2711914e..704e4c2f 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -142,7 +142,7 @@ -(BOOL)isBridgeLoadedURL:(NSURL*)url { } -(void)logUnkownMessage:(NSURL*)url { - NSLog(@"WebViewJavascriptBridge: WARNING: Received unknown WebViewJavascriptBridge command %@://%@", kCustomProtocolScheme, [url path]); + NSLog(@"WebViewJavascriptBridge: WARNING: Received unknown WebViewJavascriptBridge command %@", [url absoluteString]); } -(NSString *)webViewJavascriptCheckCommand { diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m index c99b7e6a..0128ae82 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m @@ -37,8 +37,8 @@ var sendMessageQueue = []; var messageHandlers = {}; - var CUSTOM_PROTOCOL_SCHEME = 'wvjbscheme'; - var QUEUE_HAS_MESSAGE = '__WVJB_QUEUE_MESSAGE__'; + var CUSTOM_PROTOCOL_SCHEME = 'http'; + var QUEUE_HAS_MESSAGE = '__wvjb_queue_message__'; var responseCallbacks = {}; var uniqueId = 1; From 01598031fc1dadd58ebf612f42a5163fc248151e Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Fri, 23 Dec 2016 14:26:53 -0500 Subject: [PATCH 101/158] Split up test screen into UIWebVIew and WKWebView --- Tests/WebViewJavascriptBridgeTests/BridgeTests.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m index 7224e72b..82c99ab3 100644 --- a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m @@ -27,10 +27,14 @@ - (void)setUp { [super setUp]; UIViewController *rootVC = [[(AppDelegate *)[[UIApplication sharedApplication] delegate] window] rootViewController]; - _uiWebView = [[UIWebView alloc] initWithFrame:rootVC.view.bounds]; - CGRect wkFrame = _uiWebView.frame; - wkFrame.origin.y += _uiWebView.frame.size.height; - _wkWebView = [[WKWebView alloc] initWithFrame:wkFrame]; + CGRect frame = rootVC.view.bounds; + frame.size.height /= 2; + _uiWebView = [[UIWebView alloc] initWithFrame:frame]; + _uiWebView.backgroundColor = [UIColor blueColor]; + [rootVC.view addSubview:_uiWebView]; + frame.origin.y += frame.size.height; + _wkWebView = [[WKWebView alloc] initWithFrame:frame]; + _wkWebView.backgroundColor = [UIColor redColor]; [rootVC.view addSubview:_wkWebView]; } From 91eb3a6b5ab071729f7d695bd919e54999164cd6 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Fri, 23 Dec 2016 14:28:16 -0500 Subject: [PATCH 102/158] Use https instead of http to stop insecure warning. It wont finish loading anyway, since we will intercept it --- Tests/WebViewJavascriptBridgeTests/echo.html | 2 +- WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h | 2 +- WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/WebViewJavascriptBridgeTests/echo.html b/Tests/WebViewJavascriptBridgeTests/echo.html index 76808c8f..b5076d9f 100644 --- a/Tests/WebViewJavascriptBridgeTests/echo.html +++ b/Tests/WebViewJavascriptBridgeTests/echo.html @@ -9,7 +9,7 @@ window.WVJBCallbacks = [callback]; var WVJBIframe = document.createElement('iframe'); WVJBIframe.style.display = 'none'; - WVJBIframe.src = 'http://__bridge_loaded__'; + WVJBIframe.src = 'https://__bridge_loaded__'; document.documentElement.appendChild(WVJBIframe); setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) } diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h index fa645f1b..6fc37a76 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -7,7 +7,7 @@ #import -#define kCustomProtocolScheme @"http" +#define kCustomProtocolScheme @"https" #define kQueueHasMessage @"__wvjb_queue_message__" #define kBridgeLoaded @"__bridge_loaded__" diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m index 0128ae82..670a552f 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m @@ -37,7 +37,7 @@ var sendMessageQueue = []; var messageHandlers = {}; - var CUSTOM_PROTOCOL_SCHEME = 'http'; + var CUSTOM_PROTOCOL_SCHEME = 'https'; var QUEUE_HAS_MESSAGE = '__wvjb_queue_message__'; var responseCallbacks = {}; From d1396d3da160ac6e5b5fd858808873a3ed00687a Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Fri, 23 Dec 2016 14:28:56 -0500 Subject: [PATCH 103/158] v5.0.8 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 1fc63372..5c18285e 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '5.0.7' + s.version = '5.0.8' s.summary = 'An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 20e99938ccfb035c076c3fdbb4343acef396a197 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 11:05:28 -0500 Subject: [PATCH 104/158] Fix test runner by ensuring that the bridges are retained throughout the duration of each test --- .../BridgeTests.m | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m index 82c99ab3..5cdde92d 100644 --- a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m @@ -21,6 +21,8 @@ @interface BridgeTests : XCTestCase @implementation BridgeTests { UIWebView *_uiWebView; WKWebView *_wkWebView; + WebViewJavascriptBridge* _uiWebViewBridge; + WKWebViewJavascriptBridge* _wkWebViewBridge; } - (void)setUp { @@ -44,6 +46,16 @@ - (void)tearDown { [_wkWebView removeFromSuperview]; } +- (WebViewJavascriptBridge*)bridgeForCls:(Class)cls webView:(id)webView { + if (cls == [WebViewJavascriptBridge class]) { + _uiWebViewBridge = [WebViewJavascriptBridge bridgeForWebView:webView]; + return _uiWebViewBridge; + } else { + _wkWebViewBridge = [WKWebViewJavascriptBridge bridgeForWebView:_wkWebView]; + return (WebViewJavascriptBridge*) _wkWebViewBridge; + } +} + static void loadEchoSample(id webView) { NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"echo" withExtension:@"html"]]; [(UIWebView*)webView loadRequest:request]; @@ -163,13 +175,4 @@ - (void)classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:(Class)cl [callbackInvocked fulfill]; }]; } - - -- (WebViewJavascriptBridge*)bridgeForCls:(Class)cls webView:(id)webView { - if (cls == [WebViewJavascriptBridge class]) { - return [WebViewJavascriptBridge bridgeForWebView:webView]; - } else { - return (WebViewJavascriptBridge*)[WKWebViewJavascriptBridge bridgeForWebView:_wkWebView]; - } -} @end From 1fdce16f22523de57b199264e1f251eb903c6750 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 11:55:51 -0500 Subject: [PATCH 105/158] Remove build warning of test project --- .../WebViewJavascriptBridge.xcodeproj/project.pbxproj | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj index cb653385..71ffed9e 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj +++ b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -370,10 +370,7 @@ isa = XCBuildConfiguration; buildSettings = { "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -390,10 +387,7 @@ isa = XCBuildConfiguration; buildSettings = { "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = WebViewJavascriptBridgeTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswestin.WebViewJavascriptBridge.$(PRODUCT_NAME:rfc1034identifier)"; From 6ff16d5aec0f1b53b2cc255c2451ef69868e7010 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 12:00:37 -0500 Subject: [PATCH 106/158] Run travis tests on xcode 8.2 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0503bac4..c8058f46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ language: objective-c +osx_image: xcode8.2 script: - make test \ No newline at end of file From f100f84837dd92f4d060c468d615e026ada4ef57 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 12:05:47 -0500 Subject: [PATCH 107/158] Run travis CI on a range of iPhone and iOS versions --- .travis.yml | 2 +- Makefile | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c8058f46..d209611b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: objective-c osx_image: xcode8.2 script: - - make test \ No newline at end of file + - make test-all diff --git a/Makefile b/Makefile index 9d133a0b..a386175f 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,13 @@ test: - xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge -destination 'platform=iOS Simulator,name=iPhone 5s' + xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ + -destination 'platform=iOS Simulator,name=iPhone 7' + +test-all: + xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ + -destination 'platform=iOS Simulator,name=iPhone SE,OS=10.1' \ + -destination 'platform=iOS Simulator,name=iPhone 6s Plus,OS=9.3' \ + -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ + -destination 'platform=iOS Simulator,name=iPhone 7' publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' From 064b33a2bcc3d6e8e21e9827800c102876995d22 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 12:23:54 -0500 Subject: [PATCH 108/158] Create ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..5bbb1f13 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,17 @@ +# Bug report: + +Thanks for reporting an issue with WebViewJavascriptBridge! + +Do these 4 things and I will fix your problem for you! + +1: Go to https://github.com/marcuswestin/WebViewJavascriptBridge and click Fork. +2: Clone your fork, `cd` into it and run `make test`. All tests should pass! +3: Edit `Tests/WebViewJavascriptBridgeTests/BridgeTests.m` and create a new, failing test which demostrates your issue. +4: Create a pull request for https://github.com/marcuswestin/WebViewJavascriptBridge + +That's it! I'll take it from there, and promise I'll fix your failing test ASAP. + +If you don't do these 3 things then I can't help you effectively, and probably won't :) + +Cheers, +@marcuswestin From c8467f110f635aac6cf5a68aef70d8c74eeef56d Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 12:26:54 -0500 Subject: [PATCH 109/158] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 5bbb1f13..116bfc6f 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,17 +1,21 @@ -# Bug report: +# WVJB Bug Report Thanks for reporting an issue with WebViewJavascriptBridge! -Do these 4 things and I will fix your problem for you! +### Do these 4 things and I will fix your problem! -1: Go to https://github.com/marcuswestin/WebViewJavascriptBridge and click Fork. -2: Clone your fork, `cd` into it and run `make test`. All tests should pass! -3: Edit `Tests/WebViewJavascriptBridgeTests/BridgeTests.m` and create a new, failing test which demostrates your issue. -4: Create a pull request for https://github.com/marcuswestin/WebViewJavascriptBridge +1. Go to https://github.com/marcuswestin/WebViewJavascriptBridge and click Fork. +2. Clone your fork, `cd` into it and run `make test`. All tests should pass! +3. Edit `Tests/WebViewJavascriptBridgeTests/BridgeTests.m` and create a new, failing test which demostrates your issue. +4. Create a pull request for https://github.com/marcuswestin/WebViewJavascriptBridge -That's it! I'll take it from there, and promise I'll fix your failing test ASAP. +#### That's it! -If you don't do these 3 things then I can't help you effectively, and probably won't :) +I will take it from there and promise that I'll fix your problem ASAP. + +#### If you don't do these 3 things then I can't help you effectively. + +And I probably won't :) Cheers, @marcuswestin From 95de9fb54df8f8494425f779b6d8b9a5654c4346 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 12:27:09 -0500 Subject: [PATCH 110/158] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 116bfc6f..6607e632 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,6 +1,6 @@ # WVJB Bug Report -Thanks for reporting an issue with WebViewJavascriptBridge! +Thanks for reporting an issue with WebViewJavascriptBridge. ### Do these 4 things and I will fix your problem! From 8d0c68072e330a4e83c8cb11a991e795617b428d Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 12:27:49 -0500 Subject: [PATCH 111/158] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 6607e632..81a6b69c 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -13,7 +13,7 @@ Thanks for reporting an issue with WebViewJavascriptBridge. I will take it from there and promise that I'll fix your problem ASAP. -#### If you don't do these 3 things then I can't help you effectively. +#### If you don't do this then I can't help you! And I probably won't :) From 1cb9489e2a6223528c2eb65bbf8ee29e44ee23b3 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 12:36:36 -0500 Subject: [PATCH 112/158] Fix Travis test destination list - for whatever reason it doesnt handle the unspecified-OS destination 'platform=iOS Simulator,name=iPhone 7' --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a386175f..109c0fbd 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,10 @@ test: test-all: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ - -destination 'platform=iOS Simulator,name=iPhone SE,OS=10.1' \ - -destination 'platform=iOS Simulator,name=iPhone 6s Plus,OS=9.3' \ -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ - -destination 'platform=iOS Simulator,name=iPhone 7' + -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' \ + -destination 'platform=iOS Simulator,name=iPhone SE,OS=10.1' \ + -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.2' publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' From c0da3807ba9a7726e71b12ec4c3813a13f8c75b9 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 12:45:59 -0500 Subject: [PATCH 113/158] Create PULL_REQUEST_TEMPLATE.md --- .github/PULL_REQUEST_TEMPLATE.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..920af1c5 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,13 @@ +## Before your create your PR: + +#### Please add tests for any new or changed functionality! + +1. Edit `Tests/WebViewJavascriptBridgeTests/BridgeTests.m` +2. Create a new test which demostrates your changes. +3. Run `make test` and make sure your test is passing +4. That's it! + +#### Thanks for improving WebViewJavascriptBridge! + +Cheers, +@marcuswestin From 75b13d4a0c0610be682f97cef7f2af5e3e71483b Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 12:56:56 -0500 Subject: [PATCH 114/158] For some reason travis is unable to run on 10.2 with iPhone 7 despite listing it as an available option in https://travis-ci.org/marcuswestin/WebViewJavascriptBridge/builds/186670121. Remove 10.2 --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 109c0fbd..db01edac 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,7 @@ test-all: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' \ - -destination 'platform=iOS Simulator,name=iPhone SE,OS=10.1' \ - -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.2' + -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' From 8ace34c0f9eb4a508ee4d13ed4a7538a91e78000 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 13:00:37 -0500 Subject: [PATCH 115/158] Whitespace fixes no functional changes --- .../WKWebViewJavascriptBridge.h | 2 +- .../WKWebViewJavascriptBridge.m | 20 ++++++------------- .../WebViewJavascriptBridge.m | 17 ++++++++-------- .../WebViewJavascriptBridgeBase.m | 12 +++++------ 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h index 5136f8d3..57d56831 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h @@ -30,4 +30,4 @@ @end -#endif \ No newline at end of file +#endif diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index a0e95462..0d58b198 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -96,8 +96,7 @@ - (void)WKFlushMessageQueue { }]; } -- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation -{ +- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { if (webView != _webView) { return; } __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; @@ -107,8 +106,7 @@ - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigat } -- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler -{ +- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler { if (webView != _webView) { return; } __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; @@ -120,8 +118,7 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNaviga } } -- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler -{ +- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler { if (webView != _webView) { return; } __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; @@ -132,9 +129,7 @@ - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAut } } -- (void)webView:(WKWebView *)webView -decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction -decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { +- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { if (webView != _webView) { return; } NSURL *url = navigationAction.request.URL; __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; @@ -167,9 +162,7 @@ - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation } -- (void)webView:(WKWebView *)webView -didFailNavigation:(WKNavigation *)navigation - withError:(NSError *)error { +- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error { if (webView != _webView) { return; } __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; @@ -187,8 +180,7 @@ - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation } } -- (NSString*) _evaluateJavascript:(NSString*)javascriptCommand -{ +- (NSString*) _evaluateJavascript:(NSString*)javascriptCommand { [_webView evaluateJavaScript:javascriptCommand completionHandler:nil]; return NULL; } diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index 68a6964b..92719039 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -24,8 +24,12 @@ @implementation WebViewJavascriptBridge { /* API *****/ -+ (void)enableLogging { [WebViewJavascriptBridgeBase enableLogging]; } -+ (void)setLogMaxLength:(int)length { [WebViewJavascriptBridgeBase setLogMaxLength:length]; } ++ (void)enableLogging { + [WebViewJavascriptBridgeBase enableLogging]; +} ++ (void)setLogMaxLength:(int)length { + [WebViewJavascriptBridgeBase setLogMaxLength:length]; +} + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView { WebViewJavascriptBridge* bridge = [[self alloc] init]; @@ -76,8 +80,7 @@ - (void)dealloc { _webViewDelegate = nil; } -- (NSString*) _evaluateJavascript:(NSString*)javascriptCommand -{ +- (NSString*) _evaluateJavascript:(NSString*)javascriptCommand { return [_webView stringByEvaluatingJavaScriptFromString:javascriptCommand]; } @@ -87,9 +90,7 @@ - (NSString*) _evaluateJavascript:(NSString*)javascriptCommand - (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView { _webView = webView; - _webView.policyDelegate = self; - _base = [[WebViewJavascriptBridgeBase alloc] init]; _base.delegate = self; } @@ -98,8 +99,7 @@ - (void) _platformSpecificDealloc { _webView.policyDelegate = nil; } -- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id)listener -{ +- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id)listener { if (webView != _webView) { return; } NSURL *url = [request URL]; @@ -157,6 +157,7 @@ - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if (webView != _webView) { return YES; } + NSURL *url = [request URL]; __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate; if ([_base isCorrectProcotocolScheme:url]) { diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index 704e4c2f..eea6d4bf 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -121,7 +121,7 @@ - (void)injectJavascriptFile { } } --(BOOL)isCorrectProcotocolScheme:(NSURL*)url { +- (BOOL)isCorrectProcotocolScheme:(NSURL*)url { if([[url scheme] isEqualToString:kCustomProtocolScheme]){ return YES; } else { @@ -129,7 +129,7 @@ -(BOOL)isCorrectProcotocolScheme:(NSURL*)url { } } --(BOOL)isQueueMessageURL:(NSURL*)url { +- (BOOL)isQueueMessageURL:(NSURL*)url { if([[url host] isEqualToString:kQueueHasMessage]){ return YES; } else { @@ -137,19 +137,19 @@ -(BOOL)isQueueMessageURL:(NSURL*)url { } } --(BOOL)isBridgeLoadedURL:(NSURL*)url { +- (BOOL)isBridgeLoadedURL:(NSURL*)url { return ([[url scheme] isEqualToString:kCustomProtocolScheme] && [[url host] isEqualToString:kBridgeLoaded]); } --(void)logUnkownMessage:(NSURL*)url { +- (void)logUnkownMessage:(NSURL*)url { NSLog(@"WebViewJavascriptBridge: WARNING: Received unknown WebViewJavascriptBridge command %@", [url absoluteString]); } --(NSString *)webViewJavascriptCheckCommand { +- (NSString *)webViewJavascriptCheckCommand { return @"typeof WebViewJavascriptBridge == \'object\';"; } --(NSString *)webViewJavascriptFetchQueyCommand { +- (NSString *)webViewJavascriptFetchQueyCommand { return @"WebViewJavascriptBridge._fetchQueue();"; } From 539d67e923bac1c262719e0eeb8c2b6bd826b610 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 13:00:56 -0500 Subject: [PATCH 116/158] Check that [super init] succeeds --- .../WebViewJavascriptBridgeBase.m | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index eea6d4bf..42261cbc 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -20,13 +20,14 @@ @implementation WebViewJavascriptBridgeBase { + (void)enableLogging { logging = true; } + (void)setLogMaxLength:(int)length { logMaxLength = length;} --(id)init { - self = [super init]; - self.messageHandlers = [NSMutableDictionary dictionary]; - self.startupMessageQueue = [NSMutableArray array]; - self.responseCallbacks = [NSMutableDictionary dictionary]; - _uniqueId = 0; - return(self); +- (id)init { + if (self = [super init]) { + self.messageHandlers = [NSMutableDictionary dictionary]; + self.startupMessageQueue = [NSMutableArray array]; + self.responseCallbacks = [NSMutableDictionary dictionary]; + _uniqueId = 0; + } + return self; } - (void)dealloc { From f3d2aceb5bdaea2dca27be450b9af69b71d6fa1a Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 14:34:22 -0500 Subject: [PATCH 117/158] Make `[WebViewJavascriptBridge bridgeForWebView:]` work for all web view types, including WKWebView. Fixes #252, #249. --- Example Apps/ExampleApp-OSX/AppDelegate.m | 5 +- .../ExampleWKWebViewController.m | 8 +-- Example Apps/ExampleApp.html | 2 +- README.md | 31 ++------- .../BridgeTests.m | 66 +++++++++---------- WebViewJavascriptBridge.podspec | 2 +- .../WKWebViewJavascriptBridge.h | 6 +- .../WKWebViewJavascriptBridge.m | 2 +- .../WebViewJavascriptBridge.h | 15 ++++- .../WebViewJavascriptBridge.m | 21 ++++-- 10 files changed, 78 insertions(+), 80 deletions(-) diff --git a/Example Apps/ExampleApp-OSX/AppDelegate.m b/Example Apps/ExampleApp-OSX/AppDelegate.m index 0f5dc641..5677342a 100644 --- a/Example Apps/ExampleApp-OSX/AppDelegate.m +++ b/Example Apps/ExampleApp-OSX/AppDelegate.m @@ -9,13 +9,12 @@ #import "AppDelegate.h" #import #import "WebViewJavascriptBridge.h" -#import "WKWebViewJavascriptBridge.h" @implementation AppDelegate { WebView* _webView; WKWebView *_WKWebView; WebViewJavascriptBridge* _bridge; - WKWebViewJavascriptBridge* _WKBridge; + WebViewJavascriptBridge* _WKBridge; NSView* _WKWebViewWrapper; } @@ -63,7 +62,7 @@ - (void)_configureWebview { - (void)_configureWKWebview { // Create Bridge - _WKBridge = [WKWebViewJavascriptBridge bridgeForWebView:_WKWebView]; + _WKBridge = [WebViewJavascriptBridge bridgeForWebView:_WKWebView]; [_WKBridge registerHandler:@"testObjcCallback" handler:^(id data, WVJBResponseCallback responseCallback) { NSLog(@"testObjcCallback called: %@", data); diff --git a/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m b/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m index 01aaa10f..f9d4ac79 100644 --- a/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m +++ b/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m @@ -7,11 +7,11 @@ // #import "ExampleWKWebViewController.h" -#import "WKWebViewJavascriptBridge.h" +#import "WebViewJavascriptBridge.h" @interface ExampleWKWebViewController () -@property WKWebViewJavascriptBridge* bridge; +@property WebViewJavascriptBridge* bridge; @end @@ -23,8 +23,8 @@ - (void)viewWillAppear:(BOOL)animated { WKWebView* webView = [[NSClassFromString(@"WKWebView") alloc] initWithFrame:self.view.bounds]; webView.navigationDelegate = self; [self.view addSubview:webView]; - [WKWebViewJavascriptBridge enableLogging]; - _bridge = [WKWebViewJavascriptBridge bridgeForWebView:webView]; + [WebViewJavascriptBridge enableLogging]; + _bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; [_bridge setWebViewDelegate:self]; [_bridge registerHandler:@"testObjcCallback" handler:^(id data, WVJBResponseCallback responseCallback) { diff --git a/Example Apps/ExampleApp.html b/Example Apps/ExampleApp.html index cc690a3c..06e7dc8a 100644 --- a/Example Apps/ExampleApp.html +++ b/Example Apps/ExampleApp.html @@ -20,7 +20,7 @@

WebViewJavascriptBridge Demo

window.WVJBCallbacks = [callback]; var WVJBIframe = document.createElement('iframe'); WVJBIframe.style.display = 'none'; - WVJBIframe.src = 'http://__bridge_loaded__'; + WVJBIframe.src = 'https://__bridge_loaded__'; document.documentElement.appendChild(WVJBIframe); setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) } diff --git a/README.md b/README.md index 92f525e0..dec776e4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ WebViewJavascriptBridge [![Build Status](https://travis-ci.org/marcuswestin/WebViewJavascriptBridge.svg)](https://travis-ci.org/marcuswestin/WebViewJavascriptBridge) -An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews. +An iOS/OSX bridge for sending messages between Obj-C and JavaScript in WKWebViews, UIWebViews & WebViews. Who uses WebViewJavascriptBridge? --------------------------------- @@ -62,7 +62,7 @@ Usage @property WebViewJavascriptBridge* bridge; ``` -2) Instantiate WebViewJavascriptBridge with a UIWebView (iOS) or WebView (OSX): +2) Instantiate WebViewJavascriptBridge with a WKWebView, UIWebView (iOS) or WebView (OSX): ```objc self.bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; @@ -89,7 +89,7 @@ function setupWebViewJavascriptBridge(callback) { window.WVJBCallbacks = [callback]; var WVJBIframe = document.createElement('iframe'); WVJBIframe.style.display = 'none'; - WVJBIframe.src = 'http://__bridge_loaded__'; + WVJBIframe.src = 'https://__bridge_loaded__'; document.documentElement.appendChild(WVJBIframe); setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) } @@ -112,25 +112,6 @@ setupWebViewJavascriptBridge(function(bridge) { }) ``` -WKWebView Support (iOS 8+ & OS 10.10+) --------------------------------------- - -(WARNING: WKWebView still has [bugs and missing network APIs.](https://github.com/ShingoFukuyama/WKWebViewTips/blob/master/README.md) It may not be a simple drop-in replacement). - -WebViewJavascriptBridge supports [WKWebView](http://nshipster.com/wkwebkit/) for iOS 8 and OSX Yosemite. In order to use WKWebView you need to instantiate the `WKWebViewJavascriptBridge`. The rest of the `WKWebViewJavascriptBridge` API is the same as `WebViewJavascriptBridge`. - -1) Import the header file: - -```objc -#import "WKWebViewJavascriptBridge.h" -``` - -2) Instantiate WKWebViewJavascriptBridge and with a WKWebView object - -```objc -WKWebViewJavascriptBridge* bridge = [WKWebViewJavascriptBridge bridgeForWebView:webView]; -``` - Automatic reference counting (ARC) ---------------------------------- This library relies on ARC, so if you use ARC in you project, all works fine. @@ -155,7 +136,7 @@ API Reference ### ObjC API -##### `[WebViewJavascriptBridge bridgeForWebView:(UIWebView/WebView*)webview` +##### `[WebViewJavascriptBridge bridgeForWebView:(WKWebVIew/UIWebView/WebView*)webview` Create a javascript bridge for the given web view. @@ -195,9 +176,9 @@ Example: }]; ``` -#### `[bridge setWebViewDelegate:(NSObject *)webViewDelegate]` +#### `[bridge setWebViewDelegate:(id)webViewDelegate]` -Optionally, set a `UIWebViewDelegate` if you need to respond to the [web view's lifecycle events](http://developer.apple.com/library/ios/documentation/uikit/reference/UIWebViewDelegate_Protocol/Reference/Reference.html). +Optionally, set a `WKNavigationDelegate/UIWebViewDelegate` if you need to respond to the [web view's lifecycle events](https://developer.apple.com/reference/uikit/uiwebviewdelegate). ##### `[bridge disableJavscriptAlertBoxSafetyTimeout]` diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m index 5cdde92d..2b865ca4 100644 --- a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m @@ -9,7 +9,6 @@ #import #import "WebViewJavascriptBridge.h" -#import "WKWebViewJavascriptBridge.h" #import "AppDelegate.h" static NSString *const echoHandler = @"echoHandler"; @@ -21,8 +20,7 @@ @interface BridgeTests : XCTestCase @implementation BridgeTests { UIWebView *_uiWebView; WKWebView *_wkWebView; - WebViewJavascriptBridge* _uiWebViewBridge; - WKWebViewJavascriptBridge* _wkWebViewBridge; + NSMutableArray* _bridgeRefs; } - (void)setUp { @@ -38,6 +36,8 @@ - (void)setUp { _wkWebView = [[WKWebView alloc] initWithFrame:frame]; _wkWebView.backgroundColor = [UIColor redColor]; [rootVC.view addSubview:_wkWebView]; + + _bridgeRefs = [NSMutableArray array]; } - (void)tearDown { @@ -46,14 +46,10 @@ - (void)tearDown { [_wkWebView removeFromSuperview]; } -- (WebViewJavascriptBridge*)bridgeForCls:(Class)cls webView:(id)webView { - if (cls == [WebViewJavascriptBridge class]) { - _uiWebViewBridge = [WebViewJavascriptBridge bridgeForWebView:webView]; - return _uiWebViewBridge; - } else { - _wkWebViewBridge = [WKWebViewJavascriptBridge bridgeForWebView:_wkWebView]; - return (WebViewJavascriptBridge*) _wkWebViewBridge; - } +- (WebViewJavascriptBridge*)bridgeForWebView:(id)webView { + WebViewJavascriptBridge* bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; + [_bridgeRefs addObject:bridge]; + return bridge; } static void loadEchoSample(id webView) { @@ -64,13 +60,13 @@ static void loadEchoSample(id webView) { const NSTimeInterval timeoutSec = 100; - (void)testInitialization { - [self classSpecificTestInitialization:[WebViewJavascriptBridge class] webView:_uiWebView]; - [self classSpecificTestInitialization:[WKWebViewJavascriptBridge class] webView:_wkWebView]; + [self classSpecificTestInitialization:_uiWebView]; + [self classSpecificTestInitialization:_wkWebView]; [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; } -- (void)classSpecificTestInitialization:(Class)cls webView:(id)webView { +- (void)classSpecificTestInitialization:(id)webView { XCTestExpectation *startup = [self expectationWithDescription:@"Startup completed"]; - WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; + WebViewJavascriptBridge *bridge = [self bridgeForWebView:webView]; [bridge registerHandler:@"Greet" handler:^(id data, WVJBResponseCallback responseCallback) { XCTAssertEqualObjects(data, @"Hello world"); [startup fulfill]; @@ -81,12 +77,12 @@ - (void)classSpecificTestInitialization:(Class)cls webView:(id)webView { } - (void)testEchoHandler { - [self classSpecificTestEchoHandler:[WebViewJavascriptBridge class] webView:_uiWebView]; - [self classSpecificTestEchoHandler:[WKWebViewJavascriptBridge class] webView:_wkWebView]; + [self classSpecificTestEchoHandler:_uiWebView]; + [self classSpecificTestEchoHandler:_wkWebView]; [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; } -- (void)classSpecificTestEchoHandler:(Class)cls webView:(id)webView { - WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; +- (void)classSpecificTestEchoHandler:(id)webView { + WebViewJavascriptBridge *bridge = [self bridgeForWebView:webView]; XCTestExpectation *callbackInvocked = [self expectationWithDescription:@"Callback invoked"]; [bridge callHandler:echoHandler data:@"testEchoHandler" responseCallback:^(id responseData) { @@ -98,12 +94,12 @@ - (void)classSpecificTestEchoHandler:(Class)cls webView:(id)webView { } - (void)testEchoHandlerAfterSetup { - [self classSpecificTestEchoHandlerAfterSetup:[WebViewJavascriptBridge class] webView:_uiWebView]; - [self classSpecificTestEchoHandlerAfterSetup:[WKWebViewJavascriptBridge class] webView:_wkWebView]; + [self classSpecificTestEchoHandlerAfterSetup:_uiWebView]; + [self classSpecificTestEchoHandlerAfterSetup:_wkWebView]; [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; } -- (void)classSpecificTestEchoHandlerAfterSetup:(Class)cls webView:(id)webView { - WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; +- (void)classSpecificTestEchoHandlerAfterSetup:(id)webView { + WebViewJavascriptBridge *bridge = [self bridgeForWebView:webView]; XCTestExpectation *callbackInvocked = [self expectationWithDescription:@"Callback invoked"]; loadEchoSample(webView); @@ -116,12 +112,12 @@ - (void)classSpecificTestEchoHandlerAfterSetup:(Class)cls webView:(id)webView { } - (void)testObjectEncoding { - [self classSpecificTestObjectEncoding:[WebViewJavascriptBridge class] webView:_uiWebView]; - [self classSpecificTestObjectEncoding:[WKWebViewJavascriptBridge class] webView:_wkWebView]; + [self classSpecificTestObjectEncoding:_uiWebView]; + [self classSpecificTestObjectEncoding:_wkWebView]; [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; } -- (void)classSpecificTestObjectEncoding:(Class)cls webView:(id)webView { - WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; +- (void)classSpecificTestObjectEncoding:(id)webView { + WebViewJavascriptBridge *bridge = [self bridgeForWebView:webView]; void (^echoObject)(id) = ^void(id object) { XCTestExpectation *callbackInvocked = [self expectationWithDescription:@"Callback invoked"]; @@ -140,12 +136,12 @@ - (void)classSpecificTestObjectEncoding:(Class)cls webView:(id)webView { } - (void)testJavascriptReceiveResponse { - [self classSpecificTestJavascriptReceiveResponse:[WebViewJavascriptBridge class] webView:_uiWebView]; - [self classSpecificTestJavascriptReceiveResponse:[WKWebViewJavascriptBridge class] webView:_wkWebView]; + [self classSpecificTestJavascriptReceiveResponse:_uiWebView]; + [self classSpecificTestJavascriptReceiveResponse:_wkWebView]; [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; } -- (void)classSpecificTestJavascriptReceiveResponse:(Class)cls webView:(id)webView { - WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; +- (void)classSpecificTestJavascriptReceiveResponse:(id)webView { + WebViewJavascriptBridge *bridge = [self bridgeForWebView:webView]; loadEchoSample(webView); XCTestExpectation *callbackInvocked = [self expectationWithDescription:@"Callback invoked"]; [bridge registerHandler:@"objcEchoToJs" handler:^(id data, WVJBResponseCallback responseCallback) { @@ -158,12 +154,12 @@ - (void)classSpecificTestJavascriptReceiveResponse:(Class)cls webView:(id)webVie } - (void)testJavascriptReceiveResponseWithoutSafetyTimeout { - [self classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:[WebViewJavascriptBridge class] webView:_uiWebView]; - [self classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:[WKWebViewJavascriptBridge class] webView:_wkWebView]; + [self classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:_uiWebView]; + [self classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:_wkWebView]; [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; } -- (void)classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:(Class)cls webView:(id)webView { - WebViewJavascriptBridge *bridge = [self bridgeForCls:cls webView:webView]; +- (void)classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:(id)webView { + WebViewJavascriptBridge *bridge = [self bridgeForWebView:webView]; [bridge disableJavscriptAlertBoxSafetyTimeout]; loadEchoSample(webView); XCTestExpectation *callbackInvocked = [self expectationWithDescription:@"Callback invoked"]; diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 5c18285e..47175a40 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -12,6 +12,6 @@ Pod::Spec.new do |s| s.osx.source_files = 'WebViewJavascriptBridge/*.{h,m}' s.ios.private_header_files = 'WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h' s.osx.private_header_files = 'WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h' + s.framework = 'WebKit' s.ios.framework = 'UIKit' - s.osx.framework = 'WebKit' end diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h index 57d56831..c7ca3b83 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h @@ -6,10 +6,10 @@ // #if (__MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_9 || __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_1) -#define supportsWKWebKit +#define supportsWKWebView #endif -#if defined(supportsWKWebKit ) +#if defined supportsWKWebView #import #import "WebViewJavascriptBridgeBase.h" @@ -25,7 +25,7 @@ - (void)callHandler:(NSString*)handlerName data:(id)data; - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; - (void)reset; -- (void)setWebViewDelegate:(id)webViewDelegate; +- (void)setWebViewDelegate:(id)webViewDelegate; - (void)disableJavscriptAlertBoxSafetyTimeout; @end diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index 0d58b198..e4a64adf 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -8,7 +8,7 @@ #import "WKWebViewJavascriptBridge.h" -#if defined(supportsWKWebKit) +#if defined supportsWKWebView @implementation WKWebViewJavascriptBridge { __weak WKWebView* _webView; diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.h index 0996944d..d7a297ab 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.h @@ -9,8 +9,15 @@ #import #import "WebViewJavascriptBridgeBase.h" +#if (__MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_9 || __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_1) +#define supportsWKWebView +#endif + +#if defined supportsWKWebView +#import +#endif + #if defined __MAC_OS_X_VERSION_MAX_ALLOWED - #import #define WVJB_PLATFORM_OSX #define WVJB_WEBVIEW_TYPE WebView #define WVJB_WEBVIEW_DELEGATE_TYPE NSObject @@ -25,7 +32,9 @@ @interface WebViewJavascriptBridge : WVJB_WEBVIEW_DELEGATE_INTERFACE -+ (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView; + ++ (instancetype)bridgeForWebView:(id)webView; + + (void)enableLogging; + (void)setLogMaxLength:(int)length; @@ -33,7 +42,7 @@ - (void)callHandler:(NSString*)handlerName; - (void)callHandler:(NSString*)handlerName data:(id)data; - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; -- (void)setWebViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate; +- (void)setWebViewDelegate:(id)webViewDelegate; - (void)disableJavscriptAlertBoxSafetyTimeout; @end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index 92719039..4e89898f 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -8,6 +8,10 @@ #import "WebViewJavascriptBridge.h" +#if defined(supportsWKWebView) +#import "WKWebViewJavascriptBridge.h" +#endif + #if __has_feature(objc_arc_weak) #define WVJB_WEAK __weak #else @@ -31,10 +35,19 @@ + (void)setLogMaxLength:(int)length { [WebViewJavascriptBridgeBase setLogMaxLength:length]; } -+ (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView { - WebViewJavascriptBridge* bridge = [[self alloc] init]; - [bridge _platformSpecificSetup:webView]; - return bridge; ++ (instancetype)bridgeForWebView:(id)webView { +#if defined supportsWKWebView + if ([webView isKindOfClass:[WKWebView class]]) { + return (WebViewJavascriptBridge*) [WKWebViewJavascriptBridge bridgeForWebView:webView]; + } +#endif + if ([webView isKindOfClass:[WVJB_WEBVIEW_TYPE class]]) { + WebViewJavascriptBridge* bridge = [[self alloc] init]; + [bridge _platformSpecificSetup:webView]; + return bridge; + } + [NSException raise:@"BadWebViewType" format:@"Unknown web view type."]; + return nil; } - (void)setWebViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate { From e3aef23e3379091b0d55ecadd6af19bee9114e82 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sun, 25 Dec 2016 14:35:02 -0500 Subject: [PATCH 118/158] v5.1.0 --- Changelog | 5 +++++ README.md | 1 + WebViewJavascriptBridge.podspec | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 362f9fdd..17be6b6c 100644 --- a/Changelog +++ b/Changelog @@ -16,6 +16,11 @@ Version History Next version + Pretty-print json in log messages +v5.1.0 ++ A single instantiation function for all webview types. ++ Improved test runner. ++ New instructions & templates for github issues and pull requests. + v5.0.5 + Run all tests for both UIWebView and WKWebView webviews/bridges. + Allow for calling handlers from JS with just a handler name and responseCallback function (#184). diff --git a/README.md b/README.md index dec776e4..ea4186a6 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ WebViewJavascriptBridge is used by a range of companies and projects. This is a - [FRIL](https://fril.jp) - [留白·WHITE](http://liubaiapp.com) - [BrowZine](http://thirdiron.com/browzine/) +- ... & many more! Installation (iOS & OSX) ------------------------ diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 47175a40..e0995936 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '5.0.8' + s.version = '5.1.0' s.summary = 'An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 690ae4d16e29e4a72aeadc477492c0d508693334 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 27 Dec 2016 15:38:31 -0500 Subject: [PATCH 119/158] Create a Swift app with automated tests --- .../ExampleApp-iOS.xcodeproj/project.pbxproj | 81 ++ .../project.pbxproj | 562 +++++++++++++ .../ExampleSwiftApp-iOS/AppDelegate.swift | 47 ++ .../AppIcon.appiconset/Contents.json | 68 ++ .../Base.lproj/LaunchScreen.storyboard | 27 + .../Base.lproj/Main.storyboard | 26 + .../ExampleSwiftApp-iOS/Info.plist | 45 ++ .../ExampleSwiftApp-iOS/ViewController.swift | 25 + .../ExampleSwiftApp_iOSTests.swift | 179 +++++ .../ExampleSwiftApp-iOSTests/Info.plist | 22 + Example Apps/ExampleSwiftApp-iOS/Podfile | 18 + Example Apps/ExampleSwiftApp-iOS/Podfile.lock | 16 + .../WebViewJavascriptBridge.podspec.json | 35 + .../ExampleSwiftApp-iOS/Pods/Manifest.lock | 16 + .../Pods/Pods.xcodeproj/project.pbxproj | 746 ++++++++++++++++++ .../Pods-ExampleSwiftApp-iOS/Info.plist | 26 + ...mpleSwiftApp-iOS-acknowledgements.markdown | 29 + ...ExampleSwiftApp-iOS-acknowledgements.plist | 61 ++ .../Pods-ExampleSwiftApp-iOS-dummy.m | 5 + .../Pods-ExampleSwiftApp-iOS-frameworks.sh | 91 +++ .../Pods-ExampleSwiftApp-iOS-resources.sh | 96 +++ .../Pods-ExampleSwiftApp-iOS-umbrella.h | 8 + .../Pods-ExampleSwiftApp-iOS.debug.xcconfig | 9 + .../Pods-ExampleSwiftApp-iOS.modulemap | 6 + .../Pods-ExampleSwiftApp-iOS.release.xcconfig | 9 + .../Pods-ExampleSwiftApp-iOSTests/Info.plist | 26 + ...wiftApp-iOSTests-acknowledgements.markdown | 29 + ...leSwiftApp-iOSTests-acknowledgements.plist | 61 ++ .../Pods-ExampleSwiftApp-iOSTests-dummy.m | 5 + ...ods-ExampleSwiftApp-iOSTests-frameworks.sh | 91 +++ ...Pods-ExampleSwiftApp-iOSTests-resources.sh | 96 +++ .../Pods-ExampleSwiftApp-iOSTests-umbrella.h | 8 + ...ds-ExampleSwiftApp-iOSTests.debug.xcconfig | 9 + .../Pods-ExampleSwiftApp-iOSTests.modulemap | 6 + ...-ExampleSwiftApp-iOSTests.release.xcconfig | 9 + .../WebViewJavascriptBridge/Info.plist | 26 + .../WebViewJavascriptBridge-dummy.m | 5 + .../WebViewJavascriptBridge-prefix.pch | 4 + .../WebViewJavascriptBridge-umbrella.h | 11 + .../WebViewJavascriptBridge.modulemap | 6 + .../WebViewJavascriptBridge.xcconfig | 9 + Example Apps/ExampleSwiftApp-iOS/echo.html | 33 + Makefile | 8 +- .../project.pbxproj | 14 + ...JavascriptBridgeTestHost-Bridging-Header.h | 13 + .../BridgeTests.swift | 35 + ...iewJavascriptBridgeTests-Bridging-Header.h | 4 + WebViewJavascriptBridge.podspec | 16 +- .../WebViewJavascriptBridge.h | 3 +- .../WebViewJavascriptBridge.m | 7 +- 50 files changed, 2776 insertions(+), 11 deletions(-) create mode 100644 Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcodeproj/project.pbxproj create mode 100644 Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/AppDelegate.swift create mode 100644 Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Base.lproj/LaunchScreen.storyboard create mode 100644 Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Base.lproj/Main.storyboard create mode 100644 Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Info.plist create mode 100644 Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/ViewController.swift create mode 100644 Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift create mode 100644 Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/Info.plist create mode 100644 Example Apps/ExampleSwiftApp-iOS/Podfile create mode 100644 Example Apps/ExampleSwiftApp-iOS/Podfile.lock create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Pods.xcodeproj/project.pbxproj create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Info.plist create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-acknowledgements.markdown create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-acknowledgements.plist create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-dummy.m create mode 100755 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-frameworks.sh create mode 100755 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-resources.sh create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-umbrella.h create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.debug.xcconfig create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.modulemap create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.release.xcconfig create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Info.plist create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-acknowledgements.markdown create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-acknowledgements.plist create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-dummy.m create mode 100755 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-frameworks.sh create mode 100755 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-resources.sh create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-umbrella.h create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.debug.xcconfig create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.modulemap create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.release.xcconfig create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/Info.plist create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-dummy.m create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-prefix.pch create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-umbrella.h create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge.modulemap create mode 100644 Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge.xcconfig create mode 100644 Example Apps/ExampleSwiftApp-iOS/echo.html create mode 100644 Tests/WebViewJavascriptBridgeTestHost/WebViewJavascriptBridgeTestHost-Bridging-Header.h create mode 100644 Tests/WebViewJavascriptBridgeTests/BridgeTests.swift create mode 100644 Tests/WebViewJavascriptBridgeTests/WebViewJavascriptBridgeTests-Bridging-Header.h diff --git a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj index 6f608b26..d351431a 100644 --- a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj @@ -20,6 +20,7 @@ 2CA0465C1711AC8E006DEE8B /* ExampleApp.html in Resources */ = {isa = PBXBuildFile; fileRef = 2CA0465B1711AC8D006DEE8B /* ExampleApp.html */; }; 2CAB869B1727684300BD9ED1 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2CAB869A1727684300BD9ED1 /* Default-568h@2x.png */; }; 2CEB3EC01602563600548120 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EBF1602563600548120 /* UIKit.framework */; }; + 6529BCFA17DEACD6F9C2E820 /* Pods_ExampleApp_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 495C20DD246029C0B2405EC9 /* Pods_ExampleApp_iOS.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -48,6 +49,9 @@ 2CEB3EBF1602563600548120 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 2CEB3EC11602563600548120 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 2CEB3EC31602563600548120 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 495C20DD246029C0B2405EC9 /* Pods_ExampleApp_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ExampleApp_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 4BCA4425A9554AF93A944458 /* Pods-ExampleApp-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleApp-iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleApp-iOS/Pods-ExampleApp-iOS.debug.xcconfig"; sourceTree = ""; }; + E4F0C608003752F273BB146F /* Pods-ExampleApp-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleApp-iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleApp-iOS/Pods-ExampleApp-iOS.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -57,6 +61,7 @@ files = ( 0E4E9D4C1A101E0B00043087 /* WebKit.framework in Frameworks */, 2CEB3EC01602563600548120 /* UIKit.framework in Frameworks */, + 6529BCFA17DEACD6F9C2E820 /* Pods_ExampleApp_iOS.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -113,6 +118,7 @@ 2CA045B617117439006DEE8B /* ExampleApp-iOS */, 2CEB3EBE1602563600548120 /* Frameworks */, 2CEB3EBC1602563600548120 /* Products */, + 81A733051B2F9C5795D856E4 /* Pods */, ); sourceTree = ""; }; @@ -131,10 +137,20 @@ 2CEB3EBF1602563600548120 /* UIKit.framework */, 2CEB3EC11602563600548120 /* Foundation.framework */, 2CEB3EC31602563600548120 /* CoreGraphics.framework */, + 495C20DD246029C0B2405EC9 /* Pods_ExampleApp_iOS.framework */, ); name = Frameworks; sourceTree = ""; }; + 81A733051B2F9C5795D856E4 /* Pods */ = { + isa = PBXGroup; + children = ( + 4BCA4425A9554AF93A944458 /* Pods-ExampleApp-iOS.debug.xcconfig */, + E4F0C608003752F273BB146F /* Pods-ExampleApp-iOS.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -142,9 +158,12 @@ isa = PBXNativeTarget; buildConfigurationList = 2CEB3ED31602563600548120 /* Build configuration list for PBXNativeTarget "ExampleApp-iOS" */; buildPhases = ( + 953B195B62A37FA474FD95D5 /* [CP] Check Pods Manifest.lock */, 2CEB3EB71602563600548120 /* Sources */, 2CEB3EB81602563600548120 /* Frameworks */, 2CEB3EB91602563600548120 /* Resources */, + A9D6EE0CEB388638298EBC18 /* [CP] Embed Pods Frameworks */, + 7E64B37A61F02883676CA89F /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -163,6 +182,11 @@ attributes = { LastUpgradeCheck = 0810; ORGANIZATIONNAME = "Marcus Westin"; + TargetAttributes = { + 2CEB3EBA1602563600548120 = { + LastSwiftMigration = 0820; + }; + }; }; buildConfigurationList = 2CEB3EB51602563600548120 /* Build configuration list for PBXProject "ExampleApp-iOS" */; compatibilityVersion = "Xcode 3.2"; @@ -194,6 +218,54 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 7E64B37A61F02883676CA89F /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleApp-iOS/Pods-ExampleApp-iOS-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 953B195B62A37FA474FD95D5 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + A9D6EE0CEB388638298EBC18 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleApp-iOS/Pods-ExampleApp-iOS-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 2CEB3EB71602563600548120 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -301,26 +373,35 @@ }; 2CEB3ED41602563600548120 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 4BCA4425A9554AF93A944458 /* Pods-ExampleApp-iOS.debug.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "ExampleApp-iOS/ExampleApp-iOS-Prefix.pch"; INFOPLIST_FILE = "ExampleApp-iOS/ExampleApp-iOS-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.example.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "ExampleApp-iOS"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; WRAPPER_EXTENSION = app; }; name = Debug; }; 2CEB3ED51602563600548120 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = E4F0C608003752F273BB146F /* Pods-ExampleApp-iOS.release.xcconfig */; buildSettings = { + CLANG_ENABLE_MODULES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "ExampleApp-iOS/ExampleApp-iOS-Prefix.pch"; INFOPLIST_FILE = "ExampleApp-iOS/ExampleApp-iOS-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.example.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "ExampleApp-iOS"; + SWIFT_VERSION = 3.0; WRAPPER_EXTENSION = app; }; name = Release; diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcodeproj/project.pbxproj b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcodeproj/project.pbxproj new file mode 100644 index 00000000..e40d422e --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcodeproj/project.pbxproj @@ -0,0 +1,562 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 2C85D0041E12D13E00B5BB1F /* echo.html in Resources */ = {isa = PBXBuildFile; fileRef = 2C85D0031E12D13E00B5BB1F /* echo.html */; }; + 2C85D0051E12D13E00B5BB1F /* echo.html in Resources */ = {isa = PBXBuildFile; fileRef = 2C85D0031E12D13E00B5BB1F /* echo.html */; }; + 2CF20A991E12BB3F00D3009D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CF20A981E12BB3F00D3009D /* AppDelegate.swift */; }; + 2CF20A9B1E12BB3F00D3009D /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CF20A9A1E12BB3F00D3009D /* ViewController.swift */; }; + 2CF20A9E1E12BB3F00D3009D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2CF20A9C1E12BB3F00D3009D /* Main.storyboard */; }; + 2CF20AA01E12BB3F00D3009D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2CF20A9F1E12BB3F00D3009D /* Assets.xcassets */; }; + 2CF20AA31E12BB3F00D3009D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2CF20AA11E12BB3F00D3009D /* LaunchScreen.storyboard */; }; + 2CF20AAE1E12BB3F00D3009D /* ExampleSwiftApp_iOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CF20AAD1E12BB3F00D3009D /* ExampleSwiftApp_iOSTests.swift */; }; + D8CEA1425EC257C350E1AB7B /* Pods_ExampleSwiftApp_iOSTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F83CA56A2551209150BE3026 /* Pods_ExampleSwiftApp_iOSTests.framework */; }; + F2E5C0A8E08BEBA27AF5E74A /* Pods_ExampleSwiftApp_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEA6EDCA550904DB02B48E33 /* Pods_ExampleSwiftApp_iOS.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 2CF20AAA1E12BB3F00D3009D /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 2CF20A8D1E12BB3F00D3009D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 2CF20A941E12BB3F00D3009D; + remoteInfo = "ExampleSwiftApp-iOS"; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 2C85D0031E12D13E00B5BB1F /* echo.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = echo.html; sourceTree = ""; }; + 2CF20A951E12BB3F00D3009D /* ExampleSwiftApp-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ExampleSwiftApp-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 2CF20A981E12BB3F00D3009D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 2CF20A9A1E12BB3F00D3009D /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 2CF20A9D1E12BB3F00D3009D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 2CF20A9F1E12BB3F00D3009D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 2CF20AA21E12BB3F00D3009D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 2CF20AA41E12BB3F00D3009D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 2CF20AA91E12BB3F00D3009D /* ExampleSwiftApp-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "ExampleSwiftApp-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 2CF20AAD1E12BB3F00D3009D /* ExampleSwiftApp_iOSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleSwiftApp_iOSTests.swift; sourceTree = ""; }; + 2CF20AAF1E12BB3F00D3009D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 428486AD61C115757F5B2D0E /* Pods-ExampleSwiftApp-iOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleSwiftApp-iOSTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.release.xcconfig"; sourceTree = ""; }; + 501BFA93F6923681FFC52CCF /* Pods-ExampleSwiftApp-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleSwiftApp-iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.debug.xcconfig"; sourceTree = ""; }; + 540FA2D8150D626B9E77FAB0 /* Pods-ExampleSwiftApp-iOSTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleSwiftApp-iOSTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.debug.xcconfig"; sourceTree = ""; }; + BEA6EDCA550904DB02B48E33 /* Pods_ExampleSwiftApp_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ExampleSwiftApp_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C5654CD94CAAAA26115AFE32 /* Pods-ExampleSwiftApp-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleSwiftApp-iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.release.xcconfig"; sourceTree = ""; }; + F83CA56A2551209150BE3026 /* Pods_ExampleSwiftApp_iOSTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ExampleSwiftApp_iOSTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 2CF20A921E12BB3F00D3009D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + F2E5C0A8E08BEBA27AF5E74A /* Pods_ExampleSwiftApp_iOS.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2CF20AA61E12BB3F00D3009D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + D8CEA1425EC257C350E1AB7B /* Pods_ExampleSwiftApp_iOSTests.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2CF20A8C1E12BB3F00D3009D = { + isa = PBXGroup; + children = ( + 2C85D0031E12D13E00B5BB1F /* echo.html */, + 2CF20A971E12BB3F00D3009D /* ExampleSwiftApp-iOS */, + 2CF20AAC1E12BB3F00D3009D /* ExampleSwiftApp-iOSTests */, + 2CF20A961E12BB3F00D3009D /* Products */, + 9F0299D3BBA025224C110345 /* Pods */, + 6303D0CF3CEDE121D7B2EAE7 /* Frameworks */, + ); + sourceTree = ""; + }; + 2CF20A961E12BB3F00D3009D /* Products */ = { + isa = PBXGroup; + children = ( + 2CF20A951E12BB3F00D3009D /* ExampleSwiftApp-iOS.app */, + 2CF20AA91E12BB3F00D3009D /* ExampleSwiftApp-iOSTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 2CF20A971E12BB3F00D3009D /* ExampleSwiftApp-iOS */ = { + isa = PBXGroup; + children = ( + 2CF20A981E12BB3F00D3009D /* AppDelegate.swift */, + 2CF20A9A1E12BB3F00D3009D /* ViewController.swift */, + 2CF20A9C1E12BB3F00D3009D /* Main.storyboard */, + 2CF20A9F1E12BB3F00D3009D /* Assets.xcassets */, + 2CF20AA11E12BB3F00D3009D /* LaunchScreen.storyboard */, + 2CF20AA41E12BB3F00D3009D /* Info.plist */, + ); + path = "ExampleSwiftApp-iOS"; + sourceTree = ""; + }; + 2CF20AAC1E12BB3F00D3009D /* ExampleSwiftApp-iOSTests */ = { + isa = PBXGroup; + children = ( + 2CF20AAD1E12BB3F00D3009D /* ExampleSwiftApp_iOSTests.swift */, + 2CF20AAF1E12BB3F00D3009D /* Info.plist */, + ); + path = "ExampleSwiftApp-iOSTests"; + sourceTree = ""; + }; + 6303D0CF3CEDE121D7B2EAE7 /* Frameworks */ = { + isa = PBXGroup; + children = ( + BEA6EDCA550904DB02B48E33 /* Pods_ExampleSwiftApp_iOS.framework */, + F83CA56A2551209150BE3026 /* Pods_ExampleSwiftApp_iOSTests.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 9F0299D3BBA025224C110345 /* Pods */ = { + isa = PBXGroup; + children = ( + 501BFA93F6923681FFC52CCF /* Pods-ExampleSwiftApp-iOS.debug.xcconfig */, + C5654CD94CAAAA26115AFE32 /* Pods-ExampleSwiftApp-iOS.release.xcconfig */, + 540FA2D8150D626B9E77FAB0 /* Pods-ExampleSwiftApp-iOSTests.debug.xcconfig */, + 428486AD61C115757F5B2D0E /* Pods-ExampleSwiftApp-iOSTests.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 2CF20A941E12BB3F00D3009D /* ExampleSwiftApp-iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2CF20AB21E12BB3F00D3009D /* Build configuration list for PBXNativeTarget "ExampleSwiftApp-iOS" */; + buildPhases = ( + E1EE87376320127A646E0030 /* [CP] Check Pods Manifest.lock */, + 2CF20A911E12BB3F00D3009D /* Sources */, + 2CF20A921E12BB3F00D3009D /* Frameworks */, + 2CF20A931E12BB3F00D3009D /* Resources */, + BA4C674FF1CCCC87D20090E4 /* [CP] Embed Pods Frameworks */, + F106D79C2CD5F06E8F3F438D /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "ExampleSwiftApp-iOS"; + productName = "ExampleSwiftApp-iOS"; + productReference = 2CF20A951E12BB3F00D3009D /* ExampleSwiftApp-iOS.app */; + productType = "com.apple.product-type.application"; + }; + 2CF20AA81E12BB3F00D3009D /* ExampleSwiftApp-iOSTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2CF20AB51E12BB3F00D3009D /* Build configuration list for PBXNativeTarget "ExampleSwiftApp-iOSTests" */; + buildPhases = ( + 4889AB1A10A2C9552E6BBD23 /* [CP] Check Pods Manifest.lock */, + 2CF20AA51E12BB3F00D3009D /* Sources */, + 2CF20AA61E12BB3F00D3009D /* Frameworks */, + 2CF20AA71E12BB3F00D3009D /* Resources */, + 329B179F6DF51F14F9B1629B /* [CP] Embed Pods Frameworks */, + 50CDAEBCB453B9875E9F7147 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + 2CF20AAB1E12BB3F00D3009D /* PBXTargetDependency */, + ); + name = "ExampleSwiftApp-iOSTests"; + productName = "ExampleSwiftApp-iOSTests"; + productReference = 2CF20AA91E12BB3F00D3009D /* ExampleSwiftApp-iOSTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 2CF20A8D1E12BB3F00D3009D /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0820; + LastUpgradeCheck = 0820; + ORGANIZATIONNAME = "Marcus Westin"; + TargetAttributes = { + 2CF20A941E12BB3F00D3009D = { + CreatedOnToolsVersion = 8.2.1; + ProvisioningStyle = Automatic; + }; + 2CF20AA81E12BB3F00D3009D = { + CreatedOnToolsVersion = 8.2.1; + ProvisioningStyle = Automatic; + TestTargetID = 2CF20A941E12BB3F00D3009D; + }; + }; + }; + buildConfigurationList = 2CF20A901E12BB3F00D3009D /* Build configuration list for PBXProject "ExampleSwiftApp-iOS" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 2CF20A8C1E12BB3F00D3009D; + productRefGroup = 2CF20A961E12BB3F00D3009D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 2CF20A941E12BB3F00D3009D /* ExampleSwiftApp-iOS */, + 2CF20AA81E12BB3F00D3009D /* ExampleSwiftApp-iOSTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 2CF20A931E12BB3F00D3009D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2CF20AA31E12BB3F00D3009D /* LaunchScreen.storyboard in Resources */, + 2CF20AA01E12BB3F00D3009D /* Assets.xcassets in Resources */, + 2CF20A9E1E12BB3F00D3009D /* Main.storyboard in Resources */, + 2C85D0041E12D13E00B5BB1F /* echo.html in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2CF20AA71E12BB3F00D3009D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2C85D0051E12D13E00B5BB1F /* echo.html in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 329B179F6DF51F14F9B1629B /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 4889AB1A10A2C9552E6BBD23 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 50CDAEBCB453B9875E9F7147 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + BA4C674FF1CCCC87D20090E4 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + E1EE87376320127A646E0030 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + F106D79C2CD5F06E8F3F438D /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 2CF20A911E12BB3F00D3009D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2CF20A9B1E12BB3F00D3009D /* ViewController.swift in Sources */, + 2CF20A991E12BB3F00D3009D /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 2CF20AA51E12BB3F00D3009D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2CF20AAE1E12BB3F00D3009D /* ExampleSwiftApp_iOSTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 2CF20AAB1E12BB3F00D3009D /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 2CF20A941E12BB3F00D3009D /* ExampleSwiftApp-iOS */; + targetProxy = 2CF20AAA1E12BB3F00D3009D /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 2CF20A9C1E12BB3F00D3009D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 2CF20A9D1E12BB3F00D3009D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 2CF20AA11E12BB3F00D3009D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 2CF20AA21E12BB3F00D3009D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 2CF20AB01E12BB3F00D3009D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 2CF20AB11E12BB3F00D3009D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 2CF20AB31E12BB3F00D3009D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 501BFA93F6923681FFC52CCF /* Pods-ExampleSwiftApp-iOS.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = "ExampleSwiftApp-iOS/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswest.ExampleSwiftApp-iOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 2CF20AB41E12BB3F00D3009D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C5654CD94CAAAA26115AFE32 /* Pods-ExampleSwiftApp-iOS.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = "ExampleSwiftApp-iOS/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswest.ExampleSwiftApp-iOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; + 2CF20AB61E12BB3F00D3009D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 540FA2D8150D626B9E77FAB0 /* Pods-ExampleSwiftApp-iOSTests.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + INFOPLIST_FILE = "ExampleSwiftApp-iOSTests/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswest.ExampleSwiftApp-iOSTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ExampleSwiftApp-iOS.app/ExampleSwiftApp-iOS"; + }; + name = Debug; + }; + 2CF20AB71E12BB3F00D3009D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 428486AD61C115757F5B2D0E /* Pods-ExampleSwiftApp-iOSTests.release.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + INFOPLIST_FILE = "ExampleSwiftApp-iOSTests/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswest.ExampleSwiftApp-iOSTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ExampleSwiftApp-iOS.app/ExampleSwiftApp-iOS"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2CF20A901E12BB3F00D3009D /* Build configuration list for PBXProject "ExampleSwiftApp-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2CF20AB01E12BB3F00D3009D /* Debug */, + 2CF20AB11E12BB3F00D3009D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2CF20AB21E12BB3F00D3009D /* Build configuration list for PBXNativeTarget "ExampleSwiftApp-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2CF20AB31E12BB3F00D3009D /* Debug */, + 2CF20AB41E12BB3F00D3009D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2CF20AB51E12BB3F00D3009D /* Build configuration list for PBXNativeTarget "ExampleSwiftApp-iOSTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2CF20AB61E12BB3F00D3009D /* Debug */, + 2CF20AB71E12BB3F00D3009D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 2CF20A8D1E12BB3F00D3009D /* Project object */; +} diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/AppDelegate.swift b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/AppDelegate.swift new file mode 100644 index 00000000..808eae5c --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/AppDelegate.swift @@ -0,0 +1,47 @@ +// +// AppDelegate.swift +// ExampleSwiftApp-iOS +// +// Created by John Marcus Westin on 12/27/16. +// Copyright © 2016 Marcus Westin. All rights reserved. +// + +import UIKit +import WebViewJavascriptBridge + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..36d2c80d --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Base.lproj/LaunchScreen.storyboard b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..fdf3f97d --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Base.lproj/Main.storyboard b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Base.lproj/Main.storyboard new file mode 100644 index 00000000..273375fc --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Info.plist b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Info.plist new file mode 100644 index 00000000..d0524738 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/ViewController.swift b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/ViewController.swift new file mode 100644 index 00000000..f6eb0351 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS/ViewController.swift @@ -0,0 +1,25 @@ +// +// ViewController.swift +// ExampleSwiftApp-iOS +// +// Created by John Marcus Westin on 12/27/16. +// Copyright © 2016 Marcus Westin. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + +} + diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift new file mode 100644 index 00000000..97bda1c5 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift @@ -0,0 +1,179 @@ +// +// ExampleSwiftApp_iOSTests.swift +// ExampleSwiftApp-iOSTests +// +// Created by John Marcus Westin on 12/27/16. +// Copyright © 2016 Marcus Westin. All rights reserved. +// + +import XCTest +import WebKit + +import WebViewJavascriptBridge +@testable import ExampleSwiftApp_iOS + +let timeout: Double = 3 + +class ExampleSwiftApp_iOSTests: XCTestCase { + var uiWebView: UIWebView = UIWebView.init() + var wkWebView: WKWebView = WKWebView.init() + var bridgeRefs: NSMutableArray = [] + + override func setUp() { + super.setUp() + + let rootVC = (UIApplication.shared.delegate as! AppDelegate).window!.rootViewController! + var frame = rootVC.view.bounds + frame.size.height /= 2 + + uiWebView = UIWebView.init(frame: frame) + uiWebView.backgroundColor = UIColor.blue + rootVC.view.addSubview(uiWebView) + + frame.origin.y += frame.size.height + wkWebView = WKWebView.init(frame: frame) + wkWebView.backgroundColor = UIColor.red + rootVC.view.addSubview(wkWebView) + + bridgeRefs = NSMutableArray.init() + } + + override func tearDown() { + super.tearDown() + uiWebView.removeFromSuperview() + wkWebView.removeFromSuperview() + } + + func bridgeForWebView(_ webView: Any) -> WebViewJavascriptBridge { + let bridge = WebViewJavascriptBridge.init(webView)! + bridgeRefs.add(bridge) + return bridge + } + + func loadEchoSample(_ webView: Any) { + let request = URLRequest.init(url: Bundle.main.url(forResource: "echo", withExtension: "html")!) + if webView is UIWebView { + (webView as! UIWebView).loadRequest(request) + } else { + (webView as! WKWebView).load(request) + } + } + + func testSetup() { + _testSetup(webView: uiWebView) + _testSetup(webView: wkWebView) + waitForExpectations(timeout: timeout, handler: nil) + } + func _testSetup(webView: Any) { + let setup = self.expectation(description: "Setup completed") + let bridge = self.bridgeForWebView(webView: webView) + bridge.registerHandler("Greet") { (data, responseCallback) in + XCTAssertEqual(data as! String, "Hello world") + setup.fulfill() + } + XCTAssertNotNil(bridge) + self.loadEchoSample(webView) + } + + + func testEchoHandler() { + _testEchoHandler(uiWebView) + _testEchoHandler(wkWebView) + waitForExpectations(timeout: timeout, handler: nil) + } + func _testEchoHandler(_ webView: Any) { + let bridge = bridgeForWebView(webView) + + let callbackInvoked = expectation(description: "Callback invoked") + bridge.callHandler("echoHandler", data:"testEchoHandler") { (responseData) in + XCTAssertEqual(responseData as! String, "testEchoHandler"); + callbackInvoked.fulfill() + }; + + loadEchoSample(webView); + } + + func testEchoHandlerAfterSetup() { + _testEchoHandlerAfterSetup(uiWebView) + _testEchoHandlerAfterSetup(wkWebView) + waitForExpectations(timeout: timeout, handler: nil) + } + func _testEchoHandlerAfterSetup(_ webView: Any) { + let bridge = bridgeForWebView(webView) + + let callbackInvoked = expectation(description: "Callback invoked") + loadEchoSample(webView); + DispatchQueue.main.asyncAfter(deadline: .now() + 0.150) { + bridge.callHandler("echoHandler", data:"testEchoHandler") { (responseData) in + XCTAssertEqual(responseData as! String, "testEchoHandler") + callbackInvoked.fulfill() + } + } + } + + func testObjectEncoding() { + _testObjectEncoding(uiWebView) + _testObjectEncoding(wkWebView) + waitForExpectations(timeout: timeout, handler: nil) + } + func _testObjectEncoding(_ webView: Any) { + let bridge = bridgeForWebView(webView) + + func echoObject(_ object: Any) { + let callbackInvoked = expectation(description: "Callback invoked") + bridge.callHandler("echoHandler", data:object) { (responseData) in + if (object is NSDictionary) { + XCTAssertEqual(responseData as! NSDictionary, object as! NSDictionary) + } else if (object is NSArray) { + XCTAssertEqual(responseData as! NSArray, object as! NSArray) + } + callbackInvoked.fulfill() + } + } + + echoObject("A string sent over the wire"); + echoObject("A string with '\"'/\\"); + echoObject([1, 2, 3]); + echoObject(["a":1, "b":2]); + + loadEchoSample(webView); + } + + func testJavascriptReceiveResponse() { + _testJavascriptReceiveResponse(uiWebView) + _testJavascriptReceiveResponse(wkWebView) + waitForExpectations(timeout: timeout, handler: nil) + } + func _testJavascriptReceiveResponse(_ webView: Any) { + let bridge = bridgeForWebView(webView) + loadEchoSample(webView); + let callbackInvoked = expectation(description: "Callback invoked") + bridge.registerHandler("objcEchoToJs") { (data, responseCallback) in + responseCallback!(data) + } + bridge.callHandler("jsRcvResponseTest", data:nil) { (responseData) in + XCTAssertEqual(responseData as! String, "Response from JS"); + callbackInvoked.fulfill() + } + } + + func testJavascriptReceiveResponseWithoutSafetyTimeout() { + _testJavascriptReceiveResponseWithoutSafetyTimeout(uiWebView) + _testJavascriptReceiveResponseWithoutSafetyTimeout(wkWebView) + waitForExpectations(timeout: timeout, handler: nil) + } + func _testJavascriptReceiveResponseWithoutSafetyTimeout(_ webView: Any) { + let bridge = bridgeForWebView(webView) + bridge.disableJavscriptAlertBoxSafetyTimeout() + loadEchoSample(webView); + let callbackInvoked = expectation(description: "Callback invoked") + bridge.registerHandler("objcEchoToJs") { (data, responseCallback) in + responseCallback!(data); + } + bridge.callHandler("jsRcvResponseTest", data:nil) { (responseData) in + XCTAssertEqual(responseData as! String, "Response from JS"); + callbackInvoked.fulfill() + } + } + +} diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/Info.plist b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/Info.plist new file mode 100644 index 00000000..6c6c23c4 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/Example Apps/ExampleSwiftApp-iOS/Podfile b/Example Apps/ExampleSwiftApp-iOS/Podfile new file mode 100644 index 00000000..504f6f15 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Podfile @@ -0,0 +1,18 @@ +project 'ExampleSwiftApp-iOS.xcodeproj' + +# Uncomment the next line to define a global platform for your project +platform :ios, '9.0' +use_frameworks! + +target 'ExampleSwiftApp-iOS' do + # Comment the next line if you're not using Swift and don't want to use dynamic frameworks + + pod 'WebViewJavascriptBridge', :path => '../..' + + target 'ExampleSwiftApp-iOSTests' do + inherit! :search_paths + + pod 'WebViewJavascriptBridge', :path => '../..' + end + +end diff --git a/Example Apps/ExampleSwiftApp-iOS/Podfile.lock b/Example Apps/ExampleSwiftApp-iOS/Podfile.lock new file mode 100644 index 00000000..bfae7841 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Podfile.lock @@ -0,0 +1,16 @@ +PODS: + - WebViewJavascriptBridge (5.1.0) + +DEPENDENCIES: + - WebViewJavascriptBridge (from `../..`) + +EXTERNAL SOURCES: + WebViewJavascriptBridge: + :path: ../.. + +SPEC CHECKSUMS: + WebViewJavascriptBridge: 46545f19ee7ccbf7c6b6d60ac32742cb972356a1 + +PODFILE CHECKSUM: f657cfcc5a24b7c7f0c7781719b73d4a834bc276 + +COCOAPODS: 1.1.1 diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json b/Example Apps/ExampleSwiftApp-iOS/Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json new file mode 100644 index 00000000..0a01c92d --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json @@ -0,0 +1,35 @@ +{ + "name": "WebViewJavascriptBridge", + "version": "5.1.0", + "summary": "An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.", + "homepage": "https://github.com/marcuswestin/WebViewJavascriptBridge", + "license": { + "type": "MIT", + "file": "LICENSE" + }, + "authors": { + "marcuswestin": "marcus.westin@gmail.com" + }, + "source": { + "git": "https://github.com/marcuswestin/WebViewJavascriptBridge.git", + "tag": "v5.1.0" + }, + "platforms": { + "ios": "5.0", + "osx": "" + }, + "requires_arc": true, + "ios": { + "source_files": "WebViewJavascriptBridge/*.{h,m}", + "private_header_files": "WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h", + "frameworks": [ + "UIKit", + "WebKit" + ] + }, + "osx": { + "source_files": "WebViewJavascriptBridge/*.{h,m}", + "private_header_files": "WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h" + }, + "frameworks": "WebKit" +} diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock b/Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock new file mode 100644 index 00000000..bfae7841 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock @@ -0,0 +1,16 @@ +PODS: + - WebViewJavascriptBridge (5.1.0) + +DEPENDENCIES: + - WebViewJavascriptBridge (from `../..`) + +EXTERNAL SOURCES: + WebViewJavascriptBridge: + :path: ../.. + +SPEC CHECKSUMS: + WebViewJavascriptBridge: 46545f19ee7ccbf7c6b6d60ac32742cb972356a1 + +PODFILE CHECKSUM: f657cfcc5a24b7c7f0c7781719b73d4a834bc276 + +COCOAPODS: 1.1.1 diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Pods.xcodeproj/project.pbxproj b/Example Apps/ExampleSwiftApp-iOS/Pods/Pods.xcodeproj/project.pbxproj new file mode 100644 index 00000000..3df53a61 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Pods.xcodeproj/project.pbxproj @@ -0,0 +1,746 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 1CE763074FD41F8F2481F1F218DE4A8D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81607F20092CACC1394D3DCB7D6993B0 /* Foundation.framework */; }; + 3CB3835FBA4FA17B69633D2A875158DD /* WebViewJavascriptBridge_JS.m in Sources */ = {isa = PBXBuildFile; fileRef = ECBC45CC74132CEFC65377142E782D6C /* WebViewJavascriptBridge_JS.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 4250D949ECFC5A97E1770301D77E2605 /* WKWebViewJavascriptBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 80C51525CDB583C0489D564B2B01B11A /* WKWebViewJavascriptBridge.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 45742C8C964B582FE0ADFF2E7905DFF5 /* WebViewJavascriptBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = E2A53CC2E9D7695847074947A62978CD /* WebViewJavascriptBridge.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4BB0061F245D474622102084EFAB5BD2 /* WebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = FE6B78215ECE85734B6458DD230E2364 /* WebViewJavascriptBridge.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 502A928C6ABAB459D2BA4B139DA6E1B1 /* WebViewJavascriptBridgeBase.m in Sources */ = {isa = PBXBuildFile; fileRef = FE55E03982FB6FAB2D2EA3B51B77077C /* WebViewJavascriptBridgeBase.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 64475BD96D86AB0FCCB594C527F1CAB8 /* WebViewJavascriptBridge-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 809AF8CF0188033BFA114CCE00D8B1BE /* WebViewJavascriptBridge-dummy.m */; }; + 68865B6F5C4FE0AA46A28DCAC9F4FC2A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5147AE3C7F8B063B02257EFF0EFD800 /* UIKit.framework */; }; + 8458FF2CDCD670B1FC51A7DDFD08255D /* WKWebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = CF0C2E9DF0EDC82844031C75B907FD1C /* WKWebViewJavascriptBridge.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 84B65AC46F34EA67BF48C8C3E7E71958 /* WebViewJavascriptBridge-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 8601B0C4F04E6601DF1E5B029E37AB16 /* WebViewJavascriptBridge-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 86194B24481631A6A6D0A698889045E3 /* Pods-ExampleSwiftApp-iOSTests-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 51187EA2FE506237A47693D319F38538 /* Pods-ExampleSwiftApp-iOSTests-dummy.m */; }; + 8F33194746E2C7D3D5BFE4E1FA5F8F11 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81607F20092CACC1394D3DCB7D6993B0 /* Foundation.framework */; }; + 902762E83E038BF12A45D29D10921D42 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81607F20092CACC1394D3DCB7D6993B0 /* Foundation.framework */; }; + 934D4692AC47E843BCD0C3B5751BC3E0 /* WebViewJavascriptBridge_JS.h in Headers */ = {isa = PBXBuildFile; fileRef = D02463846541C58A2828A6072E9B2B9F /* WebViewJavascriptBridge_JS.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 970CB101700BE9265F0267146F918345 /* WebViewJavascriptBridgeBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D0D1260897B04C231A6991D22E5429 /* WebViewJavascriptBridgeBase.h */; settings = {ATTRIBUTES = (Public, ); }; }; + EA1C1C1CC94437B705A83C5729E9480E /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1FAF4F70740F05FA34D54F1982E18E7A /* WebKit.framework */; }; + F2BD89AED3B8530725EED73659CD7F72 /* Pods-ExampleSwiftApp-iOS-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 221FB5C393B5465B754FAF4DC182E72C /* Pods-ExampleSwiftApp-iOS-dummy.m */; }; + F6693066686B895A8F059D886F82D6A1 /* Pods-ExampleSwiftApp-iOS-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = C83E0A2774D73C8F7C5A71AE10D90669 /* Pods-ExampleSwiftApp-iOS-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FF1285970402E7D12FC2D6EBE81D223E /* Pods-ExampleSwiftApp-iOSTests-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = CB0DCBAEC1A0C74D1AFC55D1DA8CB0CC /* Pods-ExampleSwiftApp-iOSTests-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 4CFE87BDA707128AA8A6C5FC0C72AB8C /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = C1D60A5C9331D2F60A106303D3494E52; + remoteInfo = WebViewJavascriptBridge; + }; + 5FFA8080C4895A871CEA5CBB57781845 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = C1D60A5C9331D2F60A106303D3494E52; + remoteInfo = WebViewJavascriptBridge; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 074E573B7C4E7956272ECDDD90007364 /* WebViewJavascriptBridge.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = WebViewJavascriptBridge.xcconfig; sourceTree = ""; }; + 11B2B8BD3820A60AFC145AD769239715 /* Pods-ExampleSwiftApp-iOSTests-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-ExampleSwiftApp-iOSTests-resources.sh"; sourceTree = ""; }; + 153E8B22B37A83060A1543A8C162FF14 /* Pods_ExampleSwiftApp_iOSTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_ExampleSwiftApp_iOSTests.framework; path = "Pods-ExampleSwiftApp-iOSTests.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; + 16E86B5E097D5A8CE34F29BC6EC8562A /* Pods_ExampleSwiftApp_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_ExampleSwiftApp_iOS.framework; path = "Pods-ExampleSwiftApp-iOS.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; + 1E3A50278BA035C069540E5E3AB2AEE1 /* Pods-ExampleSwiftApp-iOS-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-ExampleSwiftApp-iOS-frameworks.sh"; sourceTree = ""; }; + 1FAF4F70740F05FA34D54F1982E18E7A /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/System/Library/Frameworks/WebKit.framework; sourceTree = DEVELOPER_DIR; }; + 221FB5C393B5465B754FAF4DC182E72C /* Pods-ExampleSwiftApp-iOS-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-ExampleSwiftApp-iOS-dummy.m"; sourceTree = ""; }; + 23D3E482532423C6D5312922387BEBC0 /* Pods-ExampleSwiftApp-iOSTests-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-ExampleSwiftApp-iOSTests-frameworks.sh"; sourceTree = ""; }; + 31A437740C886407B1BD834E14857AB2 /* Pods-ExampleSwiftApp-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-ExampleSwiftApp-iOS.debug.xcconfig"; sourceTree = ""; }; + 51187EA2FE506237A47693D319F38538 /* Pods-ExampleSwiftApp-iOSTests-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-ExampleSwiftApp-iOSTests-dummy.m"; sourceTree = ""; }; + 51711AC3868C2190C69CA4EE14609033 /* Pods-ExampleSwiftApp-iOS-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-ExampleSwiftApp-iOS-acknowledgements.plist"; sourceTree = ""; }; + 57D0D1260897B04C231A6991D22E5429 /* WebViewJavascriptBridgeBase.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridgeBase.h; sourceTree = ""; }; + 6D44F90D4EBEFA879E24602D9D112830 /* Pods-ExampleSwiftApp-iOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-ExampleSwiftApp-iOSTests.release.xcconfig"; sourceTree = ""; }; + 6D8F8016ACD01541DE8081F8C58930B7 /* Pods-ExampleSwiftApp-iOSTests-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-ExampleSwiftApp-iOSTests-acknowledgements.markdown"; sourceTree = ""; }; + 710F90291714B9A1D4E8E2967AA7E943 /* Pods-ExampleSwiftApp-iOSTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-ExampleSwiftApp-iOSTests.debug.xcconfig"; sourceTree = ""; }; + 7B0012B4474436C3998A7A0A253BB7FE /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 809AF8CF0188033BFA114CCE00D8B1BE /* WebViewJavascriptBridge-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "WebViewJavascriptBridge-dummy.m"; sourceTree = ""; }; + 80C51525CDB583C0489D564B2B01B11A /* WKWebViewJavascriptBridge.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = WKWebViewJavascriptBridge.h; sourceTree = ""; }; + 81607F20092CACC1394D3DCB7D6993B0 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + 8601B0C4F04E6601DF1E5B029E37AB16 /* WebViewJavascriptBridge-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "WebViewJavascriptBridge-umbrella.h"; sourceTree = ""; }; + 92A1209FAB40669DA320B3F83F0A3933 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 932785F7067BA34CED10E511033B8A87 /* Pods-ExampleSwiftApp-iOS-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-ExampleSwiftApp-iOS-acknowledgements.markdown"; sourceTree = ""; }; + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + 9F83FE7CA7AEEB63554078FAAB16CE8A /* WebViewJavascriptBridge.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = WebViewJavascriptBridge.framework; path = WebViewJavascriptBridge.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + A17E3228DC6A2FAA18E03C30E1780481 /* Pods-ExampleSwiftApp-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-ExampleSwiftApp-iOS.release.xcconfig"; sourceTree = ""; }; + A3E25E1708830CCE4BAB07009465D3A0 /* WebViewJavascriptBridge-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "WebViewJavascriptBridge-prefix.pch"; sourceTree = ""; }; + A8E9C149CADB94BAF0285D8FEC5B4543 /* Pods-ExampleSwiftApp-iOS.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = "Pods-ExampleSwiftApp-iOS.modulemap"; sourceTree = ""; }; + B3B2F31B7B3A2585AC20B9B1315640AF /* Pods-ExampleSwiftApp-iOSTests.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = "Pods-ExampleSwiftApp-iOSTests.modulemap"; sourceTree = ""; }; + C249E5C9809AB24175069C00CD913083 /* Pods-ExampleSwiftApp-iOSTests-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-ExampleSwiftApp-iOSTests-acknowledgements.plist"; sourceTree = ""; }; + C83E0A2774D73C8F7C5A71AE10D90669 /* Pods-ExampleSwiftApp-iOS-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-ExampleSwiftApp-iOS-umbrella.h"; sourceTree = ""; }; + CB0DCBAEC1A0C74D1AFC55D1DA8CB0CC /* Pods-ExampleSwiftApp-iOSTests-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-ExampleSwiftApp-iOSTests-umbrella.h"; sourceTree = ""; }; + CF0C2E9DF0EDC82844031C75B907FD1C /* WKWebViewJavascriptBridge.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = WKWebViewJavascriptBridge.m; sourceTree = ""; }; + D02463846541C58A2828A6072E9B2B9F /* WebViewJavascriptBridge_JS.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge_JS.h; sourceTree = ""; }; + E2A53CC2E9D7695847074947A62978CD /* WebViewJavascriptBridge.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridge.h; sourceTree = ""; }; + EBC2E87E1DCDC145DB442F7AC9CEBB9E /* WebViewJavascriptBridge.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; path = WebViewJavascriptBridge.modulemap; sourceTree = ""; }; + ECBC45CC74132CEFC65377142E782D6C /* WebViewJavascriptBridge_JS.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge_JS.m; sourceTree = ""; }; + F392BCD91CC1BBCBEC3934F857C1D59C /* Pods-ExampleSwiftApp-iOS-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-ExampleSwiftApp-iOS-resources.sh"; sourceTree = ""; }; + F5147AE3C7F8B063B02257EFF0EFD800 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + FE21A82064159C68F43B52C838C010B1 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + FE55E03982FB6FAB2D2EA3B51B77077C /* WebViewJavascriptBridgeBase.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeBase.m; sourceTree = ""; }; + FE6B78215ECE85734B6458DD230E2364 /* WebViewJavascriptBridge.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridge.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 725CFEC49A26DCFA0EE64E353D657C0D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8F33194746E2C7D3D5BFE4E1FA5F8F11 /* Foundation.framework in Frameworks */, + 68865B6F5C4FE0AA46A28DCAC9F4FC2A /* UIKit.framework in Frameworks */, + EA1C1C1CC94437B705A83C5729E9480E /* WebKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 857767A96DDF1BEA80FAB0218D443372 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1CE763074FD41F8F2481F1F218DE4A8D /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 890137DFC8228A2238111729EAD6DCB2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 902762E83E038BF12A45D29D10921D42 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 122DA2E5084A4393C29BE363C764795C /* Frameworks */ = { + isa = PBXGroup; + children = ( + 6FFDF343B465C42F26242933972F7F1D /* iOS */, + ); + name = Frameworks; + sourceTree = ""; + }; + 24A5F2EBAAEACE0915403BD0A61B7BDB /* Development Pods */ = { + isa = PBXGroup; + children = ( + BBA310B35CA03E5C16F75EB829798B19 /* WebViewJavascriptBridge */, + ); + name = "Development Pods"; + sourceTree = ""; + }; + 5F8EB9918E764211737A00481D412C60 /* Pods-ExampleSwiftApp-iOSTests */ = { + isa = PBXGroup; + children = ( + 92A1209FAB40669DA320B3F83F0A3933 /* Info.plist */, + B3B2F31B7B3A2585AC20B9B1315640AF /* Pods-ExampleSwiftApp-iOSTests.modulemap */, + 6D8F8016ACD01541DE8081F8C58930B7 /* Pods-ExampleSwiftApp-iOSTests-acknowledgements.markdown */, + C249E5C9809AB24175069C00CD913083 /* Pods-ExampleSwiftApp-iOSTests-acknowledgements.plist */, + 51187EA2FE506237A47693D319F38538 /* Pods-ExampleSwiftApp-iOSTests-dummy.m */, + 23D3E482532423C6D5312922387BEBC0 /* Pods-ExampleSwiftApp-iOSTests-frameworks.sh */, + 11B2B8BD3820A60AFC145AD769239715 /* Pods-ExampleSwiftApp-iOSTests-resources.sh */, + CB0DCBAEC1A0C74D1AFC55D1DA8CB0CC /* Pods-ExampleSwiftApp-iOSTests-umbrella.h */, + 710F90291714B9A1D4E8E2967AA7E943 /* Pods-ExampleSwiftApp-iOSTests.debug.xcconfig */, + 6D44F90D4EBEFA879E24602D9D112830 /* Pods-ExampleSwiftApp-iOSTests.release.xcconfig */, + ); + name = "Pods-ExampleSwiftApp-iOSTests"; + path = "Target Support Files/Pods-ExampleSwiftApp-iOSTests"; + sourceTree = ""; + }; + 6FFDF343B465C42F26242933972F7F1D /* iOS */ = { + isa = PBXGroup; + children = ( + 81607F20092CACC1394D3DCB7D6993B0 /* Foundation.framework */, + F5147AE3C7F8B063B02257EFF0EFD800 /* UIKit.framework */, + 1FAF4F70740F05FA34D54F1982E18E7A /* WebKit.framework */, + ); + name = iOS; + sourceTree = ""; + }; + 73C16EEBFFA1E1F4F0EAA9E996DDADFE /* Support Files */ = { + isa = PBXGroup; + children = ( + FE21A82064159C68F43B52C838C010B1 /* Info.plist */, + EBC2E87E1DCDC145DB442F7AC9CEBB9E /* WebViewJavascriptBridge.modulemap */, + 074E573B7C4E7956272ECDDD90007364 /* WebViewJavascriptBridge.xcconfig */, + 809AF8CF0188033BFA114CCE00D8B1BE /* WebViewJavascriptBridge-dummy.m */, + A3E25E1708830CCE4BAB07009465D3A0 /* WebViewJavascriptBridge-prefix.pch */, + 8601B0C4F04E6601DF1E5B029E37AB16 /* WebViewJavascriptBridge-umbrella.h */, + ); + name = "Support Files"; + path = "Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge"; + sourceTree = ""; + }; + 78F44B0D402C2970C0507A1D9158BD94 /* Targets Support Files */ = { + isa = PBXGroup; + children = ( + DE0ED14CB65A96D71C44D7BA5782E4C8 /* Pods-ExampleSwiftApp-iOS */, + 5F8EB9918E764211737A00481D412C60 /* Pods-ExampleSwiftApp-iOSTests */, + ); + name = "Targets Support Files"; + sourceTree = ""; + }; + 7DB346D0F39D3F0E887471402A8071AB = { + isa = PBXGroup; + children = ( + 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */, + 24A5F2EBAAEACE0915403BD0A61B7BDB /* Development Pods */, + 122DA2E5084A4393C29BE363C764795C /* Frameworks */, + E6006E29B8A33BE8A154EE70CB02A7D5 /* Products */, + 78F44B0D402C2970C0507A1D9158BD94 /* Targets Support Files */, + ); + sourceTree = ""; + }; + 911475E28609F2390A280F1D8707E180 /* WebViewJavascriptBridge */ = { + isa = PBXGroup; + children = ( + E2A53CC2E9D7695847074947A62978CD /* WebViewJavascriptBridge.h */, + FE6B78215ECE85734B6458DD230E2364 /* WebViewJavascriptBridge.m */, + D02463846541C58A2828A6072E9B2B9F /* WebViewJavascriptBridge_JS.h */, + ECBC45CC74132CEFC65377142E782D6C /* WebViewJavascriptBridge_JS.m */, + 57D0D1260897B04C231A6991D22E5429 /* WebViewJavascriptBridgeBase.h */, + FE55E03982FB6FAB2D2EA3B51B77077C /* WebViewJavascriptBridgeBase.m */, + 80C51525CDB583C0489D564B2B01B11A /* WKWebViewJavascriptBridge.h */, + CF0C2E9DF0EDC82844031C75B907FD1C /* WKWebViewJavascriptBridge.m */, + ); + name = WebViewJavascriptBridge; + path = WebViewJavascriptBridge; + sourceTree = ""; + }; + BBA310B35CA03E5C16F75EB829798B19 /* WebViewJavascriptBridge */ = { + isa = PBXGroup; + children = ( + 73C16EEBFFA1E1F4F0EAA9E996DDADFE /* Support Files */, + 911475E28609F2390A280F1D8707E180 /* WebViewJavascriptBridge */, + ); + name = WebViewJavascriptBridge; + path = ../../..; + sourceTree = ""; + }; + DE0ED14CB65A96D71C44D7BA5782E4C8 /* Pods-ExampleSwiftApp-iOS */ = { + isa = PBXGroup; + children = ( + 7B0012B4474436C3998A7A0A253BB7FE /* Info.plist */, + A8E9C149CADB94BAF0285D8FEC5B4543 /* Pods-ExampleSwiftApp-iOS.modulemap */, + 932785F7067BA34CED10E511033B8A87 /* Pods-ExampleSwiftApp-iOS-acknowledgements.markdown */, + 51711AC3868C2190C69CA4EE14609033 /* Pods-ExampleSwiftApp-iOS-acknowledgements.plist */, + 221FB5C393B5465B754FAF4DC182E72C /* Pods-ExampleSwiftApp-iOS-dummy.m */, + 1E3A50278BA035C069540E5E3AB2AEE1 /* Pods-ExampleSwiftApp-iOS-frameworks.sh */, + F392BCD91CC1BBCBEC3934F857C1D59C /* Pods-ExampleSwiftApp-iOS-resources.sh */, + C83E0A2774D73C8F7C5A71AE10D90669 /* Pods-ExampleSwiftApp-iOS-umbrella.h */, + 31A437740C886407B1BD834E14857AB2 /* Pods-ExampleSwiftApp-iOS.debug.xcconfig */, + A17E3228DC6A2FAA18E03C30E1780481 /* Pods-ExampleSwiftApp-iOS.release.xcconfig */, + ); + name = "Pods-ExampleSwiftApp-iOS"; + path = "Target Support Files/Pods-ExampleSwiftApp-iOS"; + sourceTree = ""; + }; + E6006E29B8A33BE8A154EE70CB02A7D5 /* Products */ = { + isa = PBXGroup; + children = ( + 16E86B5E097D5A8CE34F29BC6EC8562A /* Pods_ExampleSwiftApp_iOS.framework */, + 153E8B22B37A83060A1543A8C162FF14 /* Pods_ExampleSwiftApp_iOSTests.framework */, + 9F83FE7CA7AEEB63554078FAAB16CE8A /* WebViewJavascriptBridge.framework */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 734E3D2EE8FCFD6CEED32749CBAB5966 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 84B65AC46F34EA67BF48C8C3E7E71958 /* WebViewJavascriptBridge-umbrella.h in Headers */, + 45742C8C964B582FE0ADFF2E7905DFF5 /* WebViewJavascriptBridge.h in Headers */, + 934D4692AC47E843BCD0C3B5751BC3E0 /* WebViewJavascriptBridge_JS.h in Headers */, + 970CB101700BE9265F0267146F918345 /* WebViewJavascriptBridgeBase.h in Headers */, + 4250D949ECFC5A97E1770301D77E2605 /* WKWebViewJavascriptBridge.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + BD6C6E2FF5EA299771748CB4DED72704 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + F6693066686B895A8F059D886F82D6A1 /* Pods-ExampleSwiftApp-iOS-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D7AA88A6D68871CED7311BB22AC97F05 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + FF1285970402E7D12FC2D6EBE81D223E /* Pods-ExampleSwiftApp-iOSTests-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + A54833AA1912A64524F87E8A91967601 /* Pods-ExampleSwiftApp-iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = BB29106CFF2F0230123BBB222DBAA8A3 /* Build configuration list for PBXNativeTarget "Pods-ExampleSwiftApp-iOS" */; + buildPhases = ( + A0F68E6ED45928E82301EFB65D08C62D /* Sources */, + 857767A96DDF1BEA80FAB0218D443372 /* Frameworks */, + BD6C6E2FF5EA299771748CB4DED72704 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + 4C41CDA555C81C25F7F723E869937B51 /* PBXTargetDependency */, + ); + name = "Pods-ExampleSwiftApp-iOS"; + productName = "Pods-ExampleSwiftApp-iOS"; + productReference = 16E86B5E097D5A8CE34F29BC6EC8562A /* Pods_ExampleSwiftApp_iOS.framework */; + productType = "com.apple.product-type.framework"; + }; + C1D60A5C9331D2F60A106303D3494E52 /* WebViewJavascriptBridge */ = { + isa = PBXNativeTarget; + buildConfigurationList = 15283965C689D50142F65CC947E95772 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridge" */; + buildPhases = ( + 1C606BE46617D22E9EA0F278CFBBF20D /* Sources */, + 725CFEC49A26DCFA0EE64E353D657C0D /* Frameworks */, + 734E3D2EE8FCFD6CEED32749CBAB5966 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = WebViewJavascriptBridge; + productName = WebViewJavascriptBridge; + productReference = 9F83FE7CA7AEEB63554078FAAB16CE8A /* WebViewJavascriptBridge.framework */; + productType = "com.apple.product-type.framework"; + }; + E44F08A1D65BDBC2B5BCB7C942113B9D /* Pods-ExampleSwiftApp-iOSTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 71C2414272E63AF42549A85955FBFB48 /* Build configuration list for PBXNativeTarget "Pods-ExampleSwiftApp-iOSTests" */; + buildPhases = ( + 79E093A84032034699562712B5C16611 /* Sources */, + 890137DFC8228A2238111729EAD6DCB2 /* Frameworks */, + D7AA88A6D68871CED7311BB22AC97F05 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + A5ECEF2B489E810AD4D19BDA32BD0B6F /* PBXTargetDependency */, + ); + name = "Pods-ExampleSwiftApp-iOSTests"; + productName = "Pods-ExampleSwiftApp-iOSTests"; + productReference = 153E8B22B37A83060A1543A8C162FF14 /* Pods_ExampleSwiftApp_iOSTests.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D41D8CD98F00B204E9800998ECF8427E /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0730; + LastUpgradeCheck = 0700; + }; + buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 7DB346D0F39D3F0E887471402A8071AB; + productRefGroup = E6006E29B8A33BE8A154EE70CB02A7D5 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + A54833AA1912A64524F87E8A91967601 /* Pods-ExampleSwiftApp-iOS */, + E44F08A1D65BDBC2B5BCB7C942113B9D /* Pods-ExampleSwiftApp-iOSTests */, + C1D60A5C9331D2F60A106303D3494E52 /* WebViewJavascriptBridge */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 1C606BE46617D22E9EA0F278CFBBF20D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 64475BD96D86AB0FCCB594C527F1CAB8 /* WebViewJavascriptBridge-dummy.m in Sources */, + 4BB0061F245D474622102084EFAB5BD2 /* WebViewJavascriptBridge.m in Sources */, + 3CB3835FBA4FA17B69633D2A875158DD /* WebViewJavascriptBridge_JS.m in Sources */, + 502A928C6ABAB459D2BA4B139DA6E1B1 /* WebViewJavascriptBridgeBase.m in Sources */, + 8458FF2CDCD670B1FC51A7DDFD08255D /* WKWebViewJavascriptBridge.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 79E093A84032034699562712B5C16611 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 86194B24481631A6A6D0A698889045E3 /* Pods-ExampleSwiftApp-iOSTests-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A0F68E6ED45928E82301EFB65D08C62D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F2BD89AED3B8530725EED73659CD7F72 /* Pods-ExampleSwiftApp-iOS-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 4C41CDA555C81C25F7F723E869937B51 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = WebViewJavascriptBridge; + target = C1D60A5C9331D2F60A106303D3494E52 /* WebViewJavascriptBridge */; + targetProxy = 5FFA8080C4895A871CEA5CBB57781845 /* PBXContainerItemProxy */; + }; + A5ECEF2B489E810AD4D19BDA32BD0B6F /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = WebViewJavascriptBridge; + target = C1D60A5C9331D2F60A106303D3494E52 /* WebViewJavascriptBridge */; + targetProxy = 4CFE87BDA707128AA8A6C5FC0C72AB8C /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 038CE773516022A9EA24BAE86FEE1F0B /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 074E573B7C4E7956272ECDDD90007364 /* WebViewJavascriptBridge.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/WebViewJavascriptBridge/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_NAME = WebViewJavascriptBridge; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 183F4D214A091DB4B17ACFDEC53A6378 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = A17E3228DC6A2FAA18E03C30E1780481 /* Pods-ExampleSwiftApp-iOS.release.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-ExampleSwiftApp-iOS/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_ExampleSwiftApp_iOS; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 4DC1FAB6BB7E21E398D812098E4EA9A6 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 31A437740C886407B1BD834E14857AB2 /* Pods-ExampleSwiftApp-iOS.debug.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-ExampleSwiftApp-iOS/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_ExampleSwiftApp_iOS; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 59B042A655B7C20CBAB90E385BF4E4C7 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_REQUIRED = NO; + COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_DEBUG=1", + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + ONLY_ACTIVE_ARCH = YES; + PROVISIONING_PROFILE_SPECIFIER = NO_SIGNING/; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Debug; + }; + 6D10B2247443F4A32F297F70584B2ECF /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 710F90291714B9A1D4E8E2967AA7E943 /* Pods-ExampleSwiftApp-iOSTests.debug.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-ExampleSwiftApp-iOSTests/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_ExampleSwiftApp_iOSTests; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + A595ED041DAD51092925AD1F85D81823 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 074E573B7C4E7956272ECDDD90007364 /* WebViewJavascriptBridge.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/WebViewJavascriptBridge/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge.modulemap"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_NAME = WebViewJavascriptBridge; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + B7324857C38B065FEB1EEE3105C2367A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGNING_REQUIRED = NO; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_RELEASE=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + PROVISIONING_PROFILE_SPECIFIER = NO_SIGNING/; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + E53ACF0949BA7DC515874F9EBEB78B27 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 6D44F90D4EBEFA879E24602D9D112830 /* Pods-ExampleSwiftApp-iOSTests.release.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = "Target Support Files/Pods-ExampleSwiftApp-iOSTests/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = Pods_ExampleSwiftApp_iOSTests; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 15283965C689D50142F65CC947E95772 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridge" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A595ED041DAD51092925AD1F85D81823 /* Debug */, + 038CE773516022A9EA24BAE86FEE1F0B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 59B042A655B7C20CBAB90E385BF4E4C7 /* Debug */, + B7324857C38B065FEB1EEE3105C2367A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 71C2414272E63AF42549A85955FBFB48 /* Build configuration list for PBXNativeTarget "Pods-ExampleSwiftApp-iOSTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6D10B2247443F4A32F297F70584B2ECF /* Debug */, + E53ACF0949BA7DC515874F9EBEB78B27 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + BB29106CFF2F0230123BBB222DBAA8A3 /* Build configuration list for PBXNativeTarget "Pods-ExampleSwiftApp-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4DC1FAB6BB7E21E398D812098E4EA9A6 /* Debug */, + 183F4D214A091DB4B17ACFDEC53A6378 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */; +} diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Info.plist b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Info.plist new file mode 100644 index 00000000..2243fe6e --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-acknowledgements.markdown b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-acknowledgements.markdown new file mode 100644 index 00000000..ce5d3d20 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-acknowledgements.markdown @@ -0,0 +1,29 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## WebViewJavascriptBridge + +Copyright (c) 2011-2015 Marcus Westin, Antoine Lagadec + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Generated by CocoaPods - https://cocoapods.org diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-acknowledgements.plist b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-acknowledgements.plist new file mode 100644 index 00000000..ec65f732 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-acknowledgements.plist @@ -0,0 +1,61 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2011-2015 Marcus Westin, Antoine Lagadec + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + + License + MIT + Title + WebViewJavascriptBridge + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - https://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-dummy.m b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-dummy.m new file mode 100644 index 00000000..5736c16b --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods_ExampleSwiftApp_iOS : NSObject +@end +@implementation PodsDummy_Pods_ExampleSwiftApp_iOS +@end diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-frameworks.sh b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-frameworks.sh new file mode 100755 index 00000000..43c5de29 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-frameworks.sh @@ -0,0 +1,91 @@ +#!/bin/sh +set -e + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" + +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink "${source}")" + fi + + # use filter instead of exclude so missing patterns dont' throw errors + echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identitiy + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" + /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" + fi +} + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + # Get architectures for current file + archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" + stripped="" + for arch in $archs; do + if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" || exit 1 + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi +} + + +if [[ "$CONFIGURATION" == "Debug" ]]; then + install_framework "$BUILT_PRODUCTS_DIR/WebViewJavascriptBridge/WebViewJavascriptBridge.framework" +fi +if [[ "$CONFIGURATION" == "Release" ]]; then + install_framework "$BUILT_PRODUCTS_DIR/WebViewJavascriptBridge/WebViewJavascriptBridge.framework" +fi diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-resources.sh b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-resources.sh new file mode 100755 index 00000000..25e9d377 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-resources.sh @@ -0,0 +1,96 @@ +#!/bin/sh +set -e + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + +RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt +> "$RESOURCES_TO_COPY" + +XCASSET_FILES=() + +case "${TARGETED_DEVICE_FAMILY}" in + 1,2) + TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" + ;; + 1) + TARGET_DEVICE_ARGS="--target-device iphone" + ;; + 2) + TARGET_DEVICE_ARGS="--target-device ipad" + ;; + *) + TARGET_DEVICE_ARGS="--target-device mac" + ;; +esac + +install_resource() +{ + if [[ "$1" = /* ]] ; then + RESOURCE_PATH="$1" + else + RESOURCE_PATH="${PODS_ROOT}/$1" + fi + if [[ ! -e "$RESOURCE_PATH" ]] ; then + cat << EOM +error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. +EOM + exit 1 + fi + case $RESOURCE_PATH in + *.storyboard) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.xib) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.framework) + echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + ;; + *.xcdatamodel) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" + ;; + *.xcdatamodeld) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" + ;; + *.xcmappingmodel) + echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" + xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" + ;; + *.xcassets) + ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" + XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") + ;; + *) + echo "$RESOURCE_PATH" + echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" + ;; + esac +} + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then + mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi +rm -f "$RESOURCES_TO_COPY" + +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] +then + # Find all other xcassets (this unfortunately includes those of path pods and other targets). + OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) + while read line; do + if [[ $line != "${PODS_ROOT}*" ]]; then + XCASSET_FILES+=("$line") + fi + done <<<"$OTHER_XCASSETS" + + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-umbrella.h b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-umbrella.h new file mode 100644 index 00000000..7d2746cd --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS-umbrella.h @@ -0,0 +1,8 @@ +#ifdef __OBJC__ +#import +#endif + + +FOUNDATION_EXPORT double Pods_ExampleSwiftApp_iOSVersionNumber; +FOUNDATION_EXPORT const unsigned char Pods_ExampleSwiftApp_iOSVersionString[]; + diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.debug.xcconfig b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.debug.xcconfig new file mode 100644 index 00000000..df30848c --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.debug.xcconfig @@ -0,0 +1,9 @@ +ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge/WebViewJavascriptBridge.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "WebViewJavascriptBridge" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.modulemap b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.modulemap new file mode 100644 index 00000000..4ab6cd4c --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.modulemap @@ -0,0 +1,6 @@ +framework module Pods_ExampleSwiftApp_iOS { + umbrella header "Pods-ExampleSwiftApp-iOS-umbrella.h" + + export * + module * { export * } +} diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.release.xcconfig b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.release.xcconfig new file mode 100644 index 00000000..df30848c --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOS/Pods-ExampleSwiftApp-iOS.release.xcconfig @@ -0,0 +1,9 @@ +ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge/WebViewJavascriptBridge.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "WebViewJavascriptBridge" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Info.plist b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Info.plist new file mode 100644 index 00000000..2243fe6e --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-acknowledgements.markdown b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-acknowledgements.markdown new file mode 100644 index 00000000..ce5d3d20 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-acknowledgements.markdown @@ -0,0 +1,29 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## WebViewJavascriptBridge + +Copyright (c) 2011-2015 Marcus Westin, Antoine Lagadec + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Generated by CocoaPods - https://cocoapods.org diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-acknowledgements.plist b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-acknowledgements.plist new file mode 100644 index 00000000..ec65f732 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-acknowledgements.plist @@ -0,0 +1,61 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2011-2015 Marcus Westin, Antoine Lagadec + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + + License + MIT + Title + WebViewJavascriptBridge + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - https://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-dummy.m b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-dummy.m new file mode 100644 index 00000000..ef312438 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods_ExampleSwiftApp_iOSTests : NSObject +@end +@implementation PodsDummy_Pods_ExampleSwiftApp_iOSTests +@end diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-frameworks.sh b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-frameworks.sh new file mode 100755 index 00000000..43c5de29 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-frameworks.sh @@ -0,0 +1,91 @@ +#!/bin/sh +set -e + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" + +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink "${source}")" + fi + + # use filter instead of exclude so missing patterns dont' throw errors + echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identitiy + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" + /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" + fi +} + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + # Get architectures for current file + archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" + stripped="" + for arch in $archs; do + if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" || exit 1 + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi +} + + +if [[ "$CONFIGURATION" == "Debug" ]]; then + install_framework "$BUILT_PRODUCTS_DIR/WebViewJavascriptBridge/WebViewJavascriptBridge.framework" +fi +if [[ "$CONFIGURATION" == "Release" ]]; then + install_framework "$BUILT_PRODUCTS_DIR/WebViewJavascriptBridge/WebViewJavascriptBridge.framework" +fi diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-resources.sh b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-resources.sh new file mode 100755 index 00000000..25e9d377 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-resources.sh @@ -0,0 +1,96 @@ +#!/bin/sh +set -e + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + +RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt +> "$RESOURCES_TO_COPY" + +XCASSET_FILES=() + +case "${TARGETED_DEVICE_FAMILY}" in + 1,2) + TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" + ;; + 1) + TARGET_DEVICE_ARGS="--target-device iphone" + ;; + 2) + TARGET_DEVICE_ARGS="--target-device ipad" + ;; + *) + TARGET_DEVICE_ARGS="--target-device mac" + ;; +esac + +install_resource() +{ + if [[ "$1" = /* ]] ; then + RESOURCE_PATH="$1" + else + RESOURCE_PATH="${PODS_ROOT}/$1" + fi + if [[ ! -e "$RESOURCE_PATH" ]] ; then + cat << EOM +error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. +EOM + exit 1 + fi + case $RESOURCE_PATH in + *.storyboard) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.xib) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" + ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} + ;; + *.framework) + echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + ;; + *.xcdatamodel) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" + ;; + *.xcdatamodeld) + echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" + xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" + ;; + *.xcmappingmodel) + echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" + xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" + ;; + *.xcassets) + ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" + XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") + ;; + *) + echo "$RESOURCE_PATH" + echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" + ;; + esac +} + +mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then + mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi +rm -f "$RESOURCES_TO_COPY" + +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] +then + # Find all other xcassets (this unfortunately includes those of path pods and other targets). + OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) + while read line; do + if [[ $line != "${PODS_ROOT}*" ]]; then + XCASSET_FILES+=("$line") + fi + done <<<"$OTHER_XCASSETS" + + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-umbrella.h b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-umbrella.h new file mode 100644 index 00000000..e20d8d81 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests-umbrella.h @@ -0,0 +1,8 @@ +#ifdef __OBJC__ +#import +#endif + + +FOUNDATION_EXPORT double Pods_ExampleSwiftApp_iOSTestsVersionNumber; +FOUNDATION_EXPORT const unsigned char Pods_ExampleSwiftApp_iOSTestsVersionString[]; + diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.debug.xcconfig b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.debug.xcconfig new file mode 100644 index 00000000..df30848c --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.debug.xcconfig @@ -0,0 +1,9 @@ +ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge/WebViewJavascriptBridge.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "WebViewJavascriptBridge" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.modulemap b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.modulemap new file mode 100644 index 00000000..1eac38ca --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.modulemap @@ -0,0 +1,6 @@ +framework module Pods_ExampleSwiftApp_iOSTests { + umbrella header "Pods-ExampleSwiftApp-iOSTests-umbrella.h" + + export * + module * { export * } +} diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.release.xcconfig b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.release.xcconfig new file mode 100644 index 00000000..df30848c --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/Pods-ExampleSwiftApp-iOSTests/Pods-ExampleSwiftApp-iOSTests.release.xcconfig @@ -0,0 +1,9 @@ +ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge/WebViewJavascriptBridge.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "WebViewJavascriptBridge" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/Info.plist b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/Info.plist new file mode 100644 index 00000000..073e0642 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 5.1.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-dummy.m b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-dummy.m new file mode 100644 index 00000000..6c5914c8 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_WebViewJavascriptBridge : NSObject +@end +@implementation PodsDummy_WebViewJavascriptBridge +@end diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-prefix.pch b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-prefix.pch new file mode 100644 index 00000000..aa992a4a --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ +#import +#endif + diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-umbrella.h b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-umbrella.h new file mode 100644 index 00000000..41f7d8e1 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge-umbrella.h @@ -0,0 +1,11 @@ +#ifdef __OBJC__ +#import +#endif + +#import "WebViewJavascriptBridge.h" +#import "WebViewJavascriptBridgeBase.h" +#import "WKWebViewJavascriptBridge.h" + +FOUNDATION_EXPORT double WebViewJavascriptBridgeVersionNumber; +FOUNDATION_EXPORT const unsigned char WebViewJavascriptBridgeVersionString[]; + diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge.modulemap b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge.modulemap new file mode 100644 index 00000000..e0cccd7e --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge.modulemap @@ -0,0 +1,6 @@ +framework module WebViewJavascriptBridge { + umbrella header "WebViewJavascriptBridge-umbrella.h" + + export * + module * { export * } +} diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge.xcconfig b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge.xcconfig new file mode 100644 index 00000000..bc2e2b7a --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/WebViewJavascriptBridge.xcconfig @@ -0,0 +1,9 @@ +CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/WebViewJavascriptBridge +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" +OTHER_LDFLAGS = -framework "UIKit" -framework "WebKit" +PODS_BUILD_DIR = $BUILD_DIR +PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES diff --git a/Example Apps/ExampleSwiftApp-iOS/echo.html b/Example Apps/ExampleSwiftApp-iOS/echo.html new file mode 100644 index 00000000..b5076d9f --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/echo.html @@ -0,0 +1,33 @@ + + + +

WebViewJavascriptBridgeTests - echo.html

+ + diff --git a/Makefile b/Makefile index db01edac..f070e5d4 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,20 @@ test: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ -destination 'platform=iOS Simulator,name=iPhone 7' + xcodebuild test -workspace Example\ Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace -scheme ExampleSwiftApp-iOS \ + -destination 'platform=iOS Simulator,name=iPhone 7' test-all: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' \ -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' + xcodebuild test -workspace Example\ Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace -scheme ExampleSwiftApp-iOS \ + -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ + -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' \ + -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' - # First, bump podspec version, then commit & create tag: `git tag -a "v5.0.X" -m "Tag v5.0.X" && git push --tags` + # First, bump podspec version, then commit & create tag: `git tag -a "v5.X.Y" -m "Tag v5.X.Y" && git push --tags` pod trunk push --verbose WebViewJavascriptBridge.podspec diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj index 71ffed9e..7b19ed63 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj +++ b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 2C3E7C641C5A928700A1E322 /* WebViewJavascriptBridge_JS.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3E7C5E1C5A928700A1E322 /* WebViewJavascriptBridge_JS.m */; }; 2C3E7C651C5A928700A1E322 /* WebViewJavascriptBridgeBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3E7C601C5A928700A1E322 /* WebViewJavascriptBridgeBase.m */; }; 2C3E7C661C5A928700A1E322 /* WKWebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3E7C621C5A928700A1E322 /* WKWebViewJavascriptBridge.m */; }; + 2C52B1E21E11858800517DAF /* BridgeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C52B1E11E11858800517DAF /* BridgeTests.swift */; }; 2C864FFD1C60FC8A00954B70 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C864FFC1C60FC8A00954B70 /* WebKit.framework */; }; 3D99867E1AE2A3B2001DDA2C /* echo.html in Resources */ = {isa = PBXBuildFile; fileRef = 3D99867D1AE2A3B2001DDA2C /* echo.html */; }; 3D9E5F2F1AE288E5009D1C36 /* BridgeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D9E5F2E1AE288E5009D1C36 /* BridgeTests.m */; }; @@ -40,6 +41,8 @@ 2C3E7C601C5A928700A1E322 /* WebViewJavascriptBridgeBase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeBase.m; sourceTree = ""; }; 2C3E7C611C5A928700A1E322 /* WKWebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewJavascriptBridge.h; sourceTree = ""; }; 2C3E7C621C5A928700A1E322 /* WKWebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WKWebViewJavascriptBridge.m; sourceTree = ""; }; + 2C52B1E01E11858800517DAF /* WebViewJavascriptBridgeTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WebViewJavascriptBridgeTests-Bridging-Header.h"; sourceTree = ""; }; + 2C52B1E11E11858800517DAF /* BridgeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BridgeTests.swift; sourceTree = ""; }; 2C864FFC1C60FC8A00954B70 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; 3D0FE4751AE2886500BB4104 /* WebViewJavascriptBridgeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WebViewJavascriptBridgeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3D0FE47B1AE2886500BB4104 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -115,6 +118,8 @@ children = ( 3D0FE47A1AE2886500BB4104 /* Supporting Files */, 3D9E5F2E1AE288E5009D1C36 /* BridgeTests.m */, + 2C52B1E11E11858800517DAF /* BridgeTests.swift */, + 2C52B1E01E11858800517DAF /* WebViewJavascriptBridgeTests-Bridging-Header.h */, ); path = WebViewJavascriptBridgeTests; sourceTree = ""; @@ -205,6 +210,7 @@ TargetAttributes = { 3D0FE4741AE2886500BB4104 = { CreatedOnToolsVersion = 6.3; + LastSwiftMigration = 0820; TestTargetID = 3DCCF7D51AE28C2900CE7C51; }; 3DCCF7D51AE28C2900CE7C51 = { @@ -259,6 +265,7 @@ 2C3E7C661C5A928700A1E322 /* WKWebViewJavascriptBridge.m in Sources */, 3D9E5F2F1AE288E5009D1C36 /* BridgeTests.m in Sources */, 2C3E7C631C5A928700A1E322 /* WebViewJavascriptBridge.m in Sources */, + 2C52B1E21E11858800517DAF /* BridgeTests.swift in Sources */, 2C3E7C641C5A928700A1E322 /* WebViewJavascriptBridge_JS.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -369,6 +376,7 @@ 3D0FE4821AE2886500BB4104 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -379,6 +387,9 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswestin.WebViewJavascriptBridge.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "WebViewJavascriptBridgeTests/WebViewJavascriptBridgeTests-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebViewJavascriptBridgeTestHost.app/WebViewJavascriptBridgeTestHost"; }; name = Debug; @@ -386,12 +397,15 @@ 3D0FE4831AE2886500BB4104 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = WebViewJavascriptBridgeTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswestin.WebViewJavascriptBridge.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "WebViewJavascriptBridgeTests/WebViewJavascriptBridgeTests-Bridging-Header.h"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebViewJavascriptBridgeTestHost.app/WebViewJavascriptBridgeTestHost"; }; name = Release; diff --git a/Tests/WebViewJavascriptBridgeTestHost/WebViewJavascriptBridgeTestHost-Bridging-Header.h b/Tests/WebViewJavascriptBridgeTestHost/WebViewJavascriptBridgeTestHost-Bridging-Header.h new file mode 100644 index 00000000..40fc7472 --- /dev/null +++ b/Tests/WebViewJavascriptBridgeTestHost/WebViewJavascriptBridgeTestHost-Bridging-Header.h @@ -0,0 +1,13 @@ +// +// AppDelegate-Bridging-Header.h +// WebViewJavascriptBridge +// +// Created by John Marcus Westin on 12/27/16. +// Copyright © 2016 marcuswestin. All rights reserved. +// + +#ifndef AppDelegate_Bridging_Header_h +#define AppDelegate_Bridging_Header_h + + +#endif /* AppDelegate_Bridging_Header_h */ diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.swift b/Tests/WebViewJavascriptBridgeTests/BridgeTests.swift new file mode 100644 index 00000000..3964f6ad --- /dev/null +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.swift @@ -0,0 +1,35 @@ +// +// BridgeTests.swift +// WebViewJavascriptBridge +// +// Created by John Marcus Westin on 12/26/16. +// Copyright © 2016 marcuswestin. All rights reserved. +// + +import XCTest + +class BridgeTests: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + + func testPerformanceExample() { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/Tests/WebViewJavascriptBridgeTests/WebViewJavascriptBridgeTests-Bridging-Header.h b/Tests/WebViewJavascriptBridgeTests/WebViewJavascriptBridgeTests-Bridging-Header.h new file mode 100644 index 00000000..1b2cb5d6 --- /dev/null +++ b/Tests/WebViewJavascriptBridgeTests/WebViewJavascriptBridgeTests-Bridging-Header.h @@ -0,0 +1,4 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index e0995936..9006fa89 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,17 +1,19 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' s.version = '5.1.0' - s.summary = 'An iOS/OSX bridge for sending messages between Obj-C and JavaScript in UIWebViews/WebViews.' + s.summary = 'An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'marcuswestin' => 'marcus.westin@gmail.com' } - s.requires_arc = true s.source = { :git => 'https://github.com/marcuswestin/WebViewJavascriptBridge.git', :tag => 'v'+s.version.to_s } - s.platforms = { :ios => "5.0", :osx => "" } - s.ios.source_files = 'WebViewJavascriptBridge/*.{h,m}' - s.osx.source_files = 'WebViewJavascriptBridge/*.{h,m}' + s.platforms = { :ios => "5.0", :osx => "" } + s.requires_arc = true + + s.ios.source_files = 'WebViewJavascriptBridge/*.{h,m}' s.ios.private_header_files = 'WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h' + s.osx.source_files = 'WebViewJavascriptBridge/*.{h,m}' s.osx.private_header_files = 'WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h' - s.framework = 'WebKit' - s.ios.framework = 'UIKit' + + s.frameworks = 'WebKit' + s.ios.frameworks = 'UIKit', 'WebKit' end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.h index d7a297ab..9790cc82 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.h @@ -33,7 +33,8 @@ @interface WebViewJavascriptBridge : WVJB_WEBVIEW_DELEGATE_INTERFACE -+ (instancetype)bridgeForWebView:(id)webView; ++ (instancetype)bridgeForWebView:(id)webView DEPRECATED_MSG_ATTRIBUTE("Use bridge instead"); ++ (instancetype)bridge:(id)webView; + (void)enableLogging; + (void)setLogMaxLength:(int)length; diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index 4e89898f..292d4b0a 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -36,6 +36,9 @@ + (void)setLogMaxLength:(int)length { } + (instancetype)bridgeForWebView:(id)webView { + return [self bridge:webView]; +} ++ (instancetype)bridge:(id)webView { #if defined supportsWKWebView if ([webView isKindOfClass:[WKWebView class]]) { return (WebViewJavascriptBridge*) [WKWebViewJavascriptBridge bridgeForWebView:webView]; @@ -97,9 +100,9 @@ - (NSString*) _evaluateJavascript:(NSString*)javascriptCommand { return [_webView stringByEvaluatingJavaScriptFromString:javascriptCommand]; } +#if defined WVJB_PLATFORM_OSX /* Platform specific internals: OSX **********************************/ -#if defined WVJB_PLATFORM_OSX - (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView { _webView = webView; @@ -135,9 +138,9 @@ - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary +#elif defined WVJB_PLATFORM_IOS /* Platform specific internals: iOS **********************************/ -#elif defined WVJB_PLATFORM_IOS - (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView { _webView = webView; From 0b7c995915232a40bc0b0fdb13232afe33d6d8b7 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 27 Dec 2016 16:02:42 -0500 Subject: [PATCH 120/158] Implement removeHandler. Fix #118 --- .../ExampleSwiftApp_iOSTests.swift | 32 +++++++++++++++++++ .../WebViewJavascriptBridge.h | 1 + .../WebViewJavascriptBridge.m | 4 +++ 3 files changed, 37 insertions(+) diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift index 97bda1c5..3c95aad4 100644 --- a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift @@ -149,6 +149,7 @@ class ExampleSwiftApp_iOSTests: XCTestCase { loadEchoSample(webView); let callbackInvoked = expectation(description: "Callback invoked") bridge.registerHandler("objcEchoToJs") { (data, responseCallback) in + XCTAssertEqual(data as! NSDictionary, ["foo":"bar"]); responseCallback!(data) } bridge.callHandler("jsRcvResponseTest", data:nil) { (responseData) in @@ -168,6 +169,7 @@ class ExampleSwiftApp_iOSTests: XCTestCase { loadEchoSample(webView); let callbackInvoked = expectation(description: "Callback invoked") bridge.registerHandler("objcEchoToJs") { (data, responseCallback) in + XCTAssertEqual(data as! NSDictionary, ["foo":"bar"]); responseCallback!(data); } bridge.callHandler("jsRcvResponseTest", data:nil) { (responseData) in @@ -176,4 +178,34 @@ class ExampleSwiftApp_iOSTests: XCTestCase { } } + func testRemoveHandler() { + _testRemoveHandler(uiWebView) + _testRemoveHandler(wkWebView) + waitForExpectations(timeout: timeout, handler: nil) + } + func _testRemoveHandler(_ webView: Any) { + loadEchoSample(webView); + let bridge = bridgeForWebView(webView) + let callbackNotInvoked = expectation(description: "Callback invoked") + var count = 0 + bridge.registerHandler("objcEchoToJs") { (data, callback) in + count += 1 + callback!(data) + } + bridge.callHandler("jsRcvResponseTest", data:nil) { (responseData) in + XCTAssertEqual(responseData as! String, "Response from JS"); + bridge.removeHandler("objcEchoToJs") + bridge.callHandler("jsRcvResponseTest", data:nil) { (responseData) in + // Since we have removed the "objcEchoToJs" handler, and since the + // echo.html javascript won't call the response callback until it has + // received a response from "objcEchoToJs", we should never get here + XCTAssert(false) + } + bridge.callHandler("echoHandler", data:nil ) { (responseData) in + XCTAssertEqual(count, 1) + callbackNotInvoked.fulfill() + } + } + } + } diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.h index 9790cc82..1e873be2 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.h @@ -40,6 +40,7 @@ + (void)setLogMaxLength:(int)length; - (void)registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler; +- (void)removeHandler:(NSString*)handlerName; - (void)callHandler:(NSString*)handlerName; - (void)callHandler:(NSString*)handlerName data:(id)data; - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index 292d4b0a..032190d0 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -81,6 +81,10 @@ - (void)registerHandler:(NSString *)handlerName handler:(WVJBHandler)handler { _base.messageHandlers[handlerName] = [handler copy]; } +- (void)removeHandler:(NSString *)handlerName { + [_base.messageHandlers removeObjectForKey:handlerName]; +} + - (void)disableJavscriptAlertBoxSafetyTimeout { [_base disableJavscriptAlertBoxSafetyTimeout]; } From f41faf7620c425d066f6db567575443ecdc093cc Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 27 Dec 2016 16:03:29 -0500 Subject: [PATCH 121/158] v5.1.1 --- Changelog | 5 +++-- WebViewJavascriptBridge.podspec | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index 17be6b6c..af90a6d3 100644 --- a/Changelog +++ b/Changelog @@ -13,8 +13,9 @@ Release Checklist Version History --------------- -Next version -+ Pretty-print json in log messages +v5.1.1 ++ Swift unit tests and examples ++ Implement removeHandler v5.1.0 + A single instantiation function for all webview types. diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 9006fa89..7c94e27f 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '5.1.0' + s.version = '5.1.1' s.summary = 'An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 3ee8b4c5d66f7d62ea65a26df2a3d801ff7e7817 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 27 Dec 2016 16:16:29 -0500 Subject: [PATCH 122/158] Fix automated test, which seemed to be choking on switching platform in between the two test runs. --- Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f070e5d4..dcd10611 100644 --- a/Makefile +++ b/Makefile @@ -8,11 +8,9 @@ test-all: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' \ - -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' + -destination 'platform=iOS Simulator,name=iPhone 7' xcodebuild test -workspace Example\ Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace -scheme ExampleSwiftApp-iOS \ - -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ - -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' \ - -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' + -destination 'platform=iOS Simulator,name=iPhone 7' publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' From 59ce0afb174e210580e3e8fc3f0cf3309b7e6dd3 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 28 Dec 2016 11:42:07 -0500 Subject: [PATCH 123/158] Include xcworkspace for swift example app --- .../contents.xcworkspacedata | 10 ++++++++++ Makefile | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace/contents.xcworkspacedata diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace/contents.xcworkspacedata b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..c6b1391d --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Makefile b/Makefile index dcd10611..11ac8273 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,9 @@ test-all: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' \ - -destination 'platform=iOS Simulator,name=iPhone 7' + -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' xcodebuild test -workspace Example\ Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace -scheme ExampleSwiftApp-iOS \ - -destination 'platform=iOS Simulator,name=iPhone 7' + -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' From 3b34849e637c6518fe7eb74a8a3d411707541395 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 28 Dec 2016 11:46:58 -0500 Subject: [PATCH 124/158] Rename test-all to test-travis-ci to be explicit --- .travis.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d209611b..fa9b45ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: objective-c osx_image: xcode8.2 script: - - make test-all + - make test-travis-ci diff --git a/Makefile b/Makefile index 11ac8273..37726fea 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ test: xcodebuild test -workspace Example\ Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace -scheme ExampleSwiftApp-iOS \ -destination 'platform=iOS Simulator,name=iPhone 7' -test-all: +test-travis-ci: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' \ From 705e813ef1aafda84e3ed6716456ce18926b1d8e Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 28 Dec 2016 12:09:36 -0500 Subject: [PATCH 125/158] Disable travis testing of swift code, since travis is having so many issues doing both tests --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index 37726fea..0aeb1b23 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,6 @@ test-travis-ci: -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' \ -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' - xcodebuild test -workspace Example\ Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace -scheme ExampleSwiftApp-iOS \ - -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' From ee08af5cc137ea2d3195f4fba0fee607c308483e Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 29 Dec 2016 12:14:18 -0500 Subject: [PATCH 126/158] Update to latest recommended xcode settings --- Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj | 3 ++- .../xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj index 7b19ed63..42961e1c 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj +++ b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -205,7 +205,7 @@ 3D0FE4621AE2886400BB4104 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0810; + LastUpgradeCheck = 0820; ORGANIZATIONNAME = marcuswestin; TargetAttributes = { 3D0FE4741AE2886500BB4104 = { @@ -369,6 +369,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme b/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme index ea9272cf..3ef901a9 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme +++ b/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme @@ -1,6 +1,6 @@ Date: Thu, 29 Dec 2016 12:32:54 -0500 Subject: [PATCH 127/158] Fix https webpage loads, and add unit test for this failure case. Fix #256 --- .../BridgeTests.m | 28 +++++++++++++++++-- .../WKWebViewJavascriptBridge.m | 2 +- .../WebViewJavascriptBridge.h | 2 +- .../WebViewJavascriptBridge.m | 4 +-- .../WebViewJavascriptBridgeBase.h | 2 +- .../WebViewJavascriptBridgeBase.m | 7 ++--- 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m index 2b865ca4..a8612b94 100644 --- a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m @@ -14,7 +14,9 @@ static NSString *const echoHandler = @"echoHandler"; @interface BridgeTests : XCTestCase - +@end +@interface TestWebPageLoadDelegate : NSObject +@property XCTestExpectation* expectation; @end @implementation BridgeTests { @@ -57,7 +59,7 @@ static void loadEchoSample(id webView) { [(UIWebView*)webView loadRequest:request]; } -const NSTimeInterval timeoutSec = 100; +const NSTimeInterval timeoutSec = 5; - (void)testInitialization { [self classSpecificTestInitialization:_uiWebView]; @@ -171,4 +173,26 @@ - (void)classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:(id)webVi [callbackInvocked fulfill]; }]; } + +- (void)testWebpageLoad { + TestWebPageLoadDelegate* delegate = [self classSpecificTestWebpageLoad:_uiWebView]; // to retain it +// [self classSpecificTestWebpageLoad:_wkWebView]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; + NSLog(@"Retain delegate %@", delegate); +} +- (TestWebPageLoadDelegate*)classSpecificTestWebpageLoad:(id)webView { + WebViewJavascriptBridge* bridge = [self bridgeForWebView:webView]; + TestWebPageLoadDelegate* delegate = [TestWebPageLoadDelegate new]; + delegate.expectation = [self expectationWithDescription:@"Webpage loaded"]; + [bridge setWebViewDelegate:delegate]; + NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://example.com"]]; + [(UIWebView*)webView loadRequest:request]; + return delegate; +} +@end + +@implementation TestWebPageLoadDelegate +- (void)webViewDidFinishLoad:(UIWebView *)webView { + [self.expectation fulfill]; +} @end diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index e4a64adf..e9baea9f 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -134,7 +134,7 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati NSURL *url = navigationAction.request.URL; __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; - if ([_base isCorrectProcotocolScheme:url]) { + if ([_base isWebViewJavascriptBridgeURL:url]) { if ([_base isBridgeLoadedURL:url]) { [_base injectJavascriptFile]; } else if ([_base isQueueMessageURL:url]) { diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.h index 1e873be2..1b64bb4e 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.h @@ -33,7 +33,7 @@ @interface WebViewJavascriptBridge : WVJB_WEBVIEW_DELEGATE_INTERFACE -+ (instancetype)bridgeForWebView:(id)webView DEPRECATED_MSG_ATTRIBUTE("Use bridge instead"); ++ (instancetype)bridgeForWebView:(id)webView; + (instancetype)bridge:(id)webView; + (void)enableLogging; diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m index 032190d0..e74a6e24 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -123,7 +123,7 @@ - (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary if (webView != _webView) { return; } NSURL *url = [request URL]; - if ([_base isCorrectProcotocolScheme:url]) { + if ([_base isWebViewJavascriptBridgeURL:url]) { if ([_base isBridgeLoadedURL:url]) { [_base injectJavascriptFile]; } else if ([_base isQueueMessageURL:url]) { @@ -180,7 +180,7 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *) NSURL *url = [request URL]; __strong WVJB_WEBVIEW_DELEGATE_TYPE* strongDelegate = _webViewDelegate; - if ([_base isCorrectProcotocolScheme:url]) { + if ([_base isWebViewJavascriptBridgeURL:url]) { if ([_base isBridgeLoadedURL:url]) { [_base injectJavascriptFile]; } else if ([_base isQueueMessageURL:url]) { diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h index 6fc37a76..9008aa61 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -34,7 +34,7 @@ typedef NSDictionary WVJBMessage; - (void)sendData:(id)data responseCallback:(WVJBResponseCallback)responseCallback handlerName:(NSString*)handlerName; - (void)flushMessageQueue:(NSString *)messageQueueString; - (void)injectJavascriptFile; -- (BOOL)isCorrectProcotocolScheme:(NSURL*)url; +- (BOOL)isWebViewJavascriptBridgeURL:(NSURL*)url; - (BOOL)isQueueMessageURL:(NSURL*)urll; - (BOOL)isBridgeLoadedURL:(NSURL*)urll; - (void)logUnkownMessage:(NSURL*)url; diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index 42261cbc..9ff3d482 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -122,12 +122,11 @@ - (void)injectJavascriptFile { } } -- (BOOL)isCorrectProcotocolScheme:(NSURL*)url { - if([[url scheme] isEqualToString:kCustomProtocolScheme]){ - return YES; - } else { +- (BOOL)isWebViewJavascriptBridgeURL:(NSURL*)url { + if (![[url scheme] isEqualToString:kCustomProtocolScheme]){ return NO; } + return ([self isBridgeLoadedURL:url] || [self isQueueMessageURL:url]); } - (BOOL)isQueueMessageURL:(NSURL*)url { From 80f150ba79728d417ab30d84c1d5d6078ed720c4 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 29 Dec 2016 12:37:45 -0500 Subject: [PATCH 128/158] Also test https page load of WKWebView --- .../BridgeTests.m | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m index a8612b94..3c3d65c7 100644 --- a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m @@ -15,14 +15,14 @@ @interface BridgeTests : XCTestCase @end -@interface TestWebPageLoadDelegate : NSObject +@interface TestWebPageLoadDelegate : NSObject @property XCTestExpectation* expectation; @end @implementation BridgeTests { UIWebView *_uiWebView; WKWebView *_wkWebView; - NSMutableArray* _bridgeRefs; + NSMutableArray* _retains; } - (void)setUp { @@ -39,7 +39,7 @@ - (void)setUp { _wkWebView.backgroundColor = [UIColor redColor]; [rootVC.view addSubview:_wkWebView]; - _bridgeRefs = [NSMutableArray array]; + _retains = [NSMutableArray array]; } - (void)tearDown { @@ -50,7 +50,7 @@ - (void)tearDown { - (WebViewJavascriptBridge*)bridgeForWebView:(id)webView { WebViewJavascriptBridge* bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; - [_bridgeRefs addObject:bridge]; + [_retains addObject:bridge]; return bridge; } @@ -175,19 +175,18 @@ - (void)classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:(id)webVi } - (void)testWebpageLoad { - TestWebPageLoadDelegate* delegate = [self classSpecificTestWebpageLoad:_uiWebView]; // to retain it -// [self classSpecificTestWebpageLoad:_wkWebView]; + [self classSpecificTestWebpageLoad:_uiWebView]; + [self classSpecificTestWebpageLoad:_wkWebView]; [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; - NSLog(@"Retain delegate %@", delegate); } -- (TestWebPageLoadDelegate*)classSpecificTestWebpageLoad:(id)webView { +- (void)classSpecificTestWebpageLoad:(id)webView { WebViewJavascriptBridge* bridge = [self bridgeForWebView:webView]; TestWebPageLoadDelegate* delegate = [TestWebPageLoadDelegate new]; delegate.expectation = [self expectationWithDescription:@"Webpage loaded"]; + [_retains addObject:delegate]; [bridge setWebViewDelegate:delegate]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://example.com"]]; [(UIWebView*)webView loadRequest:request]; - return delegate; } @end @@ -195,4 +194,7 @@ @implementation TestWebPageLoadDelegate - (void)webViewDidFinishLoad:(UIWebView *)webView { [self.expectation fulfill]; } +- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { + [self.expectation fulfill]; +} @end From 55d41e865c534a48bf9ef1f04513b7e5e68d35bf Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 29 Dec 2016 12:38:10 -0500 Subject: [PATCH 129/158] v5.1.2 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 7c94e27f..8743219c 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '5.1.1' + s.version = '5.1.2' s.summary = 'An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 56ad70dd9a66caabd0d490dce405675f0dc6ec9a Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 5 Jan 2017 10:14:53 -0500 Subject: [PATCH 130/158] Add migration a guide note from v5 to v6 --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index ea4186a6..c38d8beb 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,11 @@ WebViewJavascriptBridge An iOS/OSX bridge for sending messages between Obj-C and JavaScript in WKWebViews, UIWebViews & WebViews. +Migration Guide +--------------- + +When upgrading from v5.0.x to 6.0.x you will have to update the `setupWebViewJavascriptBridge` javascript snippet. See https://github.com/marcuswestin/WebViewJavascriptBridge#usage part 4). + Who uses WebViewJavascriptBridge? --------------------------------- WebViewJavascriptBridge is used by a range of companies and projects. This is a small and incomplete sample list: From 492d29f5e023d1706e2637e85268442a4124a22f Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Thu, 5 Jan 2017 10:15:11 -0500 Subject: [PATCH 131/158] v6.0.0 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 8743219c..fb86dd96 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '5.1.2' + s.version = '6.0.0' s.summary = 'An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 08edc4d3a281085665b6f74287cb2c005267ef07 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 10 Jan 2017 16:49:31 -0500 Subject: [PATCH 132/158] Remove unecesary console warnings during testing --- .../WebViewJavascriptBridgeTests/BridgeTests.m | 17 ----------------- Tests/WebViewJavascriptBridgeTests/echo.html | 1 - 2 files changed, 18 deletions(-) diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m index 3c3d65c7..06a139ea 100644 --- a/Tests/WebViewJavascriptBridgeTests/BridgeTests.m +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m @@ -61,23 +61,6 @@ static void loadEchoSample(id webView) { const NSTimeInterval timeoutSec = 5; -- (void)testInitialization { - [self classSpecificTestInitialization:_uiWebView]; - [self classSpecificTestInitialization:_wkWebView]; - [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; -} -- (void)classSpecificTestInitialization:(id)webView { - XCTestExpectation *startup = [self expectationWithDescription:@"Startup completed"]; - WebViewJavascriptBridge *bridge = [self bridgeForWebView:webView]; - [bridge registerHandler:@"Greet" handler:^(id data, WVJBResponseCallback responseCallback) { - XCTAssertEqualObjects(data, @"Hello world"); - [startup fulfill]; - }]; - XCTAssertNotNil(bridge); - - loadEchoSample(webView); -} - - (void)testEchoHandler { [self classSpecificTestEchoHandler:_uiWebView]; [self classSpecificTestEchoHandler:_wkWebView]; diff --git a/Tests/WebViewJavascriptBridgeTests/echo.html b/Tests/WebViewJavascriptBridgeTests/echo.html index b5076d9f..4549722d 100644 --- a/Tests/WebViewJavascriptBridgeTests/echo.html +++ b/Tests/WebViewJavascriptBridgeTests/echo.html @@ -15,7 +15,6 @@ } setupWebViewJavascriptBridge(function(bridge) { - bridge.callHandler('Greet', 'Hello world'); bridge.registerHandler('echoHandler', function(data, responseCallback) { responseCallback(data) }) From d924dccd7608825ac2bc6d37515c37f10cbcbdf2 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 10 Jan 2017 16:49:42 -0500 Subject: [PATCH 133/158] Make v6 backcompatible with v5 --- .../WebViewJavascriptBridgeBase.h | 7 ++++--- .../WebViewJavascriptBridgeBase.m | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h index 9008aa61..54d80acc 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -7,9 +7,10 @@ #import -#define kCustomProtocolScheme @"https" -#define kQueueHasMessage @"__wvjb_queue_message__" -#define kBridgeLoaded @"__bridge_loaded__" +#define kOldProtocolScheme @"wvjbscheme" +#define kNewProtocolScheme @"https" +#define kQueueHasMessage @"__wvjb_queue_message__" +#define kBridgeLoaded @"__bridge_loaded__" typedef void (^WVJBResponseCallback)(id responseData); typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback); diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m index 9ff3d482..3ec26ed4 100755 --- a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -123,22 +123,25 @@ - (void)injectJavascriptFile { } - (BOOL)isWebViewJavascriptBridgeURL:(NSURL*)url { - if (![[url scheme] isEqualToString:kCustomProtocolScheme]){ + if (![self isSchemeMatch:url]) { return NO; } - return ([self isBridgeLoadedURL:url] || [self isQueueMessageURL:url]); + return [self isBridgeLoadedURL:url] || [self isQueueMessageURL:url]; +} + +- (BOOL)isSchemeMatch:(NSURL*)url { + NSString* scheme = url.scheme.lowercaseString; + return [scheme isEqualToString:kNewProtocolScheme] || [scheme isEqualToString:kOldProtocolScheme]; } - (BOOL)isQueueMessageURL:(NSURL*)url { - if([[url host] isEqualToString:kQueueHasMessage]){ - return YES; - } else { - return NO; - } + NSString* host = url.host.lowercaseString; + return [self isSchemeMatch:url] && [host isEqualToString:kQueueHasMessage]; } - (BOOL)isBridgeLoadedURL:(NSURL*)url { - return ([[url scheme] isEqualToString:kCustomProtocolScheme] && [[url host] isEqualToString:kBridgeLoaded]); + NSString* host = url.host.lowercaseString; + return [self isSchemeMatch:url] && [host isEqualToString:kBridgeLoaded]; } - (void)logUnkownMessage:(NSURL*)url { From 1d2ee32a6e3302065de7ee2cb63946e33c6253b1 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 10 Jan 2017 16:50:07 -0500 Subject: [PATCH 134/158] v6.0.1 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index fb86dd96..c50d7b3f 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '6.0.0' + s.version = '6.0.1' s.summary = 'An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From f99c987292f413d1ce4da134e164a6433bc9d3ea Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 10 Jan 2017 16:51:38 -0500 Subject: [PATCH 135/158] Implement removeHandler for WKWebViewJavascriptBridge. Fix #260 --- WebViewJavascriptBridge/WKWebViewJavascriptBridge.h | 1 + WebViewJavascriptBridge/WKWebViewJavascriptBridge.m | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h index c7ca3b83..4e3404fc 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h @@ -21,6 +21,7 @@ + (void)enableLogging; - (void)registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler; +- (void)removeHandler:(NSString*)handlerName; - (void)callHandler:(NSString*)handlerName; - (void)callHandler:(NSString*)handlerName data:(id)data; - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index e9baea9f..47667df6 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -53,6 +53,10 @@ - (void)registerHandler:(NSString *)handlerName handler:(WVJBHandler)handler { _base.messageHandlers[handlerName] = [handler copy]; } +- (void)removeHandler:(NSString *)handlerName { + [_base.messageHandlers removeObjectForKey:handlerName]; +} + - (void)reset { [_base reset]; } From ccf1e937c0a201ae606782d701f7992c22d0949f Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Tue, 10 Jan 2017 16:52:16 -0500 Subject: [PATCH 136/158] v6.0.2 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index c50d7b3f..07f81d98 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '6.0.1' + s.version = '6.0.2' s.summary = 'An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 11d6e6d61ceb1e481c5c7a68be910239a8742148 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Fri, 21 Jul 2017 08:23:26 -0400 Subject: [PATCH 137/158] Add `make test-circle-ci` --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index 0aeb1b23..10ceb0a7 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,13 @@ test-travis-ci: -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' \ -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' +test-circle-ci: + xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ + -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ + -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' \ + -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.1' + + publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' # First, bump podspec version, then commit & create tag: `git tag -a "v5.X.Y" -m "Tag v5.X.Y" && git push --tags` From 9b6598005b67be09ca4b8166691f9d6deaa9a1aa Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Fri, 21 Jul 2017 08:33:06 -0400 Subject: [PATCH 138/158] Update version numbers --- Example Apps/ExampleSwiftApp-iOS/Podfile.lock | 4 ++-- .../Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json | 4 ++-- Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock | 4 ++-- .../Target Support Files/WebViewJavascriptBridge/Info.plist | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Example Apps/ExampleSwiftApp-iOS/Podfile.lock b/Example Apps/ExampleSwiftApp-iOS/Podfile.lock index bfae7841..0f348683 100644 --- a/Example Apps/ExampleSwiftApp-iOS/Podfile.lock +++ b/Example Apps/ExampleSwiftApp-iOS/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - WebViewJavascriptBridge (5.1.0) + - WebViewJavascriptBridge (6.0.2) DEPENDENCIES: - WebViewJavascriptBridge (from `../..`) @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: ../.. SPEC CHECKSUMS: - WebViewJavascriptBridge: 46545f19ee7ccbf7c6b6d60ac32742cb972356a1 + WebViewJavascriptBridge: 791ee0e26d1bf15efe5fb7fb9666a71a19b89d77 PODFILE CHECKSUM: f657cfcc5a24b7c7f0c7781719b73d4a834bc276 diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json b/Example Apps/ExampleSwiftApp-iOS/Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json index 0a01c92d..5fb7055c 100644 --- a/Example Apps/ExampleSwiftApp-iOS/Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json @@ -1,6 +1,6 @@ { "name": "WebViewJavascriptBridge", - "version": "5.1.0", + "version": "6.0.2", "summary": "An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.", "homepage": "https://github.com/marcuswestin/WebViewJavascriptBridge", "license": { @@ -12,7 +12,7 @@ }, "source": { "git": "https://github.com/marcuswestin/WebViewJavascriptBridge.git", - "tag": "v5.1.0" + "tag": "v6.0.2" }, "platforms": { "ios": "5.0", diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock b/Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock index bfae7841..0f348683 100644 --- a/Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock @@ -1,5 +1,5 @@ PODS: - - WebViewJavascriptBridge (5.1.0) + - WebViewJavascriptBridge (6.0.2) DEPENDENCIES: - WebViewJavascriptBridge (from `../..`) @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: ../.. SPEC CHECKSUMS: - WebViewJavascriptBridge: 46545f19ee7ccbf7c6b6d60ac32742cb972356a1 + WebViewJavascriptBridge: 791ee0e26d1bf15efe5fb7fb9666a71a19b89d77 PODFILE CHECKSUM: f657cfcc5a24b7c7f0c7781719b73d4a834bc276 diff --git a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/Info.plist b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/Info.plist index 073e0642..69f0d0ab 100644 --- a/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/Info.plist +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Target Support Files/WebViewJavascriptBridge/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 5.1.0 + 6.0.2 CFBundleSignature ???? CFBundleVersion From 51e56b044de91deb142c98336d9cc5adfcdec573 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Fri, 21 Jul 2017 08:33:23 -0400 Subject: [PATCH 139/158] Add circle.yml for circleci customization --- circle.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 circle.yml diff --git a/circle.yml b/circle.yml new file mode 100644 index 00000000..583080a5 --- /dev/null +++ b/circle.yml @@ -0,0 +1,10 @@ +machine: + xcode: + version: 8.2 +# dependencies: +# override: +# - brew install kylef/formulae/swiftenv +# - swiftenv install 3.0 +test: + override: + - make test-circle-ci From 7c1e677abe27bf635dcdde017a9facf5907e1cbc Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Fri, 21 Jul 2017 08:40:50 -0400 Subject: [PATCH 140/158] Update build badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c38d8beb..5e4368c2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ WebViewJavascriptBridge ======================= -[![Build Status](https://travis-ci.org/marcuswestin/WebViewJavascriptBridge.svg)](https://travis-ci.org/marcuswestin/WebViewJavascriptBridge) +[![Circle CI](https://img.shields.io/circleci/project/github/marcuswestin/WebViewJavascriptBridge.svg)](https://circleci.com/gh/marcuswestin/WebViewJavascriptBridge) An iOS/OSX bridge for sending messages between Obj-C and JavaScript in WKWebViews, UIWebViews & WebViews. From 4a6f59679a1aa58bd977e4518b1a546ecec5a063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=AF=8C=E4=B8=9C?= Date: Wed, 8 Nov 2017 10:03:03 -0600 Subject: [PATCH 141/158] Modify the Installation with CocoaPods (#268) The 'Usage' describes the latest version 6.0.2 and the 'Installation with CocoaPods' installs the version 5.2.0. So, if someone follows the tutor, the Objc will not connect with javascript. The reason is here https://github.com/marcuswestin/WebViewJavascriptBridge/issues/266#issuecomment-280273386 . --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e4368c2..fb14d2de 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Installation (iOS & OSX) Add this to your [podfile](https://guides.cocoapods.org/using/getting-started.html) and run `pod install` to install: ```ruby -`pod 'WebViewJavascriptBridge', '~> 5.0'` +pod 'WebViewJavascriptBridge', '~> 6.0' ``` ### Manual installation From ea4b34364f2c27bab80a19141da2f84db1e0f3ea Mon Sep 17 00:00:00 2001 From: wrlqwe <515045622@qq.com> Date: Wed, 8 Nov 2017 10:06:03 -0600 Subject: [PATCH 142/158] return after decisionHandler called to avoid call it more than once (#296) --- WebViewJavascriptBridge/WKWebViewJavascriptBridge.m | 1 + 1 file changed, 1 insertion(+) diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m index 47667df6..73c923db 100644 --- a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -147,6 +147,7 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati [_base logUnkownMessage:url]; } decisionHandler(WKNavigationActionPolicyCancel); + return; } if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)]) { From e7e734e46c14412b4066b617e95b5252191d0eee Mon Sep 17 00:00:00 2001 From: GaoYu Date: Thu, 9 Nov 2017 00:08:59 +0800 Subject: [PATCH 143/158] fix: pod version (#297) because `WVJBIframe.src = 'https://__bridge_loaded__';` is support 6.0 version, doesn't support 5.0 version. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb14d2de..31ffa5e9 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Installation (iOS & OSX) Add this to your [podfile](https://guides.cocoapods.org/using/getting-started.html) and run `pod install` to install: ```ruby -pod 'WebViewJavascriptBridge', '~> 6.0' +pod 'WebViewJavascriptBridge' ``` ### Manual installation From 039a58d633a34a4ec89b60729610ca49da813a40 Mon Sep 17 00:00:00 2001 From: Lefe Date: Thu, 9 Nov 2017 00:10:41 +0800 Subject: [PATCH 144/158] iOS 11 crash (#305) From ceb68bafb8879a3c6e9ab409aff1a65e4b99b90f Mon Sep 17 00:00:00 2001 From: "gaoliang.miao" Date: Wed, 8 Nov 2017 10:11:11 -0600 Subject: [PATCH 145/158] update: xcode9 runtime crash when invoke decisionHandler twice (#306) From 02d46321c500ebb9dd7da0c3cc2d016e1a81aeb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=9B=E5=8D=9A?= Date: Wed, 8 Nov 2017 10:14:59 -0600 Subject: [PATCH 146/158] Fix crash on iOS11 (#310) From e49d54757d612dad69fbaa6e5706834f3965b235 Mon Sep 17 00:00:00 2001 From: Chaolong Date: Wed, 8 Nov 2017 10:15:27 -0600 Subject: [PATCH 147/158] solve issue for iOS11, crashes when calling decisionHandler twice (#311) From 73833679c63a3e8237fb59d215f9b835bf96ec6a Mon Sep 17 00:00:00 2001 From: Victor Ilyukevich Date: Wed, 8 Nov 2017 08:16:58 -0800 Subject: [PATCH 148/158] Fix "declaration is not a function" warning (#313) --- WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h index 6cb1cb95..9c857f16 100644 --- a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h @@ -1,3 +1,3 @@ #import -NSString * WebViewJavascriptBridge_js(); \ No newline at end of file +NSString * WebViewJavascriptBridge_js(void); From 2333455ea990ce45405e7191d888a28aa18f55e2 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 11:52:24 -0500 Subject: [PATCH 149/158] Upgrade xcode settings, and remove old travis settings --- .travis.yml | 4 ---- Makefile | 13 ++++------- .../project.pbxproj | 22 +++++++++++++++---- .../WebViewJavascriptBridge.xcscheme | 4 +++- 4 files changed, 25 insertions(+), 18 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fa9b45ed..00000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: objective-c -osx_image: xcode8.2 -script: - - make test-travis-ci diff --git a/Makefile b/Makefile index 10ceb0a7..43b92c75 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,15 @@ test: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ - -destination 'platform=iOS Simulator,name=iPhone 7' + -destination 'platform=iOS Simulator,name=iPhone 8' xcodebuild test -workspace Example\ Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace -scheme ExampleSwiftApp-iOS \ - -destination 'platform=iOS Simulator,name=iPhone 7' - -test-travis-ci: - xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ - -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ - -destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' \ - -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.1' + -destination 'platform=iOS Simulator,name=iPhone 8' test-circle-ci: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' \ - -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.1' + -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.1' \ + -destination 'platform=iOS Simulator,name=iPhone 8,OS=11.0' publish-pod: diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj index 42961e1c..763eff7c 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj +++ b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -205,12 +205,12 @@ 3D0FE4621AE2886400BB4104 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0820; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = marcuswestin; TargetAttributes = { 3D0FE4741AE2886500BB4104 = { CreatedOnToolsVersion = 6.3; - LastSwiftMigration = 0820; + LastSwiftMigration = 0900; TestTargetID = 3DCCF7D51AE28C2900CE7C51; }; 3DCCF7D51AE28C2900CE7C51 = { @@ -298,14 +298,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -343,14 +349,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -390,7 +402,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "WebViewJavascriptBridgeTests/WebViewJavascriptBridgeTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebViewJavascriptBridgeTestHost.app/WebViewJavascriptBridgeTestHost"; }; name = Debug; @@ -406,7 +419,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswestin.WebViewJavascriptBridge.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "WebViewJavascriptBridgeTests/WebViewJavascriptBridgeTests-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebViewJavascriptBridgeTestHost.app/WebViewJavascriptBridgeTestHost"; }; name = Release; diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme b/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme index 3ef901a9..0f6982c5 100644 --- a/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme +++ b/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme @@ -1,6 +1,6 @@ Date: Wed, 8 Nov 2017 11:58:15 -0500 Subject: [PATCH 150/158] Fix circleci platform selection --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 43b92c75..ed95171a 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ test-circle-ci: -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' \ -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.1' \ - -destination 'platform=iOS Simulator,name=iPhone 8,OS=11.0' + -destination 'platform=iOS Simulator,name=iPhone 7 Plus,OS=10.2' publish-pod: From 52708d29f2a6e88101e7a9f70c484c522be2faa7 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 12:05:59 -0500 Subject: [PATCH 151/158] Bump circleci xcode version to 9.0 --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 583080a5..af65f786 100644 --- a/circle.yml +++ b/circle.yml @@ -1,6 +1,6 @@ machine: xcode: - version: 8.2 + version: 9.0 # dependencies: # override: # - brew install kylef/formulae/swiftenv From 6864376392b5584b31195342e5f44caa995a4c62 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 12:08:57 -0500 Subject: [PATCH 152/158] Update circleci targets --- Makefile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index ed95171a..e94cb20e 100644 --- a/Makefile +++ b/Makefile @@ -6,11 +6,9 @@ test: test-circle-ci: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ - -destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.4' \ - -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' \ - -destination 'platform=iOS Simulator,name=iPhone 6s,OS=10.1' \ - -destination 'platform=iOS Simulator,name=iPhone 7 Plus,OS=10.2' - + -destination 'platform=iOS Simulator,name=iPhone 5,OS=10.3.1' \ + -destination 'platform=iOS Simulator,name=iPhone X,OS=11.0.1' + publish-pod: # pod trunk register narcvs@gmail.com 'Marcus Westin' --description='MBA/MBP-xyz' From f52c9bb02d1fa1eb36c4bf726ae4c838b86b8b8c Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 12:18:38 -0500 Subject: [PATCH 153/158] Change to iPhone 7 to see if it fixes circleci build error --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e94cb20e..930eb038 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ test: test-circle-ci: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ - -destination 'platform=iOS Simulator,name=iPhone 5,OS=10.3.1' \ + -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.3.1' \ -destination 'platform=iOS Simulator,name=iPhone X,OS=11.0.1' From 3b1a57e75eafd3f9c1005bcd049b208e153ebf26 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 12:21:43 -0500 Subject: [PATCH 154/158] `make test-many` for tests across multiple iphone simulators --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 930eb038..5a89b6ca 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,12 @@ test: xcodebuild test -workspace Example\ Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcworkspace -scheme ExampleSwiftApp-iOS \ -destination 'platform=iOS Simulator,name=iPhone 8' +test-many: + xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ + -destination 'platform=iOS Simulator,name=iPhone 6' \ + -destination 'platform=iOS Simulator,name=iPhone 7' \ + -destination 'platform=iOS Simulator,name=iPhone 8' + test-circle-ci: xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.3.1' \ From a288d8b1ffafd6dce6c0e9f27e7574411993b1d1 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 12:21:50 -0500 Subject: [PATCH 155/158] v6.0.3 --- WebViewJavascriptBridge.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec index 07f81d98..ee75de48 100644 --- a/WebViewJavascriptBridge.podspec +++ b/WebViewJavascriptBridge.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'WebViewJavascriptBridge' - s.version = '6.0.2' + s.version = '6.0.3' s.summary = 'An iOS & OSX bridge for sending messages between Obj-C/Swift and JavaScript in WKWebViews, UIWebViews & WebViews.' s.homepage = 'https://github.com/marcuswestin/WebViewJavascriptBridge' s.license = { :type => 'MIT', :file => 'LICENSE' } From 5dc6a2dc5d3560d9b07226f983ae41fc0dd1633d Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 14:59:26 -0500 Subject: [PATCH 156/158] Update example projects and fix build errors/warnings --- .../ExampleApp-iOS.xcodeproj/project.pbxproj | 61 ------------------- .../project.pbxproj | 14 +++-- .../ExampleSwiftApp_iOSTests.swift | 2 +- 3 files changed, 11 insertions(+), 66 deletions(-) diff --git a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj index d351431a..324a5b06 100644 --- a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj @@ -20,7 +20,6 @@ 2CA0465C1711AC8E006DEE8B /* ExampleApp.html in Resources */ = {isa = PBXBuildFile; fileRef = 2CA0465B1711AC8D006DEE8B /* ExampleApp.html */; }; 2CAB869B1727684300BD9ED1 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2CAB869A1727684300BD9ED1 /* Default-568h@2x.png */; }; 2CEB3EC01602563600548120 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CEB3EBF1602563600548120 /* UIKit.framework */; }; - 6529BCFA17DEACD6F9C2E820 /* Pods_ExampleApp_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 495C20DD246029C0B2405EC9 /* Pods_ExampleApp_iOS.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -49,9 +48,6 @@ 2CEB3EBF1602563600548120 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 2CEB3EC11602563600548120 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 2CEB3EC31602563600548120 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; - 495C20DD246029C0B2405EC9 /* Pods_ExampleApp_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ExampleApp_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 4BCA4425A9554AF93A944458 /* Pods-ExampleApp-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleApp-iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleApp-iOS/Pods-ExampleApp-iOS.debug.xcconfig"; sourceTree = ""; }; - E4F0C608003752F273BB146F /* Pods-ExampleApp-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ExampleApp-iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-ExampleApp-iOS/Pods-ExampleApp-iOS.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -61,7 +57,6 @@ files = ( 0E4E9D4C1A101E0B00043087 /* WebKit.framework in Frameworks */, 2CEB3EC01602563600548120 /* UIKit.framework in Frameworks */, - 6529BCFA17DEACD6F9C2E820 /* Pods_ExampleApp_iOS.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -137,7 +132,6 @@ 2CEB3EBF1602563600548120 /* UIKit.framework */, 2CEB3EC11602563600548120 /* Foundation.framework */, 2CEB3EC31602563600548120 /* CoreGraphics.framework */, - 495C20DD246029C0B2405EC9 /* Pods_ExampleApp_iOS.framework */, ); name = Frameworks; sourceTree = ""; @@ -145,8 +139,6 @@ 81A733051B2F9C5795D856E4 /* Pods */ = { isa = PBXGroup; children = ( - 4BCA4425A9554AF93A944458 /* Pods-ExampleApp-iOS.debug.xcconfig */, - E4F0C608003752F273BB146F /* Pods-ExampleApp-iOS.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -158,12 +150,9 @@ isa = PBXNativeTarget; buildConfigurationList = 2CEB3ED31602563600548120 /* Build configuration list for PBXNativeTarget "ExampleApp-iOS" */; buildPhases = ( - 953B195B62A37FA474FD95D5 /* [CP] Check Pods Manifest.lock */, 2CEB3EB71602563600548120 /* Sources */, 2CEB3EB81602563600548120 /* Frameworks */, 2CEB3EB91602563600548120 /* Resources */, - A9D6EE0CEB388638298EBC18 /* [CP] Embed Pods Frameworks */, - 7E64B37A61F02883676CA89F /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -218,54 +207,6 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - 7E64B37A61F02883676CA89F /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleApp-iOS/Pods-ExampleApp-iOS-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - 953B195B62A37FA474FD95D5 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; - showEnvVarsInLog = 0; - }; - A9D6EE0CEB388638298EBC18 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleApp-iOS/Pods-ExampleApp-iOS-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ 2CEB3EB71602563600548120 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -373,7 +314,6 @@ }; 2CEB3ED41602563600548120 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 4BCA4425A9554AF93A944458 /* Pods-ExampleApp-iOS.debug.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -391,7 +331,6 @@ }; 2CEB3ED51602563600548120 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = E4F0C608003752F273BB146F /* Pods-ExampleApp-iOS.release.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcodeproj/project.pbxproj b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcodeproj/project.pbxproj index e40d422e..51bd94d7 100644 --- a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcodeproj/project.pbxproj +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcodeproj/project.pbxproj @@ -188,10 +188,12 @@ TargetAttributes = { 2CF20A941E12BB3F00D3009D = { CreatedOnToolsVersion = 8.2.1; + LastSwiftMigration = 0910; ProvisioningStyle = Automatic; }; 2CF20AA81E12BB3F00D3009D = { CreatedOnToolsVersion = 8.2.1; + LastSwiftMigration = 0910; ProvisioningStyle = Automatic; TestTargetID = 2CF20A941E12BB3F00D3009D; }; @@ -481,7 +483,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswest.ExampleSwiftApp-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -494,7 +497,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswest.ExampleSwiftApp-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -507,7 +511,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswest.ExampleSwiftApp-iOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ExampleSwiftApp-iOS.app/ExampleSwiftApp-iOS"; }; name = Debug; @@ -521,7 +526,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "in.marcuswest.ExampleSwiftApp-iOSTests"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ExampleSwiftApp-iOS.app/ExampleSwiftApp-iOS"; }; name = Release; diff --git a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift index 3c95aad4..c2a3b31a 100644 --- a/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift @@ -66,7 +66,7 @@ class ExampleSwiftApp_iOSTests: XCTestCase { } func _testSetup(webView: Any) { let setup = self.expectation(description: "Setup completed") - let bridge = self.bridgeForWebView(webView: webView) + let bridge = self.bridgeForWebView(webView) bridge.registerHandler("Greet") { (data, responseCallback) in XCTAssertEqual(data as! String, "Hello world") setup.fulfill() From 903ec069db8fdd58bc7c574d78a76fdf72b99966 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Wed, 8 Nov 2017 15:02:02 -0500 Subject: [PATCH 157/158] Specify how to install latest 6.0 version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31ffa5e9..fb14d2de 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Installation (iOS & OSX) Add this to your [podfile](https://guides.cocoapods.org/using/getting-started.html) and run `pod install` to install: ```ruby -pod 'WebViewJavascriptBridge' +pod 'WebViewJavascriptBridge', '~> 6.0' ``` ### Manual installation From 9a1ae72d99241065cdad6e56f9474c107820e61a Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Sat, 25 Feb 2023 13:34:53 -0500 Subject: [PATCH 158/158] Add COPYRIGHT --- COPYRIGHT | 1 + 1 file changed, 1 insertion(+) create mode 100644 COPYRIGHT diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 00000000..ddda54c3 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1 @@ +Copyright (c) 2023 - Marcus Westin \ No newline at end of file