From 3cc42ec6f1356001172bb0dacd7620751f3b38fb Mon Sep 17 00:00:00 2001 From: liuhl Date: Sat, 19 Apr 2025 15:05:22 +0800 Subject: [PATCH] [fix]some ignore --- .gitignore | 11 + COPYRIGHT | 1 + Changelog | 106 + .../ExampleApp-OSX.xcodeproj/project.pbxproj | 363 ++ Example Apps/ExampleApp-OSX/AppDelegate.h | 15 + Example Apps/ExampleApp-OSX/AppDelegate.m | 131 + .../ExampleApp-OSX/ExampleApp-OSX-Info.plist | 34 + .../ExampleApp-OSX/ExampleApp-OSX-Prefix.pch | 7 + Example Apps/ExampleApp-OSX/MainMenu.xib | 3244 +++++++++++++++++ .../ExampleApp-OSX/en.lproj/Credits.rtf | 29 + .../ExampleApp-OSX/en.lproj/InfoPlist.strings | 2 + Example Apps/ExampleApp-OSX/main.m | 14 + .../ExampleApp-iOS.xcodeproj/project.pbxproj | 372 ++ .../ExampleApp-iOS/Default-568h@2x.png | Bin 0 -> 18594 bytes .../ExampleApp-iOS/ExampleApp-iOS-Info.plist | 36 + .../ExampleApp-iOS/ExampleApp-iOS-Prefix.pch | 14 + .../ExampleApp-iOS/ExampleAppDelegate.h | 5 + .../ExampleApp-iOS/ExampleAppDelegate.m | 30 + .../ExampleUIWebViewController.h | 13 + .../ExampleUIWebViewController.m | 90 + .../ExampleWKWebViewController.h | 14 + .../ExampleWKWebViewController.m | 80 + .../ExampleApp-iOS/en.lproj/InfoPlist.strings | 2 + Example Apps/ExampleApp-iOS/main.m | 26 + Example Apps/ExampleApp.html | 60 + .../project.pbxproj | 568 +++ .../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 | 211 ++ .../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 + LICENSE | 22 + Makefile | 22 + README.md | 238 ++ Roadmap.md | 105 + Tests/Default-568h@2x.png | Bin 0 -> 18594 bytes .../project.pbxproj | 489 +++ .../WebViewJavascriptBridge.xcscheme | 115 + .../AppDelegate.h | 16 + .../AppDelegate.m | 43 + .../Info.plist | 34 + ...JavascriptBridgeTestHost-Bridging-Header.h | 13 + Tests/WebViewJavascriptBridgeTestHost/main.m | 16 + .../BridgeTests.m | 183 + .../BridgeTests.swift | 35 + Tests/WebViewJavascriptBridgeTests/Info.plist | 24 + ...iewJavascriptBridgeTests-Bridging-Header.h | 4 + Tests/WebViewJavascriptBridgeTests/echo.html | 32 + WebViewJavascriptBridge.podspec | 19 + .../WKWebViewJavascriptBridge.h | 34 + .../WKWebViewJavascriptBridge.m | 198 + .../WebViewJavascriptBridge.h | 43 + .../WebViewJavascriptBridge.m | 142 + .../WebViewJavascriptBridgeBase.h | 46 + .../WebViewJavascriptBridgeBase.m | 221 ++ .../WebViewJavascriptBridge_JS.h | 3 + .../WebViewJavascriptBridge_JS.m | 139 + circle.yml | 10 + 93 files changed, 9589 insertions(+) create mode 100644 .gitignore create mode 100644 COPYRIGHT create mode 100644 Changelog create mode 100644 Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj create mode 100644 Example Apps/ExampleApp-OSX/AppDelegate.h create mode 100644 Example Apps/ExampleApp-OSX/AppDelegate.m create mode 100644 Example Apps/ExampleApp-OSX/ExampleApp-OSX-Info.plist create mode 100644 Example Apps/ExampleApp-OSX/ExampleApp-OSX-Prefix.pch create mode 100644 Example Apps/ExampleApp-OSX/MainMenu.xib create mode 100644 Example Apps/ExampleApp-OSX/en.lproj/Credits.rtf create mode 100644 Example Apps/ExampleApp-OSX/en.lproj/InfoPlist.strings create mode 100644 Example Apps/ExampleApp-OSX/main.m create mode 100644 Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj create mode 100644 Example Apps/ExampleApp-iOS/Default-568h@2x.png create mode 100644 Example Apps/ExampleApp-iOS/ExampleApp-iOS-Info.plist create mode 100644 Example Apps/ExampleApp-iOS/ExampleApp-iOS-Prefix.pch create mode 100644 Example Apps/ExampleApp-iOS/ExampleAppDelegate.h create mode 100644 Example Apps/ExampleApp-iOS/ExampleAppDelegate.m create mode 100644 Example Apps/ExampleApp-iOS/ExampleUIWebViewController.h create mode 100644 Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m create mode 100644 Example Apps/ExampleApp-iOS/ExampleWKWebViewController.h create mode 100644 Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m create mode 100644 Example Apps/ExampleApp-iOS/en.lproj/InfoPlist.strings create mode 100644 Example Apps/ExampleApp-iOS/main.m create mode 100644 Example Apps/ExampleApp.html 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 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 Roadmap.md create mode 100644 Tests/Default-568h@2x.png create mode 100644 Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj create mode 100644 Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme create mode 100644 Tests/WebViewJavascriptBridgeTestHost/AppDelegate.h create mode 100644 Tests/WebViewJavascriptBridgeTestHost/AppDelegate.m create mode 100644 Tests/WebViewJavascriptBridgeTestHost/Info.plist create mode 100644 Tests/WebViewJavascriptBridgeTestHost/WebViewJavascriptBridgeTestHost-Bridging-Header.h create mode 100644 Tests/WebViewJavascriptBridgeTestHost/main.m create mode 100644 Tests/WebViewJavascriptBridgeTests/BridgeTests.m create mode 100644 Tests/WebViewJavascriptBridgeTests/BridgeTests.swift create mode 100644 Tests/WebViewJavascriptBridgeTests/Info.plist create mode 100644 Tests/WebViewJavascriptBridgeTests/WebViewJavascriptBridgeTests-Bridging-Header.h create mode 100644 Tests/WebViewJavascriptBridgeTests/echo.html create mode 100644 WebViewJavascriptBridge.podspec create mode 100644 WebViewJavascriptBridge/WKWebViewJavascriptBridge.h create mode 100644 WebViewJavascriptBridge/WKWebViewJavascriptBridge.m create mode 100755 WebViewJavascriptBridge/WebViewJavascriptBridge.h create mode 100755 WebViewJavascriptBridge/WebViewJavascriptBridge.m create mode 100755 WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h create mode 100755 WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m create mode 100644 WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h create mode 100644 WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m create mode 100644 circle.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1aa2a89 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# Mac OS X +*.DS_Store + +# Xcode +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 +*.xcuserstate +*.xcworkspace/ +xcuserdata/ diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 0000000..ddda54c --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1 @@ +Copyright (c) 2023 - Marcus Westin \ No newline at end of file diff --git a/Changelog b/Changelog new file mode 100644 index 0000000..af90a6d --- /dev/null +++ b/Changelog @@ -0,0 +1,106 @@ +WebViewJavascriptBridge Changelog +================================= + +Release Checklist +----------------- +- gitu-update +- Note Changelog +- Bump `WebViewJavascriptBridge.podspec` version "X.Y.Z" +- gitm-commit "vX.Y.Z" +- gitt-tag "vX.Y.Z" +- pod trunk push + +Version History +--------------- + +v5.1.1 ++ Swift unit tests and examples ++ Implement removeHandler + +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). + +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. + +v5.0.1 ++ 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 ++ Significantly simplified and improved wvjb load detection ++ Simplify API by focusing on explicitly named handlers instead of a default handler and plain `send`. + +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. + +v4.1.3 ++ Update podspec file with tag + +v4.1.2 ++ Fix bug: webViewDidStart/FinishLoad were called twice and isLoading was always true (#86) + +v4.1.1 ++ Better JS initialization script (thank @refractalize!) ++ When passing nil to an objc response callback, replace it with [NSNull null] (becomes null in js) + +v4.1.0 ++ Allow for sending null/nil data packets ++ Drop support for JSONKit ++ Clean up internal represenation of messages + +v4.0.2 ++ Fix NSInvalidArgumentException: "attempt to insert nil object" when using shorthand -callHandler: ++ Fix sending messages including __WVJB_MESSAGE_SEPERATOR__ string + +v4.0.1 ++ Fix detection of arc_weak support + +v4.0.0 ++ Consolidate platform-specific code into a single WebViewJavascriptBridge.m/h using macros (57ee322a4c5310eadd28b28f4d8522cd54123301) ++ Bugfix: Don't make navigation decisions for webviews we don't control (254ea00267f8c1e03727885f4e1e0fd5f5c78be8) + +v3.1.0 ++ Dont inject the WVJB bridge until all requests have finished loading (61b853) ++ Add podspec file (818d49cfc) ++ Memory leaks fixed (b06988f1, 20ce1b0b) ++ New major contributor @peyton! + +v3.0.0 ++ OSX Support ++ New major contributor @oakho! + +v2.1.2 ++ Copy handler and response blocks + +v2.1.1 ++ Handle edge cases gracefully (e.g. don't crash on unknown command or unexpected response) + +v2.1.0 ++ Remove WVJBResponse object and the notion of responding with an error. See 4ab41bb4d7. + +v2.0.0 ++ Messages are objects instead of strings. Supports NSDictionary*/Objects, NSArray*/Arrays, NSNumber*/Number & NSString*/String. ++ Messages are encoded with NSJSONSerialization. Optional fallback to JSONKit for iOS 4 support. ++ Messages can expect responses. A message received with an expected response is accompanied by a WVJBResponse* object. ++ Handlers can be registered by name, and called with data and an optional expected response. ++ Responses expect either an error or data (`-(void)respond:(id)data`, -(void)respondWithError:(id)error) + +v0.0.1 ++ ObjC: A WebViewJavascriptBridge class (a UIWebViewDelegate) that enables message passing to and from the JS ++ ObjC: A protocol called WebViewJavascriptBridgeDelegate that lets you handle messages received from the JS ++ JS: Event when the bridge is ready - document.addEventListener('WebViewJavascriptBridgeReady', function() {}, false) ++ JS: Ability to set your message handler - WebViewJavascriptBridge.setMessageHandler(function() {}) ++ JS: Function to send messages - WebViewJavascriptBridge.sendMessage('a message'); ++ All messages are strings. Use JSON in your js and e.g. JSONKit in iOS to send structured messages diff --git a/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj new file mode 100644 index 0000000..d08ca0a --- /dev/null +++ b/Example Apps/ExampleApp-OSX.xcodeproj/project.pbxproj @@ -0,0 +1,363 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 0ECB01491A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 0ECB01461A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.m */; }; + 0ECB014A1A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 0ECB01481A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.m */; }; + 2C136A2517641106004C7401 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C136A2417641106004C7401 /* Cocoa.framework */; }; + 2C136A2F17641106004C7401 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2C136A2D17641106004C7401 /* InfoPlist.strings */; }; + 2C136A3117641106004C7401 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C136A3017641106004C7401 /* main.m */; }; + 2C136A3517641106004C7401 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 2C136A3317641106004C7401 /* Credits.rtf */; }; + 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 */; }; + 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 */ + +/* Begin PBXFileReference section */ + 0ECB01451A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridgeBase.h; sourceTree = ""; }; + 0ECB01461A0EEB3A0037FF4E /* WebViewJavascriptBridgeBase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeBase.m; sourceTree = ""; }; + 0ECB01471A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewJavascriptBridge.h; sourceTree = ""; }; + 0ECB01481A0EEB3A0037FF4E /* WKWebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WKWebViewJavascriptBridge.m; sourceTree = ""; }; + 2C136A2117641106004C7401 /* ExampleApp-OSX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ExampleApp-OSX.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 2C136A2417641106004C7401 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + 2C136A2717641106004C7401 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; + 2C136A2817641106004C7401 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; + 2C136A2917641106004C7401 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 2C136A2C17641106004C7401 /* ExampleApp-OSX-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ExampleApp-OSX-Info.plist"; sourceTree = ""; }; + 2C136A2E17641106004C7401 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 2C136A3017641106004C7401 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 2C136A3217641106004C7401 /* ExampleApp-OSX-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ExampleApp-OSX-Prefix.pch"; sourceTree = ""; }; + 2C136A3417641106004C7401 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = ""; }; + 2C136A3617641106004C7401 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 2C136A3717641106004C7401 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 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 = ""; }; + 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 */ + +/* Begin PBXFrameworksBuildPhase section */ + 2C136A1E17641106004C7401 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 2C136A4217641236004C7401 /* WebKit.framework in Frameworks */, + 2C136A2517641106004C7401 /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2C136A1817641106004C7401 = { + isa = PBXGroup; + children = ( + 2C136A4117641236004C7401 /* WebKit.framework */, + 2C136A2A17641106004C7401 /* ExampleApp-OSX */, + 2C136A2317641106004C7401 /* Frameworks */, + 2C136A2217641106004C7401 /* Products */, + ); + sourceTree = ""; + }; + 2C136A2217641106004C7401 /* Products */ = { + isa = PBXGroup; + children = ( + 2C136A2117641106004C7401 /* ExampleApp-OSX.app */, + ); + name = Products; + sourceTree = ""; + }; + 2C136A2317641106004C7401 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 2C136A2417641106004C7401 /* Cocoa.framework */, + 2C136A2617641106004C7401 /* Other Frameworks */, + ); + name = Frameworks; + sourceTree = ""; + }; + 2C136A2617641106004C7401 /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 2C136A2717641106004C7401 /* AppKit.framework */, + 2C136A2817641106004C7401 /* CoreData.framework */, + 2C136A2917641106004C7401 /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 2C136A2A17641106004C7401 /* ExampleApp-OSX */ = { + isa = PBXGroup; + children = ( + 2C136A3617641106004C7401 /* AppDelegate.h */, + 2C136A3717641106004C7401 /* AppDelegate.m */, + 2C136A5917642704004C7401 /* ExampleApp.html */, + 2CF17F5217D8AACF006E828B /* MainMenu.xib */, + 2C1562C1176BA9FF00B4AE50 /* WebViewJavascriptBridge */, + 2C136A2B17641106004C7401 /* Supporting Files */, + ); + path = "ExampleApp-OSX"; + sourceTree = ""; + }; + 2C136A2B17641106004C7401 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 2C136A2C17641106004C7401 /* ExampleApp-OSX-Info.plist */, + 2C136A2D17641106004C7401 /* InfoPlist.strings */, + 2C136A3017641106004C7401 /* main.m */, + 2C136A3217641106004C7401 /* ExampleApp-OSX-Prefix.pch */, + 2C136A3317641106004C7401 /* Credits.rtf */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 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 */, + 2C1562C4176BA9FF00B4AE50 /* WebViewJavascriptBridge.m */, + ); + name = WebViewJavascriptBridge; + path = ../../WebViewJavascriptBridge; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 2C136A2017641106004C7401 /* ExampleApp-OSX */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2C136A3E17641106004C7401 /* Build configuration list for PBXNativeTarget "ExampleApp-OSX" */; + buildPhases = ( + 2C136A1D17641106004C7401 /* Sources */, + 2C136A1E17641106004C7401 /* Frameworks */, + 2C136A1F17641106004C7401 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "ExampleApp-OSX"; + productName = "ExampleApp-OSX"; + productReference = 2C136A2117641106004C7401 /* ExampleApp-OSX.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 2C136A1917641106004C7401 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0810; + ORGANIZATIONNAME = "Marcus Westin"; + }; + buildConfigurationList = 2C136A1C17641106004C7401 /* Build configuration list for PBXProject "ExampleApp-OSX" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 2C136A1817641106004C7401; + productRefGroup = 2C136A2217641106004C7401 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 2C136A2017641106004C7401 /* ExampleApp-OSX */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 2C136A1F17641106004C7401 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2C136A2F17641106004C7401 /* InfoPlist.strings in Resources */, + 2C136A3517641106004C7401 /* Credits.rtf in Resources */, + 2C136A5A17642704004C7401 /* ExampleApp.html in Resources */, + 2CF17F5317D8AACF006E828B /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 2C136A1D17641106004C7401 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + 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 */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 2C136A2D17641106004C7401 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 2C136A2E17641106004C7401 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 2C136A3317641106004C7401 /* Credits.rtf */ = { + isa = PBXVariantGroup; + children = ( + 2C136A3417641106004C7401 /* en */, + ); + name = Credits.rtf; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 2C136A3C17641106004C7401 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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", + "$(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; + MACOSX_DEPLOYMENT_TARGET = 10.8; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 2C136A3D17641106004C7401 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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; + }; + name = Release; + }; + 2C136A3F17641106004C7401 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + 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; + }; + name = Debug; + }; + 2C136A4017641106004C7401 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + 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; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2C136A1C17641106004C7401 /* Build configuration list for PBXProject "ExampleApp-OSX" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2C136A3C17641106004C7401 /* Debug */, + 2C136A3D17641106004C7401 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2C136A3E17641106004C7401 /* Build configuration list for PBXNativeTarget "ExampleApp-OSX" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2C136A3F17641106004C7401 /* Debug */, + 2C136A4017641106004C7401 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 2C136A1917641106004C7401 /* Project object */; +} diff --git a/Example Apps/ExampleApp-OSX/AppDelegate.h b/Example Apps/ExampleApp-OSX/AppDelegate.h new file mode 100644 index 0000000..6d91daf --- /dev/null +++ b/Example Apps/ExampleApp-OSX/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// ExampleApp-OSX +// +// Created by Marcus Westin on 6/8/13. +// Copyright (c) 2013 Marcus Westin. All rights reserved. +// + +#import + +@interface AppDelegate : NSObject + +@property (assign) IBOutlet NSWindow *window; + +@end diff --git a/Example Apps/ExampleApp-OSX/AppDelegate.m b/Example Apps/ExampleApp-OSX/AppDelegate.m new file mode 100644 index 0000000..5677342 --- /dev/null +++ b/Example Apps/ExampleApp-OSX/AppDelegate.m @@ -0,0 +1,131 @@ +// +// AppDelegate.m +// ExampleApp-OSX +// +// Created by Marcus Westin on 6/8/13. +// Copyright (c) 2013 Marcus Westin. All rights reserved. +// + +#import "AppDelegate.h" +#import +#import "WebViewJavascriptBridge.h" + +@implementation AppDelegate { + WebView* _webView; + WKWebView *_WKWebView; + WebViewJavascriptBridge* _bridge; + WebViewJavascriptBridge* _WKBridge; + NSView* _WKWebViewWrapper; +} + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification +{ + [self _createViews]; + [self _configureWebview]; + [self _configureWKWebview]; +} + +- (void)_configureWebview { + // Create Bridge + _bridge = [WebViewJavascriptBridge bridgeForWebView:_webView]; + + [_bridge registerHandler:@"testObjcCallback" handler:^(id data, WVJBResponseCallback responseCallback) { + NSLog(@"testObjcCallback called: %@", data); + responseCallback(@"Response from testObjcCallback"); + }]; + + [_bridge callHandler:@"testJavascriptHandler" data:@{ @"foo":@"before ready" }]; + + // Create Buttons + NSButton *callbackButton = [[NSButton alloc] initWithFrame:NSMakeRect(5, 0, 120, 40)]; + [callbackButton setTitle:@"Call handler"]; + [callbackButton setBezelStyle:NSRoundedBezelStyle]; + [callbackButton setTarget:self]; + [callbackButton setAction:@selector(_callHandler)]; + [_webView addSubview:callbackButton]; + + NSButton *webViewToggleButton = [[NSButton alloc] initWithFrame:NSMakeRect(120, 0, 180, 40)]; + [webViewToggleButton setTitle:@"Switch to WKWebView"]; + [webViewToggleButton setBezelStyle:NSRoundedBezelStyle]; + [webViewToggleButton setTarget:self]; + [webViewToggleButton setAction:@selector(_toggleExample)]; + [_webView addSubview:webViewToggleButton]; + + + // Load Page + NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"ExampleApp" ofType:@"html"]; + NSString* html = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil]; + NSURL *baseURL = [NSURL fileURLWithPath:htmlPath]; + [[_webView mainFrame] loadHTMLString:html baseURL: baseURL]; +} + + +- (void)_configureWKWebview { + // Create Bridge + _WKBridge = [WebViewJavascriptBridge bridgeForWebView:_WKWebView]; + + [_WKBridge registerHandler:@"testObjcCallback" handler:^(id data, WVJBResponseCallback responseCallback) { + NSLog(@"testObjcCallback called: %@", data); + responseCallback(@"Response from testObjcCallback"); + }]; + + [_WKBridge callHandler:@"testJavascriptHandler" data:@{ @"foo":@"before ready" }]; + + // Create Buttons + NSButton *callbackButton = [[NSButton alloc] initWithFrame:NSMakeRect(5, 0, 120, 40)]; + [callbackButton setTitle:@"Call handler"]; + [callbackButton setBezelStyle:NSRoundedBezelStyle]; + [callbackButton setTarget:self]; + [callbackButton setAction:@selector(_WKCallHandler)]; + [_WKWebView addSubview:callbackButton]; + + NSButton *webViewToggleButton = [[NSButton alloc] initWithFrame:NSMakeRect(120, 0, 180, 40)]; + [webViewToggleButton setTitle:@"Switch to WebView"]; + [webViewToggleButton setBezelStyle:NSRoundedBezelStyle]; + [webViewToggleButton setTarget:self]; + [webViewToggleButton setAction:@selector(_toggleExample)]; + [_WKWebView addSubview:webViewToggleButton]; + + // Load Page + NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"ExampleApp" ofType:@"html"]; + NSString* html = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil]; + NSURL *baseURL = [NSURL fileURLWithPath:htmlPath]; + [_WKWebView loadHTMLString:html baseURL:baseURL]; +} + +-(void)_toggleExample { + _WKWebView.hidden = !_WKWebView.isHidden; + _webView.hidden = !_webView.isHidden; +} + +- (void)_callHandler { + id data = @{ @"greetingFromObjC": @"Hi there, JS!" }; + [_bridge callHandler:@"testJavascriptHandler" data:data responseCallback:^(id response) { + NSLog(@"testJavascriptHandler responded: %@", response); + }]; +} + +- (void)_WKCallHandler { + id data = @{ @"greetingFromObjC": @"Hi there, JS!" }; + [_WKBridge callHandler:@"testJavascriptHandler" data:data responseCallback:^(id response) { + NSLog(@"testJavascriptHandler responded: %@", response); + }]; +} + +- (void)_createViews { + NSView* contentView = _window.contentView; + // WebView + _webView = [[WebView alloc] initWithFrame:contentView.frame]; + [_webView setAutoresizingMask:(NSViewHeightSizable | NSViewWidthSizable)]; + _webView.hidden = YES; + + // WKWebView + _WKWebView = [[WKWebView alloc] initWithFrame:contentView.frame]; + [_WKWebView setAutoresizingMask:(NSViewHeightSizable | NSViewWidthSizable)]; + + [contentView addSubview:_WKWebView]; + [contentView addSubview:_webView]; +} + + +@end diff --git a/Example Apps/ExampleApp-OSX/ExampleApp-OSX-Info.plist b/Example Apps/ExampleApp-OSX/ExampleApp-OSX-Info.plist new file mode 100644 index 0000000..b9f1fea --- /dev/null +++ b/Example Apps/ExampleApp-OSX/ExampleApp-OSX-Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSMinimumSystemVersion + ${MACOSX_DEPLOYMENT_TARGET} + NSHumanReadableCopyright + Copyright © 2013 Marcus Westin. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/Example Apps/ExampleApp-OSX/ExampleApp-OSX-Prefix.pch b/Example Apps/ExampleApp-OSX/ExampleApp-OSX-Prefix.pch new file mode 100644 index 0000000..32daebd --- /dev/null +++ b/Example Apps/ExampleApp-OSX/ExampleApp-OSX-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'ExampleApp-OSX' target in the 'ExampleApp-OSX' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/Example Apps/ExampleApp-OSX/MainMenu.xib b/Example Apps/ExampleApp-OSX/MainMenu.xib new file mode 100644 index 0000000..7dd4923 --- /dev/null +++ b/Example Apps/ExampleApp-OSX/MainMenu.xib @@ -0,0 +1,3244 @@ + + + + 1070 + 11E53 + 2844 + 1138.47 + 569.00 + + 2844 + 1810 + + + NSCustomObject + NSMenu + NSMenuItem + NSView + NSWindowTemplate + WebView + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.WebKitIBPlugin + + + PluginDependencyRecalculationVersion + + + + + NSApplication + + + FirstResponder + + + NSApplication + + + AMainMenu + + + + ExampleApp-OSX + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + ExampleApp-OSX + + + + About ExampleApp-OSX + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Preferences… + , + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Services + + 1048576 + 2147483647 + + + submenuAction: + + Services + + _NSServicesMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Hide ExampleApp-OSX + h + 1048576 + 2147483647 + + + + + + Hide Others + h + 1572864 + 2147483647 + + + + + + Show All + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Quit ExampleApp-OSX + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + + File + + 1048576 + 2147483647 + + + submenuAction: + + File + + + + New + n + 1048576 + 2147483647 + + + + + + Open… + o + 1048576 + 2147483647 + + + + + + Open Recent + + 1048576 + 2147483647 + + + submenuAction: + + Open Recent + + + + Clear Menu + + 1048576 + 2147483647 + + + + + _NSRecentDocumentsMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Close + w + 1048576 + 2147483647 + + + + + + Save… + s + 1048576 + 2147483647 + + + + + + Revert to Saved + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Page Setup... + P + 1179648 + 2147483647 + + + + + + + Print… + p + 1048576 + 2147483647 + + + + + + + + + Edit + + 1048576 + 2147483647 + + + submenuAction: + + Edit + + + + Undo + z + 1048576 + 2147483647 + + + + + + Redo + Z + 1179648 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Cut + x + 1048576 + 2147483647 + + + + + + Copy + c + 1048576 + 2147483647 + + + + + + Paste + v + 1048576 + 2147483647 + + + + + + Paste and Match Style + V + 1572864 + 2147483647 + + + + + + Delete + + 1048576 + 2147483647 + + + + + + Select All + a + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Find + + 1048576 + 2147483647 + + + submenuAction: + + Find + + + + Find… + f + 1048576 + 2147483647 + + + 1 + + + + Find and Replace… + f + 1572864 + 2147483647 + + + 12 + + + + Find Next + g + 1048576 + 2147483647 + + + 2 + + + + Find Previous + G + 1179648 + 2147483647 + + + 3 + + + + Use Selection for Find + e + 1048576 + 2147483647 + + + 7 + + + + Jump to Selection + j + 1048576 + 2147483647 + + + + + + + + + Spelling and Grammar + + 1048576 + 2147483647 + + + submenuAction: + + Spelling and Grammar + + + + Show Spelling and Grammar + : + 1048576 + 2147483647 + + + + + + Check Document Now + ; + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Check Spelling While Typing + + 1048576 + 2147483647 + + + + + + Check Grammar With Spelling + + 1048576 + 2147483647 + + + + + + Correct Spelling Automatically + + 2147483647 + + + + + + + + + Substitutions + + 1048576 + 2147483647 + + + submenuAction: + + Substitutions + + + + Show Substitutions + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Smart Copy/Paste + f + 1048576 + 2147483647 + + + 1 + + + + Smart Quotes + g + 1048576 + 2147483647 + + + 2 + + + + Smart Dashes + + 2147483647 + + + + + + Smart Links + G + 1179648 + 2147483647 + + + 3 + + + + Text Replacement + + 2147483647 + + + + + + + + + Transformations + + 2147483647 + + + submenuAction: + + Transformations + + + + Make Upper Case + + 2147483647 + + + + + + Make Lower Case + + 2147483647 + + + + + + Capitalize + + 2147483647 + + + + + + + + + Speech + + 1048576 + 2147483647 + + + submenuAction: + + Speech + + + + Start Speaking + + 1048576 + 2147483647 + + + + + + Stop Speaking + + 1048576 + 2147483647 + + + + + + + + + + + + Format + + 2147483647 + + + submenuAction: + + Format + + + + Font + + 2147483647 + + + submenuAction: + + Font + + + + Show Fonts + t + 1048576 + 2147483647 + + + + + + Bold + b + 1048576 + 2147483647 + + + 2 + + + + Italic + i + 1048576 + 2147483647 + + + 1 + + + + Underline + u + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Bigger + + + 1048576 + 2147483647 + + + 3 + + + + Smaller + - + 1048576 + 2147483647 + + + 4 + + + + YES + YES + + + 2147483647 + + + + + + Kern + + 2147483647 + + + submenuAction: + + Kern + + + + Use Default + + 2147483647 + + + + + + Use None + + 2147483647 + + + + + + Tighten + + 2147483647 + + + + + + Loosen + + 2147483647 + + + + + + + + + Ligatures + + 2147483647 + + + submenuAction: + + Ligatures + + + + Use Default + + 2147483647 + + + + + + Use None + + 2147483647 + + + + + + Use All + + 2147483647 + + + + + + + + + Baseline + + 2147483647 + + + submenuAction: + + Baseline + + + + Use Default + + 2147483647 + + + + + + Superscript + + 2147483647 + + + + + + Subscript + + 2147483647 + + + + + + Raise + + 2147483647 + + + + + + Lower + + 2147483647 + + + + + + + + + YES + YES + + + 2147483647 + + + + + + Show Colors + C + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Copy Style + c + 1572864 + 2147483647 + + + + + + Paste Style + v + 1572864 + 2147483647 + + + + + _NSFontMenu + + + + + Text + + 2147483647 + + + submenuAction: + + Text + + + + Align Left + { + 1048576 + 2147483647 + + + + + + Center + | + 1048576 + 2147483647 + + + + + + Justify + + 2147483647 + + + + + + Align Right + } + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Writing Direction + + 2147483647 + + + submenuAction: + + Writing Direction + + + + YES + Paragraph + + 2147483647 + + + + + + CURlZmF1bHQ + + 2147483647 + + + + + + CUxlZnQgdG8gUmlnaHQ + + 2147483647 + + + + + + CVJpZ2h0IHRvIExlZnQ + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + YES + Selection + + 2147483647 + + + + + + CURlZmF1bHQ + + 2147483647 + + + + + + CUxlZnQgdG8gUmlnaHQ + + 2147483647 + + + + + + CVJpZ2h0IHRvIExlZnQ + + 2147483647 + + + + + + + + + YES + YES + + + 2147483647 + + + + + + Show Ruler + + 2147483647 + + + + + + Copy Ruler + c + 1310720 + 2147483647 + + + + + + Paste Ruler + v + 1310720 + 2147483647 + + + + + + + + + + + + View + + 1048576 + 2147483647 + + + submenuAction: + + View + + + + Show Toolbar + t + 1572864 + 2147483647 + + + + + + Customize Toolbar… + + 1048576 + 2147483647 + + + + + + + + + Window + + 1048576 + 2147483647 + + + submenuAction: + + Window + + + + Minimize + m + 1048576 + 2147483647 + + + + + + Zoom + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Bring All to Front + + 1048576 + 2147483647 + + + + + _NSWindowsMenu + + + + + Help + + 2147483647 + + + submenuAction: + + Help + + + + ExampleApp-OSX Help + ? + 1048576 + 2147483647 + + + + + _NSHelpMenu + + + + _NSMainMenu + + + 15 + 2 + {{335, 390}, {480, 360}} + 1954021376 + ExampleApp-OSX + NSWindow + + + + + 256 + {480, 360} + + + + + {{0, 0}, {1280, 778}} + {10000000000000, 10000000000000} + YES + + + AppDelegate + + + NSFontManager + + + + 256 + + Apple HTML pasteboard type + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple URL pasteboard type + Apple Web Archive pasteboard type + NSColor pasteboard type + NSFilenamesPboardType + NSStringPboardType + NeXT RTFD pasteboard type + NeXT Rich Text Format v1.0 pasteboard type + NeXT TIFF v4.0 pasteboard type + WebURLsWithTitlesPboardType + public.png + public.url + public.url-name + + {254, 200} + + + _NS:9 + + + + + + + + + + + YES + YES + + + + + + + terminate: + + + + 449 + + + + orderFrontStandardAboutPanel: + + + + 142 + + + + delegate + + + + 495 + + + + performMiniaturize: + + + + 37 + + + + arrangeInFront: + + + + 39 + + + + print: + + + + 86 + + + + runPageLayout: + + + + 87 + + + + clearRecentDocuments: + + + + 127 + + + + performClose: + + + + 193 + + + + toggleContinuousSpellChecking: + + + + 222 + + + + undo: + + + + 223 + + + + copy: + + + + 224 + + + + checkSpelling: + + + + 225 + + + + paste: + + + + 226 + + + + stopSpeaking: + + + + 227 + + + + cut: + + + + 228 + + + + showGuessPanel: + + + + 230 + + + + redo: + + + + 231 + + + + selectAll: + + + + 232 + + + + startSpeaking: + + + + 233 + + + + delete: + + + + 235 + + + + performZoom: + + + + 240 + + + + performFindPanelAction: + + + + 241 + + + + centerSelectionInVisibleArea: + + + + 245 + + + + toggleGrammarChecking: + + + + 347 + + + + toggleSmartInsertDelete: + + + + 355 + + + + toggleAutomaticQuoteSubstitution: + + + + 356 + + + + toggleAutomaticLinkDetection: + + + + 357 + + + + saveDocument: + + + + 362 + + + + revertDocumentToSaved: + + + + 364 + + + + runToolbarCustomizationPalette: + + + + 365 + + + + toggleToolbarShown: + + + + 366 + + + + hide: + + + + 367 + + + + hideOtherApplications: + + + + 368 + + + + unhideAllApplications: + + + + 370 + + + + newDocument: + + + + 373 + + + + openDocument: + + + + 374 + + + + raiseBaseline: + + + + 426 + + + + lowerBaseline: + + + + 427 + + + + copyFont: + + + + 428 + + + + subscript: + + + + 429 + + + + superscript: + + + + 430 + + + + tightenKerning: + + + + 431 + + + + underline: + + + + 432 + + + + orderFrontColorPanel: + + + + 433 + + + + useAllLigatures: + + + + 434 + + + + loosenKerning: + + + + 435 + + + + pasteFont: + + + + 436 + + + + unscript: + + + + 437 + + + + useStandardKerning: + + + + 438 + + + + useStandardLigatures: + + + + 439 + + + + turnOffLigatures: + + + + 440 + + + + turnOffKerning: + + + + 441 + + + + toggleAutomaticSpellingCorrection: + + + + 456 + + + + orderFrontSubstitutionsPanel: + + + + 458 + + + + toggleAutomaticDashSubstitution: + + + + 461 + + + + toggleAutomaticTextReplacement: + + + + 463 + + + + uppercaseWord: + + + + 464 + + + + capitalizeWord: + + + + 467 + + + + lowercaseWord: + + + + 468 + + + + pasteAsPlainText: + + + + 486 + + + + performFindPanelAction: + + + + 487 + + + + performFindPanelAction: + + + + 488 + + + + performFindPanelAction: + + + + 489 + + + + showHelp: + + + + 493 + + + + alignCenter: + + + + 518 + + + + pasteRuler: + + + + 519 + + + + toggleRuler: + + + + 520 + + + + alignRight: + + + + 521 + + + + copyRuler: + + + + 522 + + + + alignJustified: + + + + 523 + + + + alignLeft: + + + + 524 + + + + makeBaseWritingDirectionNatural: + + + + 525 + + + + makeBaseWritingDirectionLeftToRight: + + + + 526 + + + + makeBaseWritingDirectionRightToLeft: + + + + 527 + + + + makeTextWritingDirectionNatural: + + + + 528 + + + + makeTextWritingDirectionLeftToRight: + + + + 529 + + + + makeTextWritingDirectionRightToLeft: + + + + 530 + + + + performFindPanelAction: + + + + 535 + + + + addFontTrait: + + + + 421 + + + + addFontTrait: + + + + 422 + + + + modifyFont: + + + + 423 + + + + orderFrontFontPanel: + + + + 424 + + + + modifyFont: + + + + 425 + + + + window + + + + 532 + + + + + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 29 + + + + + + + + + + + + + + 19 + + + + + + + + 56 + + + + + + + + 217 + + + + + + + + 83 + + + + + + + + 81 + + + + + + + + + + + + + + + + + 75 + + + + + 78 + + + + + 72 + + + + + 82 + + + + + 124 + + + + + + + + 77 + + + + + 73 + + + + + 79 + + + + + 112 + + + + + 74 + + + + + 125 + + + + + + + + 126 + + + + + 205 + + + + + + + + + + + + + + + + + + + + + + 202 + + + + + 198 + + + + + 207 + + + + + 214 + + + + + 199 + + + + + 203 + + + + + 197 + + + + + 206 + + + + + 215 + + + + + 218 + + + + + + + + 216 + + + + + + + + 200 + + + + + + + + + + + + + 219 + + + + + 201 + + + + + 204 + + + + + 220 + + + + + + + + + + + + + 213 + + + + + 210 + + + + + 221 + + + + + 208 + + + + + 209 + + + + + 57 + + + + + + + + + + + + + + + + + + 58 + + + + + 134 + + + + + 150 + + + + + 136 + + + + + 144 + + + + + 129 + + + + + 143 + + + + + 236 + + + + + 131 + + + + + + + + 149 + + + + + 145 + + + + + 130 + + + + + 24 + + + + + + + + + + + 92 + + + + + 5 + + + + + 239 + + + + + 23 + + + + + 295 + + + + + + + + 296 + + + + + + + + + 297 + + + + + 298 + + + + + 211 + + + + + + + + 212 + + + + + + + + + 195 + + + + + 196 + + + + + 346 + + + + + 348 + + + + + + + + 349 + + + + + + + + + + + + + + 350 + + + + + 351 + + + + + 354 + + + + + 375 + + + + + + + + 376 + + + + + + + + + 377 + + + + + + + + 388 + + + + + + + + + + + + + + + + + + + + + + + 389 + + + + + 390 + + + + + 391 + + + + + 392 + + + + + 393 + + + + + 394 + + + + + 395 + + + + + 396 + + + + + 397 + + + + + + + + 398 + + + + + + + + 399 + + + + + + + + 400 + + + + + 401 + + + + + 402 + + + + + 403 + + + + + 404 + + + + + 405 + + + + + + + + + + + + 406 + + + + + 407 + + + + + 408 + + + + + 409 + + + + + 410 + + + + + 411 + + + + + + + + + + 412 + + + + + 413 + + + + + 414 + + + + + 415 + + + + + + + + + + + 416 + + + + + 417 + + + + + 418 + + + + + 419 + + + + + 420 + + + + + 450 + + + + + + + + 451 + + + + + + + + + + 452 + + + + + 453 + + + + + 454 + + + + + 457 + + + + + 459 + + + + + 460 + + + + + 462 + + + + + 465 + + + + + 466 + + + + + 485 + + + + + 490 + + + + + + + + 491 + + + + + + + + 492 + + + + + 494 + + + + + 496 + + + + + + + + 497 + + + + + + + + + + + + + + + + + 498 + + + + + 499 + + + + + 500 + + + + + 501 + + + + + 502 + + + + + 503 + + + + + + + + 504 + + + + + 505 + + + + + 506 + + + + + 507 + + + + + 508 + + + + + + + + + + + + + + + + 509 + + + + + 510 + + + + + 511 + + + + + 512 + + + + + 513 + + + + + 514 + + + + + 515 + + + + + 516 + + + + + 517 + + + + + 534 + + + + + 544 + + + + + 371 + + + + + + + + 372 + + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{380, 496}, {480, 360}} + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.WebKitIBPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + 559 + + + + + AppDelegate + NSObject + + window + NSWindow + + + window + + window + NSWindow + + + + IBProjectSource + ./Classes/AppDelegate.h + + + + + 0 + IBCocoaFramework + YES + 3 + + {11, 11} + {10, 3} + + YES + + diff --git a/Example Apps/ExampleApp-OSX/en.lproj/Credits.rtf b/Example Apps/ExampleApp-OSX/en.lproj/Credits.rtf new file mode 100644 index 0000000..46576ef --- /dev/null +++ b/Example Apps/ExampleApp-OSX/en.lproj/Credits.rtf @@ -0,0 +1,29 @@ +{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} +{\colortbl;\red255\green255\blue255;} +\paperw9840\paperh8400 +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\b\fs24 \cf0 Engineering: +\b0 \ + Some people\ +\ + +\b Human Interface Design: +\b0 \ + Some other people\ +\ + +\b Testing: +\b0 \ + Hopefully not nobody\ +\ + +\b Documentation: +\b0 \ + Whoever\ +\ + +\b With special thanks to: +\b0 \ + Mom\ +} diff --git a/Example Apps/ExampleApp-OSX/en.lproj/InfoPlist.strings b/Example Apps/ExampleApp-OSX/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/Example Apps/ExampleApp-OSX/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/Example Apps/ExampleApp-OSX/main.m b/Example Apps/ExampleApp-OSX/main.m new file mode 100644 index 0000000..0999e46 --- /dev/null +++ b/Example Apps/ExampleApp-OSX/main.m @@ -0,0 +1,14 @@ +// +// main.m +// ExampleApp-OSX +// +// Created by Marcus Westin on 6/8/13. +// Copyright (c) 2013 Marcus Westin. All rights reserved. +// + +#import + +int main(int argc, char *argv[]) +{ + return NSApplicationMain(argc, (const char **)argv); +} diff --git a/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj new file mode 100644 index 0000000..324a5b0 --- /dev/null +++ b/Example Apps/ExampleApp-iOS.xcodeproj/project.pbxproj @@ -0,0 +1,372 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 0E4E9D4C1A101E0B00043087 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E8082DC19EDD98700479452 /* WebKit.framework */; }; + 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 */; }; + 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 */; }; + 2CA045C317117439006DEE8B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CA045BE17117439006DEE8B /* main.m */; }; + 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 */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0E50601B1A01B442000BEEEA /* WebViewJavascriptBridgeBase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewJavascriptBridgeBase.m; sourceTree = ""; }; + 0E50601D1A01B44C000BEEEA /* WebViewJavascriptBridgeBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebViewJavascriptBridgeBase.h; sourceTree = ""; }; + 0E8082D919EDC32300479452 /* WKWebViewJavascriptBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewJavascriptBridge.h; sourceTree = ""; }; + 0E8082DA19EDC32300479452 /* WKWebViewJavascriptBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WKWebViewJavascriptBridge.m; sourceTree = ""; }; + 0E8082DC19EDD98700479452 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; + 0ECB01421A0EE1BA0037FF4E /* ExampleWKWebViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ExampleWKWebViewController.h; sourceTree = ""; }; + 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 = ""; }; + 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 = ""; }; + 2CA045B917117439006DEE8B /* ExampleApp-iOS-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "ExampleApp-iOS-Info.plist"; sourceTree = ""; }; + 2CA045BA17117439006DEE8B /* ExampleApp-iOS-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ExampleApp-iOS-Prefix.pch"; sourceTree = ""; }; + 2CA045BC17117439006DEE8B /* ExampleAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleAppDelegate.h; sourceTree = ""; }; + 2CA045BD17117439006DEE8B /* ExampleAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleAppDelegate.m; sourceTree = ""; }; + 2CA045BE17117439006DEE8B /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 2CA0465B1711AC8D006DEE8B /* ExampleApp.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ExampleApp.html; sourceTree = SOURCE_ROOT; }; + 2CAB869A1727684300BD9ED1 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "ExampleApp-iOS/Default-568h@2x.png"; sourceTree = ""; }; + 2CEB3EBB1602563600548120 /* ExampleApp-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ExampleApp-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 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; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 2CEB3EB81602563600548120 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0E4E9D4C1A101E0B00043087 /* WebKit.framework in Frameworks */, + 2CEB3EC01602563600548120 /* UIKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2C1562A7176B9F5400B4AE50 /* WebViewJavascriptBridge */ = { + isa = PBXGroup; + children = ( + 2C3E7C441C5A890A00A1E322 /* WebViewJavascriptBridge_JS.h */, + 2C3E7C451C5A890A00A1E322 /* WebViewJavascriptBridge_JS.m */, + 2C1562A8176B9F6200B4AE50 /* WebViewJavascriptBridge.h */, + 2C1562A9176B9F6200B4AE50 /* WebViewJavascriptBridge.m */, + 0E8082DA19EDC32300479452 /* WKWebViewJavascriptBridge.m */, + 0E8082D919EDC32300479452 /* WKWebViewJavascriptBridge.h */, + 0E50601B1A01B442000BEEEA /* WebViewJavascriptBridgeBase.m */, + 0E50601D1A01B44C000BEEEA /* WebViewJavascriptBridgeBase.h */, + ); + name = WebViewJavascriptBridge; + path = ../../WebViewJavascriptBridge; + sourceTree = ""; + }; + 2CA045B617117439006DEE8B /* ExampleApp-iOS */ = { + isa = PBXGroup; + children = ( + 2CA0465B1711AC8D006DEE8B /* ExampleApp.html */, + 2CA045BC17117439006DEE8B /* ExampleAppDelegate.h */, + 2CA045BD17117439006DEE8B /* ExampleAppDelegate.m */, + 2C45CA2A1884AD520002A4E2 /* ExampleUIWebViewController.h */, + 2C45CA2B1884AD520002A4E2 /* ExampleUIWebViewController.m */, + 0ECB01421A0EE1BA0037FF4E /* ExampleWKWebViewController.h */, + 0ECB01431A0EE1F20037FF4E /* ExampleWKWebViewController.m */, + 2C1562A7176B9F5400B4AE50 /* WebViewJavascriptBridge */, + 2CA046211711A94E006DEE8B /* Supporting Files */, + ); + path = "ExampleApp-iOS"; + sourceTree = ""; + }; + 2CA046211711A94E006DEE8B /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 2CA045B717117439006DEE8B /* InfoPlist.strings */, + 2CA045B917117439006DEE8B /* ExampleApp-iOS-Info.plist */, + 2CA045BA17117439006DEE8B /* ExampleApp-iOS-Prefix.pch */, + 2CA045BE17117439006DEE8B /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 2CEB3EB01602563600548120 = { + isa = PBXGroup; + children = ( + 2CAB869A1727684300BD9ED1 /* Default-568h@2x.png */, + 2CA045B617117439006DEE8B /* ExampleApp-iOS */, + 2CEB3EBE1602563600548120 /* Frameworks */, + 2CEB3EBC1602563600548120 /* Products */, + 81A733051B2F9C5795D856E4 /* Pods */, + ); + sourceTree = ""; + }; + 2CEB3EBC1602563600548120 /* Products */ = { + isa = PBXGroup; + children = ( + 2CEB3EBB1602563600548120 /* ExampleApp-iOS.app */, + ); + name = Products; + sourceTree = ""; + }; + 2CEB3EBE1602563600548120 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 0E8082DC19EDD98700479452 /* WebKit.framework */, + 2CEB3EBF1602563600548120 /* UIKit.framework */, + 2CEB3EC11602563600548120 /* Foundation.framework */, + 2CEB3EC31602563600548120 /* CoreGraphics.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 81A733051B2F9C5795D856E4 /* Pods */ = { + isa = PBXGroup; + children = ( + ); + name = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 2CEB3EBA1602563600548120 /* ExampleApp-iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2CEB3ED31602563600548120 /* Build configuration list for PBXNativeTarget "ExampleApp-iOS" */; + buildPhases = ( + 2CEB3EB71602563600548120 /* Sources */, + 2CEB3EB81602563600548120 /* Frameworks */, + 2CEB3EB91602563600548120 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "ExampleApp-iOS"; + productName = ExampleApp; + productReference = 2CEB3EBB1602563600548120 /* ExampleApp-iOS.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 2CEB3EB21602563600548120 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0810; + ORGANIZATIONNAME = "Marcus Westin"; + TargetAttributes = { + 2CEB3EBA1602563600548120 = { + LastSwiftMigration = 0820; + }; + }; + }; + buildConfigurationList = 2CEB3EB51602563600548120 /* Build configuration list for PBXProject "ExampleApp-iOS" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 2CEB3EB01602563600548120; + productRefGroup = 2CEB3EBC1602563600548120 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 2CEB3EBA1602563600548120 /* ExampleApp-iOS */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 2CEB3EB91602563600548120 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2CA045BF17117439006DEE8B /* InfoPlist.strings in Resources */, + 2CA0465C1711AC8E006DEE8B /* ExampleApp.html in Resources */, + 2CAB869B1727684300BD9ED1 /* Default-568h@2x.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 2CEB3EB71602563600548120 /* Sources */ = { + 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 */, + 0ECB01441A0EE1F20037FF4E /* ExampleWKWebViewController.m in Sources */, + 2CA045C217117439006DEE8B /* ExampleAppDelegate.m in Sources */, + 0E50601C1A01B442000BEEEA /* WebViewJavascriptBridgeBase.m in Sources */, + 2CA045C317117439006DEE8B /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 2CA045B717117439006DEE8B /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 2CA045B817117439006DEE8B /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 2CEB3ED11602563600548120 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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 = 8.0; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 2CEB3ED21602563600548120 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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 = 8.0; + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 2CEB3ED41602563600548120 /* Debug */ = { + isa = XCBuildConfiguration; + 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; + 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; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2CEB3EB51602563600548120 /* Build configuration list for PBXProject "ExampleApp-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2CEB3ED11602563600548120 /* Debug */, + 2CEB3ED21602563600548120 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2CEB3ED31602563600548120 /* Build configuration list for PBXNativeTarget "ExampleApp-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2CEB3ED41602563600548120 /* Debug */, + 2CEB3ED51602563600548120 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 2CEB3EB21602563600548120 /* Project object */; +} diff --git a/Example Apps/ExampleApp-iOS/Default-568h@2x.png b/Example Apps/ExampleApp-iOS/Default-568h@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..0891b7aabfcf3422423b109c8beed2bab838c607 GIT binary patch literal 18594 zcmeI4X;f257Jx&9fS`ixvS;&$x8J@slQFSel)6zJN=?13FB7H(lQjRkSy8x_-S~tvu2gzn1oS+dLcF#eqtq$ z%tf9TTvX?`)R@}3uBI;jzS-=ZR-Td&MHaS&;!0?Ni*#$#`n*~CcQK)Q9vAQ~TUpnI!j)a2biYK^R)M~A5wUDZhx?ULMX z3x1P&qt=trOY6P2U67L=m=U?F|5#Uj(eCueNTZaHs_ceWiHeET+j+tp3Jt9g(ekqP z2WOvfR{qV+9r+o4J5?qK>7;;^+I7tGv-i)es$X_D=EoKF+S?zsyj^oRFElP}c}JT< zd8SUs-?O?}2YD#ngKbnHgzHBcboxK_2r9l(?eNCl-pEzkJm}fY?WC*jnS?VBE4EpY zO$fEejz6fU;W2Kl>JeQBZBl-%Irg`obSlg*@4QB;Dd1H7^Oi5wvt4d{RZ!8Og?^aE z)k0$1g+V3fd(gdQ3d&q2q-FL*uy#}|bc^=VhFsl0jBgUGJ+-s3U8MK9A!YJJMxpci z5hJ%|{DwV48fZn0{n5l$N_KcSb#NKE4plB`9I6Zt=Z!~-zw0{9tg$L&Ju1F0X)Cy8 zKF;(&lJ>x)Jw(=;p~sF(Sd9VWGwFE2rnyS9!f^DZ8+aCLq zQ};>lcJ1GDLqjm6Hd>|Eabno@P`~Bn(~6^aD_#yoEH(a?Nm1S<;S+hSxI5d16^<1lEM3NPFi zkqPrpL)+ zgnseFikg`gJVBha1&7C4;O6>h=dt~`ND+;Zd?W(4v2JIb7Pt>Td42%M-Ju-XAH#Pns762L}K3 zDhvsRqN0Ni(1UrishD2YvV?4*h2iFj$+&N||Fn$4n|^NSU+o?~jq`0jVQt8T9l{7b zXiwwODFh2V!Q6sqP9S>WH$oOf$N~=d0-bqTlD61!=`&0eAP-F>XN?*|gtOXX{ zQVTWyYo4ZK0GAw!GHf|pz9`D;-bbb*5LBX*{bnz|+)$@&P9|ORM2o?95{;ejvo&r- zq8cBhTN6nn)7~W>54U)%-F_-b?YKdfk5I8MHcuzBD5)!;yv#Z&R&^y=@=>VTIMy#r zX&U<=BsPkdqcMe<_}2+>H%XKyrr5ZR8_KVe>ZqYN z^=^~TFD};;rHJ$U;{~w^hYojl4hRI@SH$^K{YEo=sg)WY87r!*7blQK&qnpDo0`Vn zkl)9u9g=mCh&ZCJS(L4yN3k0kQ zuvg$h2KEEk51T+O0JQ+r0`R>g{jvqM0Mr6d3qUOZwE!?PI7HY@CE|dr sfw?Q;rAv?G4&^^8-z_>&sWXMxvD*gPOU4CBe-*@OtE+wfmVJNyHv)PfH~;_u literal 0 HcmV?d00001 diff --git a/Example Apps/ExampleApp-iOS/ExampleApp-iOS-Info.plist b/Example Apps/ExampleApp-iOS/ExampleApp-iOS-Info.plist new file mode 100644 index 0000000..3eb7025 --- /dev/null +++ b/Example Apps/ExampleApp-iOS/ExampleApp-iOS-Info.plist @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + + + diff --git a/Example Apps/ExampleApp-iOS/ExampleApp-iOS-Prefix.pch b/Example Apps/ExampleApp-iOS/ExampleApp-iOS-Prefix.pch new file mode 100644 index 0000000..29f2d2a --- /dev/null +++ b/Example Apps/ExampleApp-iOS/ExampleApp-iOS-Prefix.pch @@ -0,0 +1,14 @@ +// +// Prefix header for all source files of the 'ExampleApp' target in the 'ExampleApp' project +// + +#import + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iOS SDK 3.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/Example Apps/ExampleApp-iOS/ExampleAppDelegate.h b/Example Apps/ExampleApp-iOS/ExampleAppDelegate.h new file mode 100644 index 0000000..f59015d --- /dev/null +++ b/Example Apps/ExampleApp-iOS/ExampleAppDelegate.h @@ -0,0 +1,5 @@ +#import + +@interface ExampleAppDelegate : UIResponder +@property (nonatomic) UIWindow *window; +@end diff --git a/Example Apps/ExampleApp-iOS/ExampleAppDelegate.m b/Example Apps/ExampleApp-iOS/ExampleAppDelegate.m new file mode 100644 index 0000000..ff9f5be --- /dev/null +++ b/Example Apps/ExampleApp-iOS/ExampleAppDelegate.m @@ -0,0 +1,30 @@ +#import "ExampleAppDelegate.h" +#import "ExampleUIWebViewController.h" +#import "ExampleWKWebViewController.h" + +@implementation ExampleAppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + // 1. Create the UIWebView example + ExampleUIWebViewController* UIWebViewExampleController = [[ExampleUIWebViewController alloc] init]; + UIWebViewExampleController.tabBarItem.title = @"UIWebView"; + + // 2. Create the tab footer and add the UIWebView example + UITabBarController *tabBarController = [[UITabBarController alloc] init]; + [tabBarController addChildViewController:UIWebViewExampleController]; + + // 3. Create the WKWebView example for devices >= iOS 8 + if([WKWebView class]) { + ExampleWKWebViewController* WKWebViewExampleController = [[ExampleWKWebViewController alloc] init]; + WKWebViewExampleController.tabBarItem.title = @"WKWebView"; + [tabBarController addChildViewController:WKWebViewExampleController]; + } + + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + self.window.rootViewController = tabBarController; + [self.window makeKeyAndVisible]; + return YES; +} + +@end diff --git a/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.h b/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.h new file mode 100644 index 0000000..71364e8 --- /dev/null +++ b/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.h @@ -0,0 +1,13 @@ +// +// ExampleUIWebViewController.h +// ExampleApp-iOS +// +// Created by Marcus Westin on 1/13/14. +// Copyright (c) 2014 Marcus Westin. All rights reserved. +// + +#import + +@interface ExampleUIWebViewController : UINavigationController + +@end \ No newline at end of file diff --git a/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m b/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m new file mode 100644 index 0000000..f988a01 --- /dev/null +++ b/Example Apps/ExampleApp-iOS/ExampleUIWebViewController.m @@ -0,0 +1,90 @@ +// +// ExampleUIWebViewController.m +// ExampleApp-iOS +// +// Created by Marcus Westin on 1/13/14. +// Copyright (c) 2014 Marcus Westin. All rights reserved. +// + +#import "ExampleUIWebViewController.h" +#import "WebViewJavascriptBridge.h" + +@interface ExampleUIWebViewController () +@property WebViewJavascriptBridge* bridge; +@end + +@implementation ExampleUIWebViewController + +- (void)viewWillAppear:(BOOL)animated { + if (_bridge) { return; } + + UIWebView* webView = [[UIWebView alloc] initWithFrame:self.view.bounds]; + [self.view addSubview:webView]; + + [WebViewJavascriptBridge enableLogging]; + + _bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; + [_bridge setWebViewDelegate:self]; + + [_bridge registerHandler:@"testObjcCallback" handler:^(id data, WVJBResponseCallback responseCallback) { + NSLog(@"testObjcCallback called: %@", data); + responseCallback(@"Response from testObjcCallback"); + }]; + + [_bridge callHandler:@"testJavascriptHandler" data:@{ @"foo":@"before ready" }]; + + [self renderButtons:webView]; + [self loadExamplePage:webView]; +} + +- (void)webViewDidStartLoad:(UIWebView *)webView { + NSLog(@"webViewDidStartLoad"); +} + +- (void)webViewDidFinishLoad:(UIWebView *)webView { + NSLog(@"webViewDidFinishLoad"); +} + +- (void)renderButtons:(UIWebView*)webView { + 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(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(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 { + id data = @{ @"greetingFromObjC": @"Hi there, JS!" }; + [_bridge callHandler:@"testJavascriptHandler" data:data responseCallback:^(id response) { + NSLog(@"testJavascriptHandler responded: %@", response); + }]; +} + +- (void)loadExamplePage:(UIWebView*)webView { + NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"ExampleApp" ofType:@"html"]; + NSString* appHtml = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil]; + NSURL *baseURL = [NSURL fileURLWithPath:htmlPath]; + [webView loadHTMLString:appHtml baseURL:baseURL]; +} +@end diff --git a/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.h b/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.h new file mode 100644 index 0000000..7dd92b8 --- /dev/null +++ b/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.h @@ -0,0 +1,14 @@ +// +// ExampleWKWebViewController.h +// ExampleApp-iOS +// +// Created by Marcus Westin on 1/13/14. +// Copyright (c) 2014 Marcus Westin. All rights reserved. +// + +#import +#import + +@interface ExampleWKWebViewController : UINavigationController + +@end \ No newline at end of file diff --git a/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m b/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m new file mode 100644 index 0000000..f9d4ac7 --- /dev/null +++ b/Example Apps/ExampleApp-iOS/ExampleWKWebViewController.m @@ -0,0 +1,80 @@ +// +// ExampleWKWebViewController.m +// ExampleApp-iOS +// +// Created by Marcus Westin on 1/13/14. +// Copyright (c) 2014 Marcus Westin. All rights reserved. +// + +#import "ExampleWKWebViewController.h" +#import "WebViewJavascriptBridge.h" + +@interface ExampleWKWebViewController () + +@property WebViewJavascriptBridge* bridge; + +@end + +@implementation ExampleWKWebViewController + +- (void)viewWillAppear:(BOOL)animated { + if (_bridge) { return; } + + WKWebView* webView = [[NSClassFromString(@"WKWebView") alloc] initWithFrame:self.view.bounds]; + webView.navigationDelegate = self; + [self.view addSubview:webView]; + [WebViewJavascriptBridge enableLogging]; + _bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; + [_bridge setWebViewDelegate:self]; + + [_bridge registerHandler:@"testObjcCallback" handler:^(id data, WVJBResponseCallback responseCallback) { + NSLog(@"testObjcCallback called: %@", data); + responseCallback(@"Response from testObjcCallback"); + }]; + + [_bridge callHandler:@"testJavascriptHandler" data:@{ @"foo":@"before ready" }]; + + [self renderButtons:webView]; + [self loadExamplePage:webView]; +} + +- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation { + NSLog(@"webViewDidStartLoad"); +} + +- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { + NSLog(@"webViewDidFinishLoad"); +} + +- (void)renderButtons:(WKWebView*)webView { + UIFont* font = [UIFont fontWithName:@"HelveticaNeue" size:12.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.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.titleLabel.font = font; +} + +- (void)callHandler:(id)sender { + id data = @{ @"greetingFromObjC": @"Hi there, JS!" }; + [_bridge callHandler:@"testJavascriptHandler" data:data responseCallback:^(id response) { + NSLog(@"testJavascriptHandler responded: %@", response); + }]; +} + +- (void)loadExamplePage:(WKWebView*)webView { + NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"ExampleApp" ofType:@"html"]; + NSString* appHtml = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil]; + NSURL *baseURL = [NSURL fileURLWithPath:htmlPath]; + [webView loadHTMLString:appHtml baseURL:baseURL]; +} +@end diff --git a/Example Apps/ExampleApp-iOS/en.lproj/InfoPlist.strings b/Example Apps/ExampleApp-iOS/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/Example Apps/ExampleApp-iOS/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/Example Apps/ExampleApp-iOS/main.m b/Example Apps/ExampleApp-iOS/main.m new file mode 100644 index 0000000..003d3a8 --- /dev/null +++ b/Example Apps/ExampleApp-iOS/main.m @@ -0,0 +1,26 @@ +#import +#import +#import +#import "ExampleAppDelegate.h" + +#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) + +int main(int argc, char * argv[]) +{ + @autoreleasepool { + // Dynamically load WebKit if iOS version >= 8 + if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) { +#if TARGET_IPHONE_SIMULATOR + NSString *frameworkPath = [[NSProcessInfo processInfo] environment][@"DYLD_FALLBACK_FRAMEWORK_PATH"]; + if (frameworkPath) { + NSString *webkitLibraryPath = [NSString pathWithComponents:@[frameworkPath, @"WebKit.framework", @"WebKit"]]; + dlopen([webkitLibraryPath cStringUsingEncoding:NSUTF8StringEncoding], RTLD_LAZY); + } +#else + dlopen("/System/Library/Frameworks/WebKit.framework/WebKit", RTLD_LAZY); +#endif + } + + return UIApplicationMain(argc, argv, nil, NSStringFromClass([ExampleAppDelegate class])); + } +} \ No newline at end of file diff --git a/Example Apps/ExampleApp.html b/Example Apps/ExampleApp.html new file mode 100644 index 0000000..06e7dc8 --- /dev/null +++ b/Example Apps/ExampleApp.html @@ -0,0 +1,60 @@ + + + + + +

WebViewJavascriptBridge Demo

+ +
+ 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 0000000..51bd94d --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOS.xcodeproj/project.pbxproj @@ -0,0 +1,568 @@ +// !$*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; + LastSwiftMigration = 0910; + ProvisioningStyle = Automatic; + }; + 2CF20AA81E12BB3F00D3009D = { + CreatedOnToolsVersion = 8.2.1; + LastSwiftMigration = 0910; + 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_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.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_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.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_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.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_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.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 0000000..808eae5 --- /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 0000000..36d2c80 --- /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 0000000..fdf3f97 --- /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 0000000..273375f --- /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 0000000..d052473 --- /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 0000000..f6eb035 --- /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 0000000..c2a3b31 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/ExampleSwiftApp_iOSTests.swift @@ -0,0 +1,211 @@ +// +// 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) + 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 + XCTAssertEqual(data as! NSDictionary, ["foo":"bar"]); + 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 + XCTAssertEqual(data as! NSDictionary, ["foo":"bar"]); + responseCallback!(data); + } + bridge.callHandler("jsRcvResponseTest", data:nil) { (responseData) in + XCTAssertEqual(responseData as! String, "Response from JS"); + callbackInvoked.fulfill() + } + } + + 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/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/Info.plist b/Example Apps/ExampleSwiftApp-iOS/ExampleSwiftApp-iOSTests/Info.plist new file mode 100644 index 0000000..6c6c23c --- /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 0000000..504f6f1 --- /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 0000000..0f34868 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Podfile.lock @@ -0,0 +1,16 @@ +PODS: + - WebViewJavascriptBridge (6.0.2) + +DEPENDENCIES: + - WebViewJavascriptBridge (from `../..`) + +EXTERNAL SOURCES: + WebViewJavascriptBridge: + :path: ../.. + +SPEC CHECKSUMS: + WebViewJavascriptBridge: 791ee0e26d1bf15efe5fb7fb9666a71a19b89d77 + +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 0000000..5fb7055 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Local Podspecs/WebViewJavascriptBridge.podspec.json @@ -0,0 +1,35 @@ +{ + "name": "WebViewJavascriptBridge", + "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": { + "type": "MIT", + "file": "LICENSE" + }, + "authors": { + "marcuswestin": "marcus.westin@gmail.com" + }, + "source": { + "git": "https://github.com/marcuswestin/WebViewJavascriptBridge.git", + "tag": "v6.0.2" + }, + "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 0000000..0f34868 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/Pods/Manifest.lock @@ -0,0 +1,16 @@ +PODS: + - WebViewJavascriptBridge (6.0.2) + +DEPENDENCIES: + - WebViewJavascriptBridge (from `../..`) + +EXTERNAL SOURCES: + WebViewJavascriptBridge: + :path: ../.. + +SPEC CHECKSUMS: + WebViewJavascriptBridge: 791ee0e26d1bf15efe5fb7fb9666a71a19b89d77 + +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 0000000..3df53a6 --- /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 0000000..2243fe6 --- /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 0000000..ce5d3d2 --- /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 0000000..ec65f73 --- /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 0000000..5736c16 --- /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 0000000..43c5de2 --- /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 0000000..25e9d37 --- /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 0000000..7d2746c --- /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 0000000..df30848 --- /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 0000000..4ab6cd4 --- /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 0000000..df30848 --- /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 0000000..2243fe6 --- /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 0000000..ce5d3d2 --- /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 0000000..ec65f73 --- /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 0000000..ef31243 --- /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 0000000..43c5de2 --- /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 0000000..25e9d37 --- /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 0000000..e20d8d8 --- /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 0000000..df30848 --- /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 0000000..1eac38c --- /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 0000000..df30848 --- /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 0000000..69f0d0a --- /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 + 6.0.2 + 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 0000000..6c5914c --- /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 0000000..aa992a4 --- /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 0000000..41f7d8e --- /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 0000000..e0cccd7 --- /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 0000000..bc2e2b7 --- /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 0000000..b5076d9 --- /dev/null +++ b/Example Apps/ExampleSwiftApp-iOS/echo.html @@ -0,0 +1,33 @@ + + + +

WebViewJavascriptBridgeTests - echo.html

+ + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..56b0824 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5a89b6c --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +test: + xcodebuild test -project Tests/WebViewJavascriptBridge.xcodeproj -scheme WebViewJavascriptBridge \ + -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 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' \ + -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' + # 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/README.md b/README.md new file mode 100644 index 0000000..fb14d2d --- /dev/null +++ b/README.md @@ -0,0 +1,238 @@ +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. + +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: + +- [Facebook Messenger](https://www.facebook.com/mobile/messenger) +- [Facebook Paper](https://facebook.com/paper) +- [Yardsale](http://www.getyardsale.com/) +- [EverTrue](http://www.evertrue.com/) +- [Game Insight](http://www.game-insight.com/) +- [Sush.io](http://www.sush.io) +- [Imbed](http://imbed.github.io/) +- [CareZone](https://carezone.com) +- [Hemlig](http://www.hemlig.co) +- [Altralogica](http://www.altralogica.it) +- [鼎盛中华](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/) +- ... & many more! + +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: + +```ruby +pod 'WebViewJavascriptBridge', '~> 6.0' +``` + +### 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 +-------- + +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: + +Usage +----- + +1) Import the header file and declare an ivar property: + +```objc +#import "WebViewJavascriptBridge.h" +``` + +... + +```objc +@property WebViewJavascriptBridge* bridge; +``` + +2) Instantiate WebViewJavascriptBridge with a WKWebView, UIWebView (iOS) or WebView (OSX): + +```objc +self.bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; +``` + +3) Register a handler in ObjC, and call a JS handler: + +```objc +[self.bridge registerHandler:@"ObjC Echo" handler:^(id data, WVJBResponseCallback responseCallback) { + NSLog(@"ObjC Echo called with: %@", data); + responseCallback(data); +}]; +[self.bridge callHandler:@"JS Echo" data:nil responseCallback:^(id responseData) { + NSLog(@"ObjC received response: %@", responseData); +}]; +``` + +4) Copy and paste `setupWebViewJavascriptBridge` into your JS: + +```javascript +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 = 'https://__bridge_loaded__'; + document.documentElement.appendChild(WVJBIframe); + setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0) +} +``` + +5) Finally, call `setupWebViewJavascriptBridge` and then use the bridge to register handlers and call ObjC handlers: + +```javascript +setupWebViewJavascriptBridge(function(bridge) { + + /* Initialize your app here */ + + bridge.registerHandler('JS Echo', function(data, responseCallback) { + console.log("JS Echo called with:", data) + responseCallback(data) + }) + bridge.callHandler('ObjC Echo', {'key':'value'}, function responseCallback(responseData) { + console.log("JS received response:", responseData) + }) +}) +``` + +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 + +Forks: https://github.com/marcuswestin/WebViewJavascriptBridge/network/members + +API Reference +------------- + +### ObjC API + +##### `[WebViewJavascriptBridge bridgeForWebView:(WKWebVIew/UIWebView/WebView*)webview` + +Create a javascript bridge for the given web view. + +Example: + +```objc +[WebViewJavascriptBridge bridgeForWebView:webView]; +``` + +##### `[bridge registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler]` + +Register a handler called `handlerName`. The javascript can then call this handler with `WebViewJavascriptBridge.callHandler("handlerName")`. + +Example: + +```objc +[self.bridge registerHandler:@"getScreenHeight" handler:^(id data, WVJBResponseCallback responseCallback) { + responseCallback([NSNumber numberWithInt:[UIScreen mainScreen].bounds.size.height]); +}]; +[self.bridge registerHandler:@"log" handler:^(id data, WVJBResponseCallback responseCallback) { + NSLog(@"Log: %@", data); +}]; + +``` + +##### `[bridge callHandler:(NSString*)handlerName data:(id)data]` +##### `[bridge callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)callback]` + +Call the javascript handler called `handlerName`. If a `responseCallback` block is given the javascript handler can respond. + +Example: + +```objc +[self.bridge callHandler:@"showAlert" data:@"Hi from ObjC to JS!"]; +[self.bridge callHandler:@"getCurrentPageUrl" data:nil responseCallback:^(id responseData) { + NSLog(@"Current UIWebView page URL is: %@", responseData); +}]; +``` + +#### `[bridge setWebViewDelegate:(id)webViewDelegate]` + +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]` + +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]; + + + +### Javascript API + +##### `bridge.registerHandler("handlerName", function(responseData) { ... })` + +Register a handler called `handlerName`. The ObjC can then call this handler with `[bridge callHandler:"handlerName" data:@"Foo"]` and `[bridge callHandler:"handlerName" data:@"Foo" responseCallback:^(id responseData) { ... }]` + +Example: + +```javascript +bridge.registerHandler("showAlert", function(data) { alert(data) }) +bridge.registerHandler("getCurrentPageUrl", function(data, responseCallback) { + responseCallback(document.location.toString()) +}) +``` + + +##### `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. + +Example: + +```javascript +bridge.callHandler("Log", "Foo") +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() +``` diff --git a/Roadmap.md b/Roadmap.md new file mode 100644 index 0000000..00e0e35 --- /dev/null +++ b/Roadmap.md @@ -0,0 +1,105 @@ +Roadmap +======= +###通过使用该库可以轻松实现JS与原生交互。 + +Issues +------ + +- [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) +- [ ] WKWebView issue in OSX? (#84) +- [ ] Release new version (#143, #155, #167) +- [ ] Optional alert-unsafe message speedup (PR #133, I #132) +- [ ] 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) +- [ ] Pending bug repro/info + - [ ] #123: unity3d and WebViewJavascriptBridge unrecognized selector sent to instance + - [ ] #124: Getting an exception during _flushMessageQueue + +Misc +---- + +- [ ] Clean up webview delegate - can we get away without passing through one now? +- [ ] Make bridge a subclass of UI/WKWebView +- [ ] Scrap UIWebView? +- [ ] Style consistency through all code +- [ ] Test pod +- [X] Fix OSX lint warnings (`pod spec lint`) +- [X] I believe `receiveMessageQueue` in JS is no longer needed, since the JS explicitly tells ObjC when to start sending messages. Remove? + +v5.0.1 +------ + +Pull requests: +- [X] Dev env / docs + - [X] Automated tests (PR #128, I #151) + - [X] Travis? https://github.com/integrations/feature/code + - [X] Embed js in objc source (PR #129) + - [X] Also fixes PR #138, I #160, I #108 + - [X] Docs for podfile installation (PR #140) +- [X] Improve API + - [X] Remove default bridge handler - just do command/response. Remove bridge.init +- [X] Features & fixes to consider + - [X] Message response timeout (PR #106) + - [X] Remove or fix numRequestsLoading (PR #146, PR #157) +- [X] Net load fixes + - [X] Fix `[webView stopLoading]` (PR #168, I #163) + - [x] Detect offline failed requests (PR #170) + - [X] Handle redirects (PR #172) + - [X] Bridge never initiates without a didLoad (I #156) + +Future considerations +--------------------- +- [ ] 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) + - [ ] Windows phone + + +Common Messages +--------------- + +#### Fixed in v5.x.y: + +Hi! + +I believe this may be fixed in v5.0.1. + +When you switch to the new version, please note that the API has changed. In particular, make sure that you use the javascript setup code, as it has changed: https://github.com/marcuswestin/WebViewJavascriptBridge#usage + +If you are still having trouble when using v5.0.x, feel free to reopen. + +Cheers! + + +#### Need repro: + +Hi! + +Without a repro I won't be able to help you :( + +If you create a PR with a failing test then I will definitely give you a hand (see https://github.com/marcuswestin/WebViewJavascriptBridge/blob/master/Tests/WebViewJavascriptBridgeTests/BridgeTests.m and https://github.com/marcuswestin/WebViewJavascriptBridge/blob/master/Tests/WebViewJavascriptBridgeTests/echo.html). + +You could also create a PR with an example in `Example Apps` with the problem you're seeing in - that would definitely help me help you :) + +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! diff --git a/Tests/Default-568h@2x.png b/Tests/Default-568h@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..0891b7aabfcf3422423b109c8beed2bab838c607 GIT binary patch literal 18594 zcmeI4X;f257Jx&9fS`ixvS;&$x8J@slQFSel)6zJN=?13FB7H(lQjRkSy8x_-S~tvu2gzn1oS+dLcF#eqtq$ z%tf9TTvX?`)R@}3uBI;jzS-=ZR-Td&MHaS&;!0?Ni*#$#`n*~CcQK)Q9vAQ~TUpnI!j)a2biYK^R)M~A5wUDZhx?ULMX z3x1P&qt=trOY6P2U67L=m=U?F|5#Uj(eCueNTZaHs_ceWiHeET+j+tp3Jt9g(ekqP z2WOvfR{qV+9r+o4J5?qK>7;;^+I7tGv-i)es$X_D=EoKF+S?zsyj^oRFElP}c}JT< zd8SUs-?O?}2YD#ngKbnHgzHBcboxK_2r9l(?eNCl-pEzkJm}fY?WC*jnS?VBE4EpY zO$fEejz6fU;W2Kl>JeQBZBl-%Irg`obSlg*@4QB;Dd1H7^Oi5wvt4d{RZ!8Og?^aE z)k0$1g+V3fd(gdQ3d&q2q-FL*uy#}|bc^=VhFsl0jBgUGJ+-s3U8MK9A!YJJMxpci z5hJ%|{DwV48fZn0{n5l$N_KcSb#NKE4plB`9I6Zt=Z!~-zw0{9tg$L&Ju1F0X)Cy8 zKF;(&lJ>x)Jw(=;p~sF(Sd9VWGwFE2rnyS9!f^DZ8+aCLq zQ};>lcJ1GDLqjm6Hd>|Eabno@P`~Bn(~6^aD_#yoEH(a?Nm1S<;S+hSxI5d16^<1lEM3NPFi zkqPrpL)+ zgnseFikg`gJVBha1&7C4;O6>h=dt~`ND+;Zd?W(4v2JIb7Pt>Td42%M-Ju-XAH#Pns762L}K3 zDhvsRqN0Ni(1UrishD2YvV?4*h2iFj$+&N||Fn$4n|^NSU+o?~jq`0jVQt8T9l{7b zXiwwODFh2V!Q6sqP9S>WH$oOf$N~=d0-bqTlD61!=`&0eAP-F>XN?*|gtOXX{ zQVTWyYo4ZK0GAw!GHf|pz9`D;-bbb*5LBX*{bnz|+)$@&P9|ORM2o?95{;ejvo&r- zq8cBhTN6nn)7~W>54U)%-F_-b?YKdfk5I8MHcuzBD5)!;yv#Z&R&^y=@=>VTIMy#r zX&U<=BsPkdqcMe<_}2+>H%XKyrr5ZR8_KVe>ZqYN z^=^~TFD};;rHJ$U;{~w^hYojl4hRI@SH$^K{YEo=sg)WY87r!*7blQK&qnpDo0`Vn zkl)9u9g=mCh&ZCJS(L4yN3k0kQ zuvg$h2KEEk51T+O0JQ+r0`R>g{jvqM0Mr6d3qUOZwE!?PI7HY@CE|dr sfw?Q;rAv?G4&^^8-z_>&sWXMxvD*gPOU4CBe-*@OtE+wfmVJNyHv)PfH~;_u literal 0 HcmV?d00001 diff --git a/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj new file mode 100644 index 0000000..763eff7 --- /dev/null +++ b/Tests/WebViewJavascriptBridge.xcodeproj/project.pbxproj @@ -0,0 +1,489 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 2C35E9761C5A7F8E0093FB29 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2C35E9751C5A7F8E0093FB29 /* Default-568h@2x.png */; }; + 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 */; }; + 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 */; }; + 3DCCF7DB1AE28C2900CE7C51 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DCCF7DA1AE28C2900CE7C51 /* main.m */; }; + 3DCCF7DE1AE28C2900CE7C51 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DCCF7DD1AE28C2900CE7C51 /* AppDelegate.m */; }; + 3DCCF8021AE2911100CE7C51 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DCCF8011AE2911100CE7C51 /* UIKit.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 3DCCF7FC1AE28C3B00CE7C51 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 3D0FE4621AE2886400BB4104 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 3DCCF7D51AE28C2900CE7C51; + remoteInfo = WebViewJavascriptBridgeTestHost; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 2C35E9751C5A7F8E0093FB29 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + 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 = ""; }; + 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 = ""; }; + 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 = ""; }; + 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 */ + 3D0FE4721AE2886500BB4104 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 2C864FFD1C60FC8A00954B70 /* WebKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3DCCF7D31AE28C2900CE7C51 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 3DCCF8021AE2911100CE7C51 /* UIKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2C3E7C5A1C5A928700A1E322 /* WebViewJavascriptBridge */ = { + isa = PBXGroup; + children = ( + 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 */, + ); + name = WebViewJavascriptBridge; + path = ../WebViewJavascriptBridge; + sourceTree = ""; + }; + 3D0FE4611AE2886400BB4104 = { + isa = PBXGroup; + children = ( + 2C864FFC1C60FC8A00954B70 /* WebKit.framework */, + 2C35E9751C5A7F8E0093FB29 /* Default-568h@2x.png */, + 2C3E7C5A1C5A928700A1E322 /* WebViewJavascriptBridge */, + 3D0FE4791AE2886500BB4104 /* WebViewJavascriptBridgeTests */, + 3DCCF7D71AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost */, + 3D0FE46B1AE2886400BB4104 /* Products */, + ); + sourceTree = ""; + }; + 3D0FE46B1AE2886400BB4104 /* Products */ = { + isa = PBXGroup; + children = ( + 3D0FE4751AE2886500BB4104 /* WebViewJavascriptBridgeTests.xctest */, + 3DCCF7D61AE28C2900CE7C51 /* WebViewJavascriptBridgeTestHost.app */, + ); + name = Products; + sourceTree = ""; + }; + 3D0FE4791AE2886500BB4104 /* WebViewJavascriptBridgeTests */ = { + isa = PBXGroup; + children = ( + 3D0FE47A1AE2886500BB4104 /* Supporting Files */, + 3D9E5F2E1AE288E5009D1C36 /* BridgeTests.m */, + 2C52B1E11E11858800517DAF /* BridgeTests.swift */, + 2C52B1E01E11858800517DAF /* WebViewJavascriptBridgeTests-Bridging-Header.h */, + ); + 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 = ( + 3D99867D1AE2A3B2001DDA2C /* echo.html */, + 3DCCF7D91AE28C2900CE7C51 /* Info.plist */, + 3DCCF7DA1AE28C2900CE7C51 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 3DCCF8031AE2911700CE7C51 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 3DCCF8011AE2911100CE7C51 /* UIKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 3D0FE4741AE2886500BB4104 /* WebViewJavascriptBridgeTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3D0FE4811AE2886500BB4104 /* Build configuration list for PBXNativeTarget "WebViewJavascriptBridgeTests" */; + buildPhases = ( + 3D0FE4711AE2886500BB4104 /* Sources */, + 3D0FE4721AE2886500BB4104 /* Frameworks */, + 3D0FE4731AE2886500BB4104 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 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 = 0900; + ORGANIZATIONNAME = marcuswestin; + TargetAttributes = { + 3D0FE4741AE2886500BB4104 = { + CreatedOnToolsVersion = 6.3; + LastSwiftMigration = 0900; + 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 = ( + 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 = ( + 3D99867E1AE2A3B2001DDA2C /* echo.html in Resources */, + 2C35E9761C5A7F8E0093FB29 /* Default-568h@2x.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 3D0FE4711AE2886500BB4104 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2C3E7C651C5A928700A1E322 /* WebViewJavascriptBridgeBase.m in Sources */, + 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; + }; + 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 */ + 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_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; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + 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_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.0; + 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_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; + 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.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 3D0FE4821AE2886500BB4104 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(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_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebViewJavascriptBridgeTestHost.app/WebViewJavascriptBridgeTestHost"; + }; + name = Debug; + }; + 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_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; + 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; + 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)"; + }; + name = Debug; + }; + 3DCCF7F71AE28C2900CE7C51 /* Release */ = { + isa = XCBuildConfiguration; + 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)"; + }; + 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; + }; + 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/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme b/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme new file mode 100644 index 0000000..0f6982c --- /dev/null +++ b/Tests/WebViewJavascriptBridge.xcodeproj/xcshareddata/xcschemes/WebViewJavascriptBridge.xcscheme @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/WebViewJavascriptBridgeTestHost/AppDelegate.h b/Tests/WebViewJavascriptBridgeTestHost/AppDelegate.h new file mode 100644 index 0000000..00728f3 --- /dev/null +++ b/Tests/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/Tests/WebViewJavascriptBridgeTestHost/AppDelegate.m b/Tests/WebViewJavascriptBridgeTestHost/AppDelegate.m new file mode 100644 index 0000000..5d903bf --- /dev/null +++ b/Tests/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/Tests/WebViewJavascriptBridgeTestHost/Info.plist b/Tests/WebViewJavascriptBridgeTestHost/Info.plist new file mode 100644 index 0000000..a8a64da --- /dev/null +++ b/Tests/WebViewJavascriptBridgeTestHost/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + + + diff --git a/Tests/WebViewJavascriptBridgeTestHost/WebViewJavascriptBridgeTestHost-Bridging-Header.h b/Tests/WebViewJavascriptBridgeTestHost/WebViewJavascriptBridgeTestHost-Bridging-Header.h new file mode 100644 index 0000000..40fc747 --- /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/WebViewJavascriptBridgeTestHost/main.m b/Tests/WebViewJavascriptBridgeTestHost/main.m new file mode 100644 index 0000000..d37bf5b --- /dev/null +++ b/Tests/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/Tests/WebViewJavascriptBridgeTests/BridgeTests.m b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m new file mode 100644 index 0000000..06a139e --- /dev/null +++ b/Tests/WebViewJavascriptBridgeTests/BridgeTests.m @@ -0,0 +1,183 @@ +// +// BridgeTests.m +// WKWebViewJavascriptBridge +// +// Created by Pieter De Baets on 18/04/2015. +// Copyright (c) 2015 marcuswestin. All rights reserved. +// + +#import + +#import "WebViewJavascriptBridge.h" +#import "AppDelegate.h" + +static NSString *const echoHandler = @"echoHandler"; + +@interface BridgeTests : XCTestCase +@end +@interface TestWebPageLoadDelegate : NSObject +@property XCTestExpectation* expectation; +@end + +@implementation BridgeTests { + UIWebView *_uiWebView; + WKWebView *_wkWebView; + NSMutableArray* _retains; +} + +- (void)setUp { + [super setUp]; + + UIViewController *rootVC = [[(AppDelegate *)[[UIApplication sharedApplication] delegate] window] rootViewController]; + 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]; + + _retains = [NSMutableArray array]; +} + +- (void)tearDown { + [super tearDown]; + [_uiWebView removeFromSuperview]; + [_wkWebView removeFromSuperview]; +} + +- (WebViewJavascriptBridge*)bridgeForWebView:(id)webView { + WebViewJavascriptBridge* bridge = [WebViewJavascriptBridge bridgeForWebView:webView]; + [_retains addObject:bridge]; + return bridge; +} + +static void loadEchoSample(id webView) { + NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"echo" withExtension:@"html"]]; + [(UIWebView*)webView loadRequest:request]; +} + +const NSTimeInterval timeoutSec = 5; + +- (void)testEchoHandler { + [self classSpecificTestEchoHandler:_uiWebView]; + [self classSpecificTestEchoHandler:_wkWebView]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; +} +- (void)classSpecificTestEchoHandler:(id)webView { + WebViewJavascriptBridge *bridge = [self bridgeForWebView:webView]; + + XCTestExpectation *callbackInvocked = [self expectationWithDescription:@"Callback invoked"]; + [bridge callHandler:echoHandler data:@"testEchoHandler" responseCallback:^(id responseData) { + XCTAssertEqualObjects(responseData, @"testEchoHandler"); + [callbackInvocked fulfill]; + }]; + + loadEchoSample(webView); +} + +- (void)testEchoHandlerAfterSetup { + [self classSpecificTestEchoHandlerAfterSetup:_uiWebView]; + [self classSpecificTestEchoHandlerAfterSetup:_wkWebView]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; +} +- (void)classSpecificTestEchoHandlerAfterSetup:(id)webView { + WebViewJavascriptBridge *bridge = [self bridgeForWebView:webView]; + + XCTestExpectation *callbackInvocked = [self expectationWithDescription:@"Callback invoked"]; + loadEchoSample(webView); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 150 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{ + [bridge callHandler:echoHandler data:@"testEchoHandler" responseCallback:^(id responseData) { + XCTAssertEqualObjects(responseData, @"testEchoHandler"); + [callbackInvocked fulfill]; + }]; + }); +} + +- (void)testObjectEncoding { + [self classSpecificTestObjectEncoding:_uiWebView]; + [self classSpecificTestObjectEncoding:_wkWebView]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; +} +- (void)classSpecificTestObjectEncoding:(id)webView { + WebViewJavascriptBridge *bridge = [self bridgeForWebView:webView]; + + 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); +} + +- (void)testJavascriptReceiveResponse { + [self classSpecificTestJavascriptReceiveResponse:_uiWebView]; + [self classSpecificTestJavascriptReceiveResponse:_wkWebView]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; +} +- (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) { + responseCallback(data); + }]; + [bridge callHandler:@"jsRcvResponseTest" data:nil responseCallback:^(id responseData) { + XCTAssertEqualObjects(responseData, @"Response from JS"); + [callbackInvocked fulfill]; + }]; +} + +- (void)testJavascriptReceiveResponseWithoutSafetyTimeout { + [self classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:_uiWebView]; + [self classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:_wkWebView]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; +} +- (void)classSpecificTestJavascriptReceiveResponseWithoutSafetyTimeout:(id)webView { + WebViewJavascriptBridge *bridge = [self bridgeForWebView: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]; + }]; +} + +- (void)testWebpageLoad { + [self classSpecificTestWebpageLoad:_uiWebView]; + [self classSpecificTestWebpageLoad:_wkWebView]; + [self waitForExpectationsWithTimeout:timeoutSec handler:NULL]; +} +- (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]; +} +@end + +@implementation TestWebPageLoadDelegate +- (void)webViewDidFinishLoad:(UIWebView *)webView { + [self.expectation fulfill]; +} +- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { + [self.expectation fulfill]; +} +@end diff --git a/Tests/WebViewJavascriptBridgeTests/BridgeTests.swift b/Tests/WebViewJavascriptBridgeTests/BridgeTests.swift new file mode 100644 index 0000000..3964f6a --- /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/Info.plist b/Tests/WebViewJavascriptBridgeTests/Info.plist new file mode 100644 index 0000000..ba72822 --- /dev/null +++ b/Tests/WebViewJavascriptBridgeTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/Tests/WebViewJavascriptBridgeTests/WebViewJavascriptBridgeTests-Bridging-Header.h b/Tests/WebViewJavascriptBridgeTests/WebViewJavascriptBridgeTests-Bridging-Header.h new file mode 100644 index 0000000..1b2cb5d --- /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/Tests/WebViewJavascriptBridgeTests/echo.html b/Tests/WebViewJavascriptBridgeTests/echo.html new file mode 100644 index 0000000..4549722 --- /dev/null +++ b/Tests/WebViewJavascriptBridgeTests/echo.html @@ -0,0 +1,32 @@ + + + +

WebViewJavascriptBridgeTests - echo.html

+ + diff --git a/WebViewJavascriptBridge.podspec b/WebViewJavascriptBridge.podspec new file mode 100644 index 0000000..4e336a7 --- /dev/null +++ b/WebViewJavascriptBridge.podspec @@ -0,0 +1,19 @@ +Pod::Spec.new do |s| + s.name = 'WebViewJavascriptBridge' + 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' } + s.author = { 'marcuswestin' => 'marcus.westin@gmail.com' } + s.source = { :git => 'https://git.qinjiu8.com/liuhl/WebViewJavascriptBridge.git', :tag => 'v'+s.version.to_s } + 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.frameworks = 'WebKit' + s.ios.frameworks = 'UIKit', 'WebKit' +end diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h new file mode 100644 index 0000000..4e3404f --- /dev/null +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.h @@ -0,0 +1,34 @@ +// +// WKWebViewJavascriptBridge.h +// +// Created by @LokiMeyburg on 10/15/14. +// Copyright (c) 2014 @LokiMeyburg. All rights reserved. +// + +#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 +#import "WebViewJavascriptBridgeBase.h" +#import + +@interface WKWebViewJavascriptBridge : NSObject + ++ (instancetype)bridgeForWebView:(WKWebView*)webView; ++ (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; +- (void)reset; +- (void)setWebViewDelegate:(id)webViewDelegate; +- (void)disableJavscriptAlertBoxSafetyTimeout; + +@end + +#endif diff --git a/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m new file mode 100644 index 0000000..73c923d --- /dev/null +++ b/WebViewJavascriptBridge/WKWebViewJavascriptBridge.m @@ -0,0 +1,198 @@ +// +// WKWebViewJavascriptBridge.m +// +// Created by @LokiMeyburg on 10/15/14. +// Copyright (c) 2014 @LokiMeyburg. All rights reserved. +// + + +#import "WKWebViewJavascriptBridge.h" + +#if defined supportsWKWebView + +@implementation WKWebViewJavascriptBridge { + __weak WKWebView* _webView; + __weak id _webViewDelegate; + long _uniqueId; + WebViewJavascriptBridgeBase *_base; +} + +/* API + *****/ + ++ (void)enableLogging { [WebViewJavascriptBridgeBase enableLogging]; } + ++ (instancetype)bridgeForWebView:(WKWebView*)webView { + WKWebViewJavascriptBridge* bridge = [[self alloc] init]; + [bridge _setupInstance:webView]; + [bridge reset]; + return bridge; +} + +- (void)send:(id)data { + [self send:data responseCallback:nil]; +} + +- (void)send:(id)data responseCallback:(WVJBResponseCallback)responseCallback { + [_base sendData:data responseCallback:responseCallback handlerName:nil]; +} + +- (void)callHandler:(NSString *)handlerName { + [self callHandler:handlerName data:nil responseCallback:nil]; +} + +- (void)callHandler:(NSString *)handlerName data:(id)data { + [self callHandler:handlerName data:data responseCallback:nil]; +} + +- (void)callHandler:(NSString *)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback { + [_base sendData:data responseCallback:responseCallback handlerName:handlerName]; +} + +- (void)registerHandler:(NSString *)handlerName handler:(WVJBHandler)handler { + _base.messageHandlers[handlerName] = [handler copy]; +} + +- (void)removeHandler:(NSString *)handlerName { + [_base.messageHandlers removeObjectForKey:handlerName]; +} + +- (void)reset { + [_base reset]; +} + +- (void)setWebViewDelegate:(id)webViewDelegate { + _webViewDelegate = webViewDelegate; +} + +- (void)disableJavscriptAlertBoxSafetyTimeout { + [_base disableJavscriptAlertBoxSafetyTimeout]; +} + +/* Internals + ***********/ + +- (void)dealloc { + _base = nil; + _webView = nil; + _webViewDelegate = nil; + _webView.navigationDelegate = nil; +} + + +/* WKWebView Specific Internals + ******************************/ + +- (void) _setupInstance:(WKWebView*)webView { + _webView = webView; + _webView.navigationDelegate = self; + _base = [[WebViewJavascriptBridgeBase alloc] init]; + _base.delegate = self; +} + + +- (void)WKFlushMessageQueue { + [_webView evaluateJavaScript:[_base webViewJavascriptFetchQueyCommand] completionHandler:^(NSString* result, NSError* error) { + if (error != nil) { + NSLog(@"WebViewJavascriptBridge: WARNING: Error when trying to fetch data from WKWebView: %@", error); + } + [_base flushMessageQueue:result]; + }]; +} + +- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { + if (webView != _webView) { return; } + + __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; + if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didFinishNavigation:)]) { + [strongDelegate webView:webView didFinishNavigation:navigation]; + } +} + + +- (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; } + + __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; + if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didReceiveAuthenticationChallenge:completionHandler:)]) { + [strongDelegate webView:webView didReceiveAuthenticationChallenge:challenge completionHandler:completionHandler]; + } else { + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + } +} + +- (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; + + if ([_base isWebViewJavascriptBridgeURL:url]) { + if ([_base isBridgeLoadedURL:url]) { + [_base injectJavascriptFile]; + } else if ([_base isQueueMessageURL:url]) { + [self WKFlushMessageQueue]; + } else { + [_base logUnkownMessage:url]; + } + decisionHandler(WKNavigationActionPolicyCancel); + return; + } + + if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)]) { + [_webViewDelegate webView:webView decidePolicyForNavigationAction:navigationAction decisionHandler:decisionHandler]; + } else { + decisionHandler(WKNavigationActionPolicyAllow); + } +} + +- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation { + if (webView != _webView) { return; } + + __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; + if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didStartProvisionalNavigation:)]) { + [strongDelegate webView:webView didStartProvisionalNavigation:navigation]; + } +} + + +- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error { + if (webView != _webView) { return; } + + __strong typeof(_webViewDelegate) strongDelegate = _webViewDelegate; + if (strongDelegate && [strongDelegate respondsToSelector:@selector(webView:didFailNavigation:withError:)]) { + [strongDelegate webView:webView didFailNavigation:navigation withError:error]; + } +} + +- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error { + if (webView != _webView) { return; } + + __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]; + return NULL; +} + + + +@end + + +#endif diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.h b/WebViewJavascriptBridge/WebViewJavascriptBridge.h new file mode 100755 index 0000000..cbcc1cb --- /dev/null +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.h @@ -0,0 +1,43 @@ +// +// WebViewJavascriptBridge.h +// ExampleApp-iOS +// +// Created by Marcus Westin on 6/14/13. +// Copyright (c) 2013 Marcus Westin. All rights reserved. +// + +#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 + +#define WVJB_PLATFORM_OSX +#define WVJB_WEBVIEW_TYPE WebView +#define WVJB_WEBVIEW_DELEGATE_TYPE NSObject +#define WVJB_WEBVIEW_DELEGATE_INTERFACE NSObject + + +@interface WebViewJavascriptBridge : WVJB_WEBVIEW_DELEGATE_INTERFACE + + ++ (instancetype)bridgeForWebView:(id)webView; ++ (instancetype)bridge:(id)webView; + ++ (void)enableLogging; ++ (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; +- (void)setWebViewDelegate:(id)webViewDelegate; +- (void)disableJavscriptAlertBoxSafetyTimeout; + +@end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge.m b/WebViewJavascriptBridge/WebViewJavascriptBridge.m new file mode 100755 index 0000000..033f7ef --- /dev/null +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge.m @@ -0,0 +1,142 @@ +// +// WebViewJavascriptBridge.m +// ExampleApp-iOS +// +// Created by Marcus Westin on 6/14/13. +// Copyright (c) 2013 Marcus Westin. All rights reserved. +// + +#import "WebViewJavascriptBridge.h" + +#if defined(supportsWKWebView) +#import "WKWebViewJavascriptBridge.h" +#endif + +#if __has_feature(objc_arc_weak) + #define WVJB_WEAK __weak +#else + #define WVJB_WEAK __unsafe_unretained +#endif + +@implementation WebViewJavascriptBridge { + WVJB_WEAK WVJB_WEBVIEW_TYPE* _webView; + WVJB_WEAK id _webViewDelegate; + long _uniqueId; + WebViewJavascriptBridgeBase *_base; +} + +/* API + *****/ + ++ (void)enableLogging { + [WebViewJavascriptBridgeBase enableLogging]; +} ++ (void)setLogMaxLength:(int)length { + [WebViewJavascriptBridgeBase setLogMaxLength: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]; + } +#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 { + _webViewDelegate = webViewDelegate; +} + +- (void)send:(id)data { + [self send:data responseCallback:nil]; +} + +- (void)send:(id)data responseCallback:(WVJBResponseCallback)responseCallback { + [_base sendData:data responseCallback:responseCallback handlerName:nil]; +} + +- (void)callHandler:(NSString *)handlerName { + [self callHandler:handlerName data:nil responseCallback:nil]; +} + +- (void)callHandler:(NSString *)handlerName data:(id)data { + [self callHandler:handlerName data:data responseCallback:nil]; +} + +- (void)callHandler:(NSString *)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback { + [_base sendData:data responseCallback:responseCallback handlerName:handlerName]; +} + +- (void)registerHandler:(NSString *)handlerName handler:(WVJBHandler)handler { + _base.messageHandlers[handlerName] = [handler copy]; +} + +- (void)removeHandler:(NSString *)handlerName { + [_base.messageHandlers removeObjectForKey:handlerName]; +} + +- (void)disableJavscriptAlertBoxSafetyTimeout { + [_base disableJavscriptAlertBoxSafetyTimeout]; +} + + +/* Platform agnostic internals + *****************************/ + +- (void)dealloc { + [self _platformSpecificDealloc]; + _base = nil; + _webView = nil; + _webViewDelegate = nil; +} + +- (NSString*) _evaluateJavascript:(NSString*)javascriptCommand { + return [_webView stringByEvaluatingJavaScriptFromString:javascriptCommand]; +} + +/* Platform specific internals: OSX + **********************************/ + +- (void) _platformSpecificSetup:(WVJB_WEBVIEW_TYPE*)webView { + _webView = webView; + _webView.policyDelegate = self; + _base = [[WebViewJavascriptBridgeBase alloc] init]; + _base.delegate = self; +} + +- (void) _platformSpecificDealloc { + _webView.policyDelegate = nil; +} + +- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id)listener { + if (webView != _webView) { return; } + + NSURL *url = [request URL]; + if ([_base isWebViewJavascriptBridgeURL:url]) { + if ([_base isBridgeLoadedURL:url]) { + [_base injectJavascriptFile]; + } else if ([_base isQueueMessageURL:url]) { + NSString *messageQueueString = [self _evaluateJavascript:[_base webViewJavascriptFetchQueyCommand]]; + [_base flushMessageQueue:messageQueueString]; + } else { + [_base logUnkownMessage:url]; + } + [listener ignore]; + } else if (_webViewDelegate && [_webViewDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:request:frame:decisionListener:)]) { + [_webViewDelegate webView:webView decidePolicyForNavigationAction:actionInformation request:request frame:frame decisionListener:listener]; + } else { + [listener use]; + } +} + +@end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h new file mode 100755 index 0000000..54d80ac --- /dev/null +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.h @@ -0,0 +1,46 @@ +// +// WebViewJavascriptBridgeBase.h +// +// Created by @LokiMeyburg on 10/15/14. +// Copyright (c) 2014 @LokiMeyburg. All rights reserved. +// + +#import + +#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); +typedef NSDictionary WVJBMessage; + +@protocol WebViewJavascriptBridgeBaseDelegate +- (NSString*) _evaluateJavascript:(NSString*)javascriptCommand; +@end + +@interface WebViewJavascriptBridgeBase : NSObject + + +@property (weak, nonatomic) id delegate; +@property (strong, nonatomic) NSMutableArray* startupMessageQueue; +@property (strong, nonatomic) NSMutableDictionary* responseCallbacks; +@property (strong, nonatomic) NSMutableDictionary* messageHandlers; +@property (strong, nonatomic) WVJBHandler messageHandler; + ++ (void)enableLogging; ++ (void)setLogMaxLength:(int)length; +- (void)reset; +- (void)sendData:(id)data responseCallback:(WVJBResponseCallback)responseCallback handlerName:(NSString*)handlerName; +- (void)flushMessageQueue:(NSString *)messageQueueString; +- (void)injectJavascriptFile; +- (BOOL)isWebViewJavascriptBridgeURL:(NSURL*)url; +- (BOOL)isQueueMessageURL:(NSURL*)urll; +- (BOOL)isBridgeLoadedURL:(NSURL*)urll; +- (void)logUnkownMessage:(NSURL*)url; +- (NSString *)webViewJavascriptCheckCommand; +- (NSString *)webViewJavascriptFetchQueyCommand; +- (void)disableJavscriptAlertBoxSafetyTimeout; + +@end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m new file mode 100755 index 0000000..3ec26ed --- /dev/null +++ b/WebViewJavascriptBridge/WebViewJavascriptBridgeBase.m @@ -0,0 +1,221 @@ +// +// WebViewJavascriptBridgeBase.m +// +// Created by @LokiMeyburg on 10/15/14. +// Copyright (c) 2014 @LokiMeyburg. All rights reserved. +// + +#import +#import "WebViewJavascriptBridgeBase.h" +#import "WebViewJavascriptBridge_JS.h" + +@implementation WebViewJavascriptBridgeBase { + __weak id _webViewDelegate; + long _uniqueId; +} + +static bool logging = false; +static int logMaxLength = 500; + ++ (void)enableLogging { logging = true; } ++ (void)setLogMaxLength:(int)length { logMaxLength = length;} + +- (id)init { + if (self = [super init]) { + self.messageHandlers = [NSMutableDictionary dictionary]; + self.startupMessageQueue = [NSMutableArray array]; + self.responseCallbacks = [NSMutableDictionary dictionary]; + _uniqueId = 0; + } + return self; +} + +- (void)dealloc { + self.startupMessageQueue = nil; + self.responseCallbacks = nil; + self.messageHandlers = nil; +} + +- (void)reset { + self.startupMessageQueue = [NSMutableArray array]; + self.responseCallbacks = [NSMutableDictionary dictionary]; + _uniqueId = 0; +} + +- (void)sendData:(id)data responseCallback:(WVJBResponseCallback)responseCallback handlerName:(NSString*)handlerName { + NSMutableDictionary* message = [NSMutableDictionary dictionary]; + + if (data) { + message[@"data"] = data; + } + + if (responseCallback) { + NSString* callbackId = [NSString stringWithFormat:@"objc_cb_%ld", ++_uniqueId]; + self.responseCallbacks[callbackId] = [responseCallback copy]; + message[@"callbackId"] = callbackId; + } + + if (handlerName) { + message[@"handlerName"] = handlerName; + } + [self _queueMessage:message]; +} + +- (void)flushMessageQueue:(NSString *)messageQueueString{ + if (messageQueueString == nil || messageQueueString.length == 0) { + NSLog(@"WebViewJavascriptBridge: WARNING: ObjC got nil while fetching the message queue JSON from webview. This can happen if the WebViewJavascriptBridge JS is not currently present in the webview, e.g if the webview just loaded a new page."); + return; + } + + id messages = [self _deserializeMessageJSON:messageQueueString]; + for (WVJBMessage* message in messages) { + if (![message isKindOfClass:[WVJBMessage class]]) { + NSLog(@"WebViewJavascriptBridge: WARNING: Invalid %@ received: %@", [message class], message); + continue; + } + [self _log:@"RCVD" json:message]; + + NSString* responseId = message[@"responseId"]; + if (responseId) { + WVJBResponseCallback responseCallback = _responseCallbacks[responseId]; + responseCallback(message[@"responseData"]); + [self.responseCallbacks removeObjectForKey:responseId]; + } else { + WVJBResponseCallback responseCallback = NULL; + NSString* callbackId = message[@"callbackId"]; + if (callbackId) { + responseCallback = ^(id responseData) { + if (responseData == nil) { + responseData = [NSNull null]; + } + + WVJBMessage* msg = @{ @"responseId":callbackId, @"responseData":responseData }; + [self _queueMessage:msg]; + }; + } else { + responseCallback = ^(id ignoreResponseData) { + // Do nothing + }; + } + + WVJBHandler handler = self.messageHandlers[message[@"handlerName"]]; + + if (!handler) { + NSLog(@"WVJBNoHandlerException, No handler for message from JS: %@", message); + continue; + } + + handler(message[@"data"], responseCallback); + } + } +} + +- (void)injectJavascriptFile { + NSString *js = WebViewJavascriptBridge_js(); + [self _evaluateJavascript:js]; + if (self.startupMessageQueue) { + NSArray* queue = self.startupMessageQueue; + self.startupMessageQueue = nil; + for (id queuedMessage in queue) { + [self _dispatchMessage:queuedMessage]; + } + } +} + +- (BOOL)isWebViewJavascriptBridgeURL:(NSURL*)url { + if (![self isSchemeMatch:url]) { + return NO; + } + 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 { + NSString* host = url.host.lowercaseString; + return [self isSchemeMatch:url] && [host isEqualToString:kQueueHasMessage]; +} + +- (BOOL)isBridgeLoadedURL:(NSURL*)url { + NSString* host = url.host.lowercaseString; + return [self isSchemeMatch:url] && [host isEqualToString:kBridgeLoaded]; +} + +- (void)logUnkownMessage:(NSURL*)url { + NSLog(@"WebViewJavascriptBridge: WARNING: Received unknown WebViewJavascriptBridge command %@", [url absoluteString]); +} + +- (NSString *)webViewJavascriptCheckCommand { + return @"typeof WebViewJavascriptBridge == \'object\';"; +} + +- (NSString *)webViewJavascriptFetchQueyCommand { + return @"WebViewJavascriptBridge._fetchQueue();"; +} + +- (void)disableJavscriptAlertBoxSafetyTimeout { + [self sendData:nil responseCallback:nil handlerName:@"_disableJavascriptAlertBoxSafetyTimeout"]; +} + +// Private +// ------------------------------------------- + +- (void) _evaluateJavascript:(NSString *)javascriptCommand { + [self.delegate _evaluateJavascript:javascriptCommand]; +} + +- (void)_queueMessage:(WVJBMessage*)message { + if (self.startupMessageQueue) { + [self.startupMessageQueue addObject:message]; + } else { + [self _dispatchMessage:message]; + } +} + +- (void)_dispatchMessage:(WVJBMessage*)message { + NSString *messageJSON = [self _serializeMessage:message pretty:NO]; + [self _log:@"SEND" json:messageJSON]; + messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"]; + messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]; + messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\'" withString:@"\\\'"]; + messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"]; + messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\r" withString:@"\\r"]; + messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\f" withString:@"\\f"]; + messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\u2028" withString:@"\\u2028"]; + messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\u2029" withString:@"\\u2029"]; + + NSString* javascriptCommand = [NSString stringWithFormat:@"WebViewJavascriptBridge._handleMessageFromObjC('%@');", messageJSON]; + if ([[NSThread currentThread] isMainThread]) { + [self _evaluateJavascript:javascriptCommand]; + + } else { + dispatch_sync(dispatch_get_main_queue(), ^{ + [self _evaluateJavascript:javascriptCommand]; + }); + } +} + +- (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 { + return [NSJSONSerialization JSONObjectWithData:[messageJSON dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingAllowFragments error:nil]; +} + +- (void)_log:(NSString *)action json:(id)json { + if (!logging) { return; } + if (![json isKindOfClass:[NSString class]]) { + json = [self _serializeMessage:json pretty:YES]; + } + if ([json length] > logMaxLength) { + NSLog(@"WVJB %@: %@ [...]", action, [json substringToIndex:logMaxLength]); + } else { + NSLog(@"WVJB %@: %@", action, json); + } +} + +@end diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h new file mode 100644 index 0000000..9c857f1 --- /dev/null +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.h @@ -0,0 +1,3 @@ +#import + +NSString * WebViewJavascriptBridge_js(void); diff --git a/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m new file mode 100644 index 0000000..670a552 --- /dev/null +++ b/WebViewJavascriptBridge/WebViewJavascriptBridge_JS.m @@ -0,0 +1,139 @@ +// 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; + } + + if (!window.onerror) { + window.onerror = function(msg, url, line) { + console.log("WebViewJavascriptBridge: ERROR:" + msg + "@" + url + ":" + line); + } + } + window.WebViewJavascriptBridge = { + registerHandler: registerHandler, + callHandler: callHandler, + disableJavscriptAlertBoxSafetyTimeout: disableJavscriptAlertBoxSafetyTimeout, + _fetchQueue: _fetchQueue, + _handleMessageFromObjC: _handleMessageFromObjC + }; + + var messagingIframe; + var sendMessageQueue = []; + var messageHandlers = {}; + + var CUSTOM_PROTOCOL_SCHEME = 'https'; + var QUEUE_HAS_MESSAGE = '__wvjb_queue_message__'; + + var responseCallbacks = {}; + var uniqueId = 1; + var dispatchMessagesWithTimeoutSafety = true; + + function registerHandler(handlerName, handler) { + messageHandlers[handlerName] = handler; + } + + function callHandler(handlerName, data, responseCallback) { + if (arguments.length == 2 && typeof data == 'function') { + responseCallback = data; + data = null; + } + _doSend({ handlerName:handlerName, data:data }, responseCallback); + } + function disableJavscriptAlertBoxSafetyTimeout() { + dispatchMessagesWithTimeoutSafety = false; + } + + function _doSend(message, responseCallback) { + if (responseCallback) { + var callbackId = 'cb_'+(uniqueId++)+'_'+new Date().getTime(); + responseCallbacks[callbackId] = responseCallback; + message['callbackId'] = callbackId; + } + sendMessageQueue.push(message); + messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE; + } + + function _fetchQueue() { + var messageQueueString = JSON.stringify(sendMessageQueue); + sendMessageQueue = []; + return messageQueueString; + } + + function _dispatchMessageFromObjC(messageJSON) { + if (dispatchMessagesWithTimeoutSafety) { + setTimeout(_doDispatchMessageFromObjC); + } else { + _doDispatchMessageFromObjC(); + } + + function _doDispatchMessageFromObjC() { + var message = JSON.parse(messageJSON); + var messageHandler; + var responseCallback; + + if (message.responseId) { + responseCallback = responseCallbacks[message.responseId]; + if (!responseCallback) { + return; + } + responseCallback(message.responseData); + delete responseCallbacks[message.responseId]; + } else { + if (message.callbackId) { + var callbackResponseId = message.callbackId; + responseCallback = function(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 { + handler(message.data, responseCallback); + } + } + } + } + + function _handleMessageFromObjC(messageJSON) { + _dispatchMessageFromObjC(messageJSON); + } + + messagingIframe = document.createElement('iframe'); + messagingIframe.style.display = 'none'; + messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE; + document.documentElement.appendChild(messagingIframe); + + registerHandler("_disableJavascriptAlertBoxSafetyTimeout", disableJavscriptAlertBoxSafetyTimeout); + + setTimeout(_callWVJBCallbacks, 0); + function _callWVJBCallbacks() { + var callbacks = window.WVJBCallbacks; + delete window.WVJBCallbacks; + for (var i=0; i