├── .gitignore ├── DemoApp ├── SimpleBrowser.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── SimpleBrowser.xcscheme ├── SimpleBrowser │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── BrowserViewController.swift │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Back.imageset │ │ │ ├── Back.png │ │ │ └── Contents.json │ │ └── Forward.imageset │ │ │ ├── Contents.json │ │ │ └── Forward.png │ ├── Info.plist │ └── ja.lproj │ │ ├── LaunchScreen.strings │ │ └── Main.strings └── SimpleBrowserTests │ ├── Info.plist │ └── SimpleBrowserTests.swift ├── LICENSE ├── Package.swift ├── README.md ├── Sources └── WebKitPlus │ ├── Functions.swift │ ├── Resources │ ├── en.lproj │ │ └── Localizable.strings │ └── ja.lproj │ │ └── Localizable.strings │ ├── UIAlertController+Init.swift │ ├── URLProtectionSpace+UserCredential.swift │ ├── WKUIDelegatePlus.swift │ ├── WebKitPlus.h │ ├── WebViewObserver.swift │ └── ZenWebViewController.swift ├── Tests └── WebKitPlusTests │ └── WebKitPlusTests.swift ├── WebKitPlus.podspec └── circle.yml /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject 91 | / 92 | -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 52; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3F33CD6D1AA9705B00E56293 /* BrowserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F33CD6C1AA9705B00E56293 /* BrowserViewController.swift */; }; 11 | 3FE36B581AA902DD005D06FE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FE36B571AA902DD005D06FE /* AppDelegate.swift */; }; 12 | 3FE36B5D1AA902DD005D06FE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3FE36B5B1AA902DD005D06FE /* Main.storyboard */; }; 13 | 3FE36B5F1AA902DD005D06FE /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3FE36B5E1AA902DD005D06FE /* Images.xcassets */; }; 14 | 3FE36B621AA902DD005D06FE /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3FE36B601AA902DD005D06FE /* LaunchScreen.xib */; }; 15 | 3FE36B6E1AA902DD005D06FE /* SimpleBrowserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FE36B6D1AA902DD005D06FE /* SimpleBrowserTests.swift */; }; 16 | 6DAEE79927A7CDE900FC7A97 /* WebKitPlus in Frameworks */ = {isa = PBXBuildFile; productRef = 6DAEE79827A7CDE900FC7A97 /* WebKitPlus */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | 3FE36B681AA902DD005D06FE /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = 3FE36B4A1AA902DD005D06FE /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = 3FE36B511AA902DD005D06FE; 25 | remoteInfo = SimpleBrowser; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXCopyFilesBuildPhase section */ 30 | 3FE36BC51AAAE65E005D06FE /* Copy Frameworks */ = { 31 | isa = PBXCopyFilesBuildPhase; 32 | buildActionMask = 2147483647; 33 | dstPath = ""; 34 | dstSubfolderSpec = 10; 35 | files = ( 36 | ); 37 | name = "Copy Frameworks"; 38 | runOnlyForDeploymentPostprocessing = 0; 39 | }; 40 | /* End PBXCopyFilesBuildPhase section */ 41 | 42 | /* Begin PBXFileReference section */ 43 | 3F33CD6C1AA9705B00E56293 /* BrowserViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BrowserViewController.swift; sourceTree = ""; }; 44 | 3FE36B521AA902DD005D06FE /* SimpleBrowser.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SimpleBrowser.app; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 3FE36B561AA902DD005D06FE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | 3FE36B571AA902DD005D06FE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 47 | 3FE36B5C1AA902DD005D06FE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 48 | 3FE36B5E1AA902DD005D06FE /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 49 | 3FE36B611AA902DD005D06FE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 50 | 3FE36B671AA902DD005D06FE /* SimpleBrowserTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SimpleBrowserTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 3FE36B6C1AA902DD005D06FE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 3FE36B6D1AA902DD005D06FE /* SimpleBrowserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleBrowserTests.swift; sourceTree = ""; }; 53 | 3FE36BC81AAAE926005D06FE /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/LaunchScreen.strings; sourceTree = ""; }; 54 | 3FE36BC91AAAE926005D06FE /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Main.strings; sourceTree = ""; }; 55 | 6DAEE79627A7CDA000FC7A97 /* WebKitPlus */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = WebKitPlus; path = ..; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | 3FE36B4F1AA902DD005D06FE /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | 6DAEE79927A7CDE900FC7A97 /* WebKitPlus in Frameworks */, 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | 3FE36B641AA902DD005D06FE /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | /* End PBXFrameworksBuildPhase section */ 75 | 76 | /* Begin PBXGroup section */ 77 | 3FE36B491AA902DD005D06FE = { 78 | isa = PBXGroup; 79 | children = ( 80 | 6DAEE79527A7CDA000FC7A97 /* Packages */, 81 | 3FE36B541AA902DD005D06FE /* SimpleBrowser */, 82 | 3FE36B6A1AA902DD005D06FE /* SimpleBrowserTests */, 83 | 3FE36B531AA902DD005D06FE /* Products */, 84 | 6DAEE79727A7CDE900FC7A97 /* Frameworks */, 85 | ); 86 | sourceTree = ""; 87 | }; 88 | 3FE36B531AA902DD005D06FE /* Products */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | 3FE36B521AA902DD005D06FE /* SimpleBrowser.app */, 92 | 3FE36B671AA902DD005D06FE /* SimpleBrowserTests.xctest */, 93 | ); 94 | name = Products; 95 | sourceTree = ""; 96 | }; 97 | 3FE36B541AA902DD005D06FE /* SimpleBrowser */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 3FE36B571AA902DD005D06FE /* AppDelegate.swift */, 101 | 3F33CD6C1AA9705B00E56293 /* BrowserViewController.swift */, 102 | 3FE36B5E1AA902DD005D06FE /* Images.xcassets */, 103 | 3FE36B601AA902DD005D06FE /* LaunchScreen.xib */, 104 | 3FE36B5B1AA902DD005D06FE /* Main.storyboard */, 105 | 3FE36B551AA902DD005D06FE /* Supporting Files */, 106 | ); 107 | path = SimpleBrowser; 108 | sourceTree = ""; 109 | }; 110 | 3FE36B551AA902DD005D06FE /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 3FE36B561AA902DD005D06FE /* Info.plist */, 114 | ); 115 | name = "Supporting Files"; 116 | sourceTree = ""; 117 | }; 118 | 3FE36B6A1AA902DD005D06FE /* SimpleBrowserTests */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 3FE36B6D1AA902DD005D06FE /* SimpleBrowserTests.swift */, 122 | 3FE36B6B1AA902DD005D06FE /* Supporting Files */, 123 | ); 124 | path = SimpleBrowserTests; 125 | sourceTree = ""; 126 | }; 127 | 3FE36B6B1AA902DD005D06FE /* Supporting Files */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 3FE36B6C1AA902DD005D06FE /* Info.plist */, 131 | ); 132 | name = "Supporting Files"; 133 | sourceTree = ""; 134 | }; 135 | 6DAEE79527A7CDA000FC7A97 /* Packages */ = { 136 | isa = PBXGroup; 137 | children = ( 138 | 6DAEE79627A7CDA000FC7A97 /* WebKitPlus */, 139 | ); 140 | name = Packages; 141 | sourceTree = ""; 142 | }; 143 | 6DAEE79727A7CDE900FC7A97 /* Frameworks */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | ); 147 | name = Frameworks; 148 | sourceTree = ""; 149 | }; 150 | /* End PBXGroup section */ 151 | 152 | /* Begin PBXNativeTarget section */ 153 | 3FE36B511AA902DD005D06FE /* SimpleBrowser */ = { 154 | isa = PBXNativeTarget; 155 | buildConfigurationList = 3FE36B711AA902DD005D06FE /* Build configuration list for PBXNativeTarget "SimpleBrowser" */; 156 | buildPhases = ( 157 | 3FE36B4E1AA902DD005D06FE /* Sources */, 158 | 3FE36B4F1AA902DD005D06FE /* Frameworks */, 159 | 3FE36B501AA902DD005D06FE /* Resources */, 160 | 3FE36BC51AAAE65E005D06FE /* Copy Frameworks */, 161 | ); 162 | buildRules = ( 163 | ); 164 | dependencies = ( 165 | ); 166 | name = SimpleBrowser; 167 | packageProductDependencies = ( 168 | 6DAEE79827A7CDE900FC7A97 /* WebKitPlus */, 169 | ); 170 | productName = SimpleBrowser; 171 | productReference = 3FE36B521AA902DD005D06FE /* SimpleBrowser.app */; 172 | productType = "com.apple.product-type.application"; 173 | }; 174 | 3FE36B661AA902DD005D06FE /* SimpleBrowserTests */ = { 175 | isa = PBXNativeTarget; 176 | buildConfigurationList = 3FE36B741AA902DD005D06FE /* Build configuration list for PBXNativeTarget "SimpleBrowserTests" */; 177 | buildPhases = ( 178 | 3FE36B631AA902DD005D06FE /* Sources */, 179 | 3FE36B641AA902DD005D06FE /* Frameworks */, 180 | 3FE36B651AA902DD005D06FE /* Resources */, 181 | ); 182 | buildRules = ( 183 | ); 184 | dependencies = ( 185 | 3FE36B691AA902DD005D06FE /* PBXTargetDependency */, 186 | ); 187 | name = SimpleBrowserTests; 188 | productName = SimpleBrowserTests; 189 | productReference = 3FE36B671AA902DD005D06FE /* SimpleBrowserTests.xctest */; 190 | productType = "com.apple.product-type.bundle.unit-test"; 191 | }; 192 | /* End PBXNativeTarget section */ 193 | 194 | /* Begin PBXProject section */ 195 | 3FE36B4A1AA902DD005D06FE /* Project object */ = { 196 | isa = PBXProject; 197 | attributes = { 198 | LastSwiftUpdateCheck = 0700; 199 | LastUpgradeCheck = 1320; 200 | ORGANIZATIONNAME = yashigani; 201 | TargetAttributes = { 202 | 3FE36B511AA902DD005D06FE = { 203 | CreatedOnToolsVersion = 6.1.1; 204 | LastSwiftMigration = 1130; 205 | }; 206 | 3FE36B661AA902DD005D06FE = { 207 | CreatedOnToolsVersion = 6.1.1; 208 | LastSwiftMigration = 1130; 209 | TestTargetID = 3FE36B511AA902DD005D06FE; 210 | }; 211 | }; 212 | }; 213 | buildConfigurationList = 3FE36B4D1AA902DD005D06FE /* Build configuration list for PBXProject "SimpleBrowser" */; 214 | compatibilityVersion = "Xcode 3.2"; 215 | developmentRegion = en; 216 | hasScannedForEncodings = 0; 217 | knownRegions = ( 218 | en, 219 | Base, 220 | ja, 221 | ); 222 | mainGroup = 3FE36B491AA902DD005D06FE; 223 | productRefGroup = 3FE36B531AA902DD005D06FE /* Products */; 224 | projectDirPath = ""; 225 | projectRoot = ""; 226 | targets = ( 227 | 3FE36B511AA902DD005D06FE /* SimpleBrowser */, 228 | 3FE36B661AA902DD005D06FE /* SimpleBrowserTests */, 229 | ); 230 | }; 231 | /* End PBXProject section */ 232 | 233 | /* Begin PBXResourcesBuildPhase section */ 234 | 3FE36B501AA902DD005D06FE /* Resources */ = { 235 | isa = PBXResourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | 3FE36B5D1AA902DD005D06FE /* Main.storyboard in Resources */, 239 | 3FE36B621AA902DD005D06FE /* LaunchScreen.xib in Resources */, 240 | 3FE36B5F1AA902DD005D06FE /* Images.xcassets in Resources */, 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | }; 244 | 3FE36B651AA902DD005D06FE /* Resources */ = { 245 | isa = PBXResourcesBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | /* End PBXResourcesBuildPhase section */ 252 | 253 | /* Begin PBXSourcesBuildPhase section */ 254 | 3FE36B4E1AA902DD005D06FE /* Sources */ = { 255 | isa = PBXSourcesBuildPhase; 256 | buildActionMask = 2147483647; 257 | files = ( 258 | 3FE36B581AA902DD005D06FE /* AppDelegate.swift in Sources */, 259 | 3F33CD6D1AA9705B00E56293 /* BrowserViewController.swift in Sources */, 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | 3FE36B631AA902DD005D06FE /* Sources */ = { 264 | isa = PBXSourcesBuildPhase; 265 | buildActionMask = 2147483647; 266 | files = ( 267 | 3FE36B6E1AA902DD005D06FE /* SimpleBrowserTests.swift in Sources */, 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | /* End PBXSourcesBuildPhase section */ 272 | 273 | /* Begin PBXTargetDependency section */ 274 | 3FE36B691AA902DD005D06FE /* PBXTargetDependency */ = { 275 | isa = PBXTargetDependency; 276 | target = 3FE36B511AA902DD005D06FE /* SimpleBrowser */; 277 | targetProxy = 3FE36B681AA902DD005D06FE /* PBXContainerItemProxy */; 278 | }; 279 | /* End PBXTargetDependency section */ 280 | 281 | /* Begin PBXVariantGroup section */ 282 | 3FE36B5B1AA902DD005D06FE /* Main.storyboard */ = { 283 | isa = PBXVariantGroup; 284 | children = ( 285 | 3FE36B5C1AA902DD005D06FE /* Base */, 286 | 3FE36BC91AAAE926005D06FE /* ja */, 287 | ); 288 | name = Main.storyboard; 289 | sourceTree = ""; 290 | }; 291 | 3FE36B601AA902DD005D06FE /* LaunchScreen.xib */ = { 292 | isa = PBXVariantGroup; 293 | children = ( 294 | 3FE36B611AA902DD005D06FE /* Base */, 295 | 3FE36BC81AAAE926005D06FE /* ja */, 296 | ); 297 | name = LaunchScreen.xib; 298 | sourceTree = ""; 299 | }; 300 | /* End PBXVariantGroup section */ 301 | 302 | /* Begin XCBuildConfiguration section */ 303 | 3FE36B6F1AA902DD005D06FE /* Debug */ = { 304 | isa = XCBuildConfiguration; 305 | buildSettings = { 306 | ALWAYS_SEARCH_USER_PATHS = NO; 307 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 308 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 309 | CLANG_CXX_LIBRARY = "libc++"; 310 | CLANG_ENABLE_MODULES = YES; 311 | CLANG_ENABLE_OBJC_ARC = YES; 312 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 313 | CLANG_WARN_BOOL_CONVERSION = YES; 314 | CLANG_WARN_COMMA = YES; 315 | CLANG_WARN_CONSTANT_CONVERSION = YES; 316 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 317 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 318 | CLANG_WARN_EMPTY_BODY = YES; 319 | CLANG_WARN_ENUM_CONVERSION = YES; 320 | CLANG_WARN_INFINITE_RECURSION = YES; 321 | CLANG_WARN_INT_CONVERSION = YES; 322 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 323 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 324 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 325 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 326 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 327 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 328 | CLANG_WARN_STRICT_PROTOTYPES = YES; 329 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 330 | CLANG_WARN_UNREACHABLE_CODE = YES; 331 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 332 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 333 | COPY_PHASE_STRIP = NO; 334 | ENABLE_STRICT_OBJC_MSGSEND = YES; 335 | ENABLE_TESTABILITY = YES; 336 | GCC_C_LANGUAGE_STANDARD = gnu99; 337 | GCC_DYNAMIC_NO_PIC = NO; 338 | GCC_NO_COMMON_BLOCKS = YES; 339 | GCC_OPTIMIZATION_LEVEL = 0; 340 | GCC_PREPROCESSOR_DEFINITIONS = ( 341 | "DEBUG=1", 342 | "$(inherited)", 343 | ); 344 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 345 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 346 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 347 | GCC_WARN_UNDECLARED_SELECTOR = YES; 348 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 349 | GCC_WARN_UNUSED_FUNCTION = YES; 350 | GCC_WARN_UNUSED_VARIABLE = YES; 351 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 352 | MTL_ENABLE_DEBUG_INFO = YES; 353 | ONLY_ACTIVE_ARCH = YES; 354 | SDKROOT = iphoneos; 355 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 356 | SWIFT_VERSION = 5.0; 357 | }; 358 | name = Debug; 359 | }; 360 | 3FE36B701AA902DD005D06FE /* Release */ = { 361 | isa = XCBuildConfiguration; 362 | buildSettings = { 363 | ALWAYS_SEARCH_USER_PATHS = NO; 364 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 365 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 366 | CLANG_CXX_LIBRARY = "libc++"; 367 | CLANG_ENABLE_MODULES = YES; 368 | CLANG_ENABLE_OBJC_ARC = YES; 369 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 370 | CLANG_WARN_BOOL_CONVERSION = YES; 371 | CLANG_WARN_COMMA = YES; 372 | CLANG_WARN_CONSTANT_CONVERSION = YES; 373 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 374 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 375 | CLANG_WARN_EMPTY_BODY = YES; 376 | CLANG_WARN_ENUM_CONVERSION = YES; 377 | CLANG_WARN_INFINITE_RECURSION = YES; 378 | CLANG_WARN_INT_CONVERSION = YES; 379 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 380 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 381 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 382 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 383 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 384 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 385 | CLANG_WARN_STRICT_PROTOTYPES = YES; 386 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 387 | CLANG_WARN_UNREACHABLE_CODE = YES; 388 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 389 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 390 | COPY_PHASE_STRIP = YES; 391 | ENABLE_NS_ASSERTIONS = NO; 392 | ENABLE_STRICT_OBJC_MSGSEND = YES; 393 | GCC_C_LANGUAGE_STANDARD = gnu99; 394 | GCC_NO_COMMON_BLOCKS = YES; 395 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 396 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 397 | GCC_WARN_UNDECLARED_SELECTOR = YES; 398 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 399 | GCC_WARN_UNUSED_FUNCTION = YES; 400 | GCC_WARN_UNUSED_VARIABLE = YES; 401 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 402 | MTL_ENABLE_DEBUG_INFO = NO; 403 | SDKROOT = iphoneos; 404 | SWIFT_COMPILATION_MODE = wholemodule; 405 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 406 | SWIFT_VERSION = 5.0; 407 | VALIDATE_PRODUCT = YES; 408 | }; 409 | name = Release; 410 | }; 411 | 3FE36B721AA902DD005D06FE /* Debug */ = { 412 | isa = XCBuildConfiguration; 413 | buildSettings = { 414 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 415 | INFOPLIST_FILE = SimpleBrowser/Info.plist; 416 | LD_RUNPATH_SEARCH_PATHS = ( 417 | "$(inherited)", 418 | "@executable_path/Frameworks", 419 | ); 420 | PRODUCT_BUNDLE_IDENTIFIER = "jp.yashigani.$(PRODUCT_NAME:rfc1034identifier)"; 421 | PRODUCT_NAME = "$(TARGET_NAME)"; 422 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 423 | SWIFT_VERSION = 5.0; 424 | TARGETED_DEVICE_FAMILY = "1,2"; 425 | }; 426 | name = Debug; 427 | }; 428 | 3FE36B731AA902DD005D06FE /* Release */ = { 429 | isa = XCBuildConfiguration; 430 | buildSettings = { 431 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 432 | INFOPLIST_FILE = SimpleBrowser/Info.plist; 433 | LD_RUNPATH_SEARCH_PATHS = ( 434 | "$(inherited)", 435 | "@executable_path/Frameworks", 436 | ); 437 | PRODUCT_BUNDLE_IDENTIFIER = "jp.yashigani.$(PRODUCT_NAME:rfc1034identifier)"; 438 | PRODUCT_NAME = "$(TARGET_NAME)"; 439 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 440 | SWIFT_VERSION = 5.0; 441 | TARGETED_DEVICE_FAMILY = "1,2"; 442 | }; 443 | name = Release; 444 | }; 445 | 3FE36B751AA902DD005D06FE /* Debug */ = { 446 | isa = XCBuildConfiguration; 447 | buildSettings = { 448 | BUNDLE_LOADER = "$(TEST_HOST)"; 449 | FRAMEWORK_SEARCH_PATHS = ( 450 | "$(SDKROOT)/Developer/Library/Frameworks", 451 | "$(inherited)", 452 | ); 453 | GCC_PREPROCESSOR_DEFINITIONS = ( 454 | "DEBUG=1", 455 | "$(inherited)", 456 | ); 457 | INFOPLIST_FILE = SimpleBrowserTests/Info.plist; 458 | LD_RUNPATH_SEARCH_PATHS = ( 459 | "$(inherited)", 460 | "@executable_path/Frameworks", 461 | "@loader_path/Frameworks", 462 | ); 463 | PRODUCT_BUNDLE_IDENTIFIER = "jp.yashigani.$(PRODUCT_NAME:rfc1034identifier)"; 464 | PRODUCT_NAME = "$(TARGET_NAME)"; 465 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 466 | SWIFT_VERSION = 5.0; 467 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SimpleBrowser.app/SimpleBrowser"; 468 | }; 469 | name = Debug; 470 | }; 471 | 3FE36B761AA902DD005D06FE /* Release */ = { 472 | isa = XCBuildConfiguration; 473 | buildSettings = { 474 | BUNDLE_LOADER = "$(TEST_HOST)"; 475 | FRAMEWORK_SEARCH_PATHS = ( 476 | "$(SDKROOT)/Developer/Library/Frameworks", 477 | "$(inherited)", 478 | ); 479 | INFOPLIST_FILE = SimpleBrowserTests/Info.plist; 480 | LD_RUNPATH_SEARCH_PATHS = ( 481 | "$(inherited)", 482 | "@executable_path/Frameworks", 483 | "@loader_path/Frameworks", 484 | ); 485 | PRODUCT_BUNDLE_IDENTIFIER = "jp.yashigani.$(PRODUCT_NAME:rfc1034identifier)"; 486 | PRODUCT_NAME = "$(TARGET_NAME)"; 487 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 488 | SWIFT_VERSION = 5.0; 489 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SimpleBrowser.app/SimpleBrowser"; 490 | }; 491 | name = Release; 492 | }; 493 | /* End XCBuildConfiguration section */ 494 | 495 | /* Begin XCConfigurationList section */ 496 | 3FE36B4D1AA902DD005D06FE /* Build configuration list for PBXProject "SimpleBrowser" */ = { 497 | isa = XCConfigurationList; 498 | buildConfigurations = ( 499 | 3FE36B6F1AA902DD005D06FE /* Debug */, 500 | 3FE36B701AA902DD005D06FE /* Release */, 501 | ); 502 | defaultConfigurationIsVisible = 0; 503 | defaultConfigurationName = Release; 504 | }; 505 | 3FE36B711AA902DD005D06FE /* Build configuration list for PBXNativeTarget "SimpleBrowser" */ = { 506 | isa = XCConfigurationList; 507 | buildConfigurations = ( 508 | 3FE36B721AA902DD005D06FE /* Debug */, 509 | 3FE36B731AA902DD005D06FE /* Release */, 510 | ); 511 | defaultConfigurationIsVisible = 0; 512 | defaultConfigurationName = Release; 513 | }; 514 | 3FE36B741AA902DD005D06FE /* Build configuration list for PBXNativeTarget "SimpleBrowserTests" */ = { 515 | isa = XCConfigurationList; 516 | buildConfigurations = ( 517 | 3FE36B751AA902DD005D06FE /* Debug */, 518 | 3FE36B761AA902DD005D06FE /* Release */, 519 | ); 520 | defaultConfigurationIsVisible = 0; 521 | defaultConfigurationName = Release; 522 | }; 523 | /* End XCConfigurationList section */ 524 | 525 | /* Begin XCSwiftPackageProductDependency section */ 526 | 6DAEE79827A7CDE900FC7A97 /* WebKitPlus */ = { 527 | isa = XCSwiftPackageProductDependency; 528 | productName = WebKitPlus; 529 | }; 530 | /* End XCSwiftPackageProductDependency section */ 531 | }; 532 | rootObject = 3FE36B4A1AA902DD005D06FE /* Project object */; 533 | } 534 | -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser.xcodeproj/xcshareddata/xcschemes/SimpleBrowser.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 51 | 52 | 53 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 77 | 79 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SimpleBrowser 4 | // 5 | // Created by taiki on 3/6/15. 6 | // Copyright (c) 2015 yashigani. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser/BrowserViewController.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import WebKit 3 | import WebKitPlus 4 | 5 | class BrowserViewController: ZenWebViewController { 6 | @IBOutlet var progressBar: UIProgressView! 7 | @IBOutlet var goBackItem: UIBarButtonItem! 8 | @IBOutlet var goForwardItem: UIBarButtonItem! 9 | @IBOutlet var reloadItem: UIBarButtonItem! 10 | @IBOutlet var stopItem: UIBarButtonItem! 11 | @IBOutlet var shareItem: UIBarButtonItem! 12 | 13 | override var prefersStatusBarHidden: Bool { 14 | return navigationController?.isNavigationBarHidden ?? false 15 | } 16 | 17 | override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation { return .slide } 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | toolbarItems?.removeLast() 22 | webView.allowsBackForwardNavigationGestures = true 23 | webView.navigationDelegate = self 24 | 25 | // observe WebView status 26 | observer.onTitleChanged = updateTitle 27 | observer.onProgressChanged = updateProgress 28 | observer.onLoadingStatusChanged = updateStatus 29 | 30 | // hide navigation bar 31 | navigationController?.hidesBarsOnTap = true 32 | navigationController?.hidesBarsOnSwipe = true 33 | navigationController?.barHideOnSwipeGestureRecognizer.addTarget(self, action: #selector(BrowserViewController.updateStatusBar(_:))) 34 | 35 | let request = URLRequest(url: URL(string: "https://www.apple.com")!) 36 | webView.load(request) 37 | } 38 | 39 | // MARK: - Update UI 40 | 41 | func updateTitle(_ newTitle: String?) { 42 | title = newTitle 43 | } 44 | 45 | func updateProgress(_ progress: Double) { 46 | progressBar.progress = Float(progress) 47 | } 48 | 49 | func updateStatus(_ loading: Bool) { 50 | progressBar.isHidden = !loading 51 | toolbarItems?.remove(at: 5) 52 | toolbarItems?.insert(loading ? stopItem : reloadItem, at: 5) 53 | goBackItem.isEnabled = webView.canGoBack 54 | goForwardItem.isEnabled = webView.canGoForward 55 | shareItem.isEnabled = !loading 56 | } 57 | 58 | @objc func updateStatusBar(_: AnyObject?) { 59 | setNeedsStatusBarAppearanceUpdate() 60 | } 61 | 62 | // MARK: - Actions 63 | 64 | @IBAction func shareTapped(_: AnyObject?) { 65 | let vc = UIActivityViewController(activityItems: [webView.url!, webView.title!], applicationActivities: nil) 66 | vc.popoverPresentationController?.barButtonItem = shareItem 67 | navigationController?.present(vc, animated: true, completion: nil) 68 | } 69 | 70 | } 71 | 72 | extension BrowserViewController: WKNavigationDelegate { 73 | 74 | func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { 75 | guard let alert = UIAlertController(for: challenge, completion: completionHandler) else { 76 | // Should call `completionHandler` if `alertForAuthentication` return `.None`. 77 | completionHandler(.performDefaultHandling, nil) 78 | return 79 | } 80 | present(alert, animated: true, completion: nil) 81 | } 82 | 83 | } 84 | 85 | -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser/Images.xcassets/Back.imageset/Back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashigani/WebKitPlus/ac21eabdd856d78f49eb6ccd10164992d6fb07c0/DemoApp/SimpleBrowser/Images.xcassets/Back.imageset/Back.png -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser/Images.xcassets/Back.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "Back.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser/Images.xcassets/Forward.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "Forward.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser/Images.xcassets/Forward.imageset/Forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashigani/WebKitPlus/ac21eabdd856d78f49eb6ccd10164992d6fb07c0/DemoApp/SimpleBrowser/Images.xcassets/Forward.imageset/Forward.png -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser/ja.lproj/LaunchScreen.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "IBUILabel"; text = " Copyright (c) 2015 yashigani. All rights reserved."; ObjectID = "8ie-xW-0ye"; */ 3 | "8ie-xW-0ye.text" = " Copyright (c) 2015 yashigani. All rights reserved."; 4 | 5 | /* Class = "IBUILabel"; text = "SimpleBrowser"; ObjectID = "kId-c2-rCX"; */ 6 | "kId-c2-rCX.text" = "SimpleBrowser"; 7 | -------------------------------------------------------------------------------- /DemoApp/SimpleBrowser/ja.lproj/Main.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yashigani/WebKitPlus/ac21eabdd856d78f49eb6ccd10164992d6fb07c0/DemoApp/SimpleBrowser/ja.lproj/Main.strings -------------------------------------------------------------------------------- /DemoApp/SimpleBrowserTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /DemoApp/SimpleBrowserTests/SimpleBrowserTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleBrowserTests.swift 3 | // SimpleBrowserTests 4 | // 5 | // Created by taiki on 3/6/15. 6 | // Copyright (c) 2015 yashigani. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class SimpleBrowserTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Taiki Fukui 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "WebKitPlus", 8 | defaultLocalization: "en", 9 | platforms: [ 10 | .iOS(.v12), 11 | ], 12 | products: [ 13 | // Products define the executables and libraries a package produces, and make them visible to other packages. 14 | .library( 15 | name: "WebKitPlus", 16 | targets: ["WebKitPlus"]), 17 | ], 18 | dependencies: [ 19 | // Dependencies declare other packages that this package depends on. 20 | // .package(url: /* package url */, from: "1.0.0"), 21 | ], 22 | targets: [ 23 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 24 | // Targets can depend on other targets in this package, and on products in packages this package depends on. 25 | .target( 26 | name: "WebKitPlus", 27 | dependencies: []), 28 | .testTarget( 29 | name: "WebKitPlusTests", 30 | dependencies: ["WebKitPlus"]), 31 | ] 32 | ) 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WebKitPlus 2 | ========== 3 | 4 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 5 | 6 | A support library for WKWebView. 7 | 8 | ## Requirements 9 | 10 | - iOS 12.0 later 11 | 12 | ## Usage 13 | 14 | ### WKUIDelegatePlus 15 | `WKUIDelegatePlus` has standard implements(Present alerts from JavaScript) for `WKUIDelegate`. 16 | 17 | ``` swift 18 | override public func viewDidLoad() { 19 | super.viewDidLoad() 20 | UIDelegate = WKUIDelegatePlus(self) 21 | webView.UIDelegate = UIDelegate 22 | } 23 | ``` 24 | 25 | ### WebViewObserver 26 | It is funtastic that `WKWebView` has key-value observing compliant properties, but KVO is so ugly. `WebViewObserver` makes observable it by closure. 27 | 28 | ``` swift 29 | lazy var observer: WebViewObserver = WebViewObserver(self.webView) 30 | override public func viewDidLoad() { 31 | super.viewDidLoad() 32 | observer.onTitleChanged = { [weak self] in self?.title = $0 } 33 | observer.onProgressChanged = { [weak self] in self?.progressbar.progress = $0 } 34 | } 35 | ``` 36 | 37 | ### Authentication in navigation 38 | Use `UIAlertController (for: completion :)` to input informations of authentication. 39 | 40 | ``` swift 41 | /// in `WKNavigationDelegate` object 42 | func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { 43 | guard let alert = UIAlertController(for: challenge, completion: completionHandler) else { 44 | // Should call `completionHandler` if `alertForAuthentication` return `.None`. 45 | completionHandler(.performDefaultHandling, nil) 46 | return 47 | } 48 | present(alert, animated: true, completion: nil) 49 | } 50 | ``` 51 | 52 | ### ZenWebViewController 53 | `ZenWebViewController` is a Simple View Controller contains `WKWebView`. You can implement simple web browser with it. 54 | 55 | ## Author 56 | @yashigani 57 | 58 | ## License 59 | WebKitPlus is available under the MIT license. See the LICENSE file for more info. 60 | -------------------------------------------------------------------------------- /Sources/WebKitPlus/Functions.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | /// Return UIAlertController? that input form for user credential if needed. 4 | @available(*, deprecated, renamed: "UIAlertController(for:completion:)") 5 | public func alert(for challenge: URLAuthenticationChallenge, completion: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) -> UIAlertController? { 6 | return UIAlertController(for: challenge, completion: completion) 7 | } 8 | 9 | @available(*, unavailable, renamed: "UIAlertController(for:completion:)") 10 | public func alertForAuthentication(_ challenge: URLAuthenticationChallenge, _ completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) -> UIAlertController? { 11 | fatalError() 12 | } 13 | 14 | @available(*, deprecated, renamed: "UIAlertController(error:)") 15 | public func alert(for error: NSError) -> UIAlertController? { 16 | return UIAlertController(error: error) 17 | } 18 | 19 | @available(*, unavailable, renamed: "UIAlertController(error:)") 20 | public func alertForNavigationFailed(_ error: NSError) -> UIAlertController? { 21 | fatalError() 22 | } 23 | 24 | func localizedString(for key: String) -> String { 25 | let bundle = Bundle(for: WKUIDelegatePlus.self) 26 | return bundle.localizedString(forKey: key, value: key, table: nil) 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Sources/WebKitPlus/Resources/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | "OK" = "OK"; 2 | "Cancel" = "Cancel"; 3 | "user" = "user"; 4 | "password" = "password"; 5 | -------------------------------------------------------------------------------- /Sources/WebKitPlus/Resources/ja.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | "OK" = "OK"; 2 | "Cancel" = "キャンセル"; 3 | "user" = "ユーザー名"; 4 | "password" = "パスワード"; 5 | -------------------------------------------------------------------------------- /Sources/WebKitPlus/UIAlertController+Init.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | extension UIAlertController { 4 | public convenience init?(for challenge: URLAuthenticationChallenge, completion: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { 5 | let space = challenge.protectionSpace 6 | guard space.isUserCredential else { 7 | return nil 8 | } 9 | self.init(title: "\(space.`protocol`!)://\(space.host):\(space.port)", message: space.realm, preferredStyle: .alert) 10 | self.addTextField { 11 | $0.placeholder = localizedString(for: "user") 12 | } 13 | self.addTextField { 14 | $0.placeholder = localizedString(for: "password") 15 | $0.isSecureTextEntry = true 16 | } 17 | self.addAction(UIAlertAction(title: localizedString(for: "Cancel"), style: .cancel) { _ in 18 | completion(.cancelAuthenticationChallenge, nil) 19 | }) 20 | self.addAction(UIAlertAction(title: localizedString(for: "OK"), style: .default) { [weak self] _ in 21 | let textFields = self!.textFields! 22 | let credential = URLCredential(user: textFields[0].text!, password: textFields[1].text!, persistence: .forSession) 23 | completion(.useCredential, credential) 24 | }) 25 | } 26 | 27 | public convenience init?(error: NSError) { 28 | if error.domain == NSURLErrorDomain && error.code == NSURLErrorCancelled { 29 | return nil 30 | } 31 | // Ignore WebKitErrorFrameLoadInterruptedByPolicyChange 32 | if error.domain == "WebKitErrorDomain" && error.code == 102 { 33 | return nil 34 | } 35 | 36 | let title = error.userInfo[NSURLErrorFailingURLStringErrorKey] as? String 37 | let message = error.localizedDescription 38 | self.init(title: title, message: message, preferredStyle: .alert) 39 | self.addAction(UIAlertAction(title: localizedString(for: "OK"), style: .default) { _ in }) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Sources/WebKitPlus/URLProtectionSpace+UserCredential.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension URLProtectionSpace { 4 | internal var isUserCredential: Bool { 5 | switch authenticationMethod { 6 | case NSURLAuthenticationMethodDefault where `protocol` == "http": 7 | return true 8 | case NSURLAuthenticationMethodHTTPBasic, NSURLAuthenticationMethodHTTPDigest: 9 | return true 10 | default: 11 | return false 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Sources/WebKitPlus/WKUIDelegatePlus.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import WebKit 3 | 4 | public class WKUIDelegatePlus: NSObject { 5 | public var createNewWebView: (WKWebView, WKWebViewConfiguration, WKNavigationAction, WKWindowFeatures) -> WKWebView? = { _, _, _, _ in nil } 6 | public var runJavaScriptAlert: (UIAlertController, WKFrameInfo) -> Void = { _, _ in } 7 | 8 | public init(parentViewController viewController: UIViewController) { 9 | weak var vc = viewController 10 | runJavaScriptAlert = { alert, _ in 11 | vc?.present(alert, animated: true, completion: nil) 12 | } 13 | } 14 | 15 | } 16 | 17 | extension WKUIDelegatePlus: WKUIDelegate { 18 | 19 | public func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? { 20 | if let webView = createNewWebView(webView, configuration, navigationAction, windowFeatures) { 21 | return webView 22 | } else { 23 | webView.load(navigationAction.request) 24 | return nil 25 | } 26 | } 27 | 28 | public func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) { 29 | guard webView.window != nil else { 30 | completionHandler() 31 | return 32 | } 33 | 34 | let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert) 35 | alert.addAction(UIAlertAction(title: localizedString(for: "OK"), style: .default) { _ in 36 | completionHandler() 37 | }) 38 | runJavaScriptAlert(alert, frame) 39 | } 40 | 41 | public func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) { 42 | guard webView.window != nil else { 43 | completionHandler(false) 44 | return 45 | } 46 | 47 | let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert) 48 | alert.addAction(UIAlertAction(title: localizedString(for: "Cancel"), style: .cancel) { _ in 49 | completionHandler(false) 50 | }) 51 | alert.addAction(UIAlertAction(title: localizedString(for: "OK"), style: .default) { _ in 52 | completionHandler(true) 53 | }) 54 | runJavaScriptAlert(alert, frame) 55 | } 56 | 57 | public func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText: String?, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (String?) -> Void) { 58 | guard webView.window != nil else { 59 | completionHandler(nil) 60 | return 61 | } 62 | 63 | let alert = UIAlertController(title: nil, message: prompt, preferredStyle: .alert) 64 | alert.addTextField { $0.text = defaultText } 65 | alert.addAction(UIAlertAction(title: localizedString(for: "Cancel"), style: .cancel) { _ in 66 | completionHandler(nil) 67 | }) 68 | alert.addAction(UIAlertAction(title: localizedString(for: "OK"), style: .default) { _ in 69 | let textField = alert.textFields!.first! 70 | completionHandler(textField.text) 71 | }) 72 | runJavaScriptAlert(alert, frame) 73 | } 74 | 75 | } 76 | 77 | public extension WKUIDelegatePlus { 78 | @available(*, unavailable, renamed: "init(parentViewController:)") 79 | convenience init(_ viewController: UIViewController) { fatalError() } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /Sources/WebKitPlus/WebKitPlus.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | //! Project version number for WebKitPlus. 4 | FOUNDATION_EXPORT double WebKitPlusVersionNumber; 5 | 6 | //! Project version string for WebKitPlus. 7 | FOUNDATION_EXPORT const unsigned char WebKitPlusVersionString[]; 8 | 9 | // In this header, you should import all the public headers of your framework using statements like #import 10 | 11 | 12 | -------------------------------------------------------------------------------- /Sources/WebKitPlus/WebViewObserver.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import WebKit 3 | 4 | public class WebViewObserver: NSObject { 5 | enum KeyPath: String, CaseIterable { 6 | case title 7 | case url = "URL" 8 | case estimatedProgress 9 | case canGoBack 10 | case canGoForward 11 | case hasOnlySecureContent 12 | case loading 13 | } 14 | let webView: WKWebView 15 | private var context: UInt8 = 0 16 | private let keyPaths: [KeyPath] = KeyPath.allCases 17 | 18 | public var onTitleChanged: (String?) -> Void = { _ in } 19 | public var onURLChanged: (URL?) -> Void = { _ in } 20 | public var onProgressChanged: (Double) -> Void = { _ in } 21 | public var onCanGoBackChanged: (Bool) -> Void = { _ in } 22 | public var onCanGoForwardChanged: (Bool) -> Void = { _ in } 23 | public var onHasOnlySecureContentChanged: (Bool) -> Void = { _ in } 24 | public var onLoadingStatusChanged: (Bool) -> Void = { _ in } 25 | 26 | // MARK: - 27 | 28 | public init(obserbee webView: WKWebView) { 29 | self.webView = webView 30 | super.init() 31 | observeProperties() 32 | } 33 | 34 | private func observeProperties() { 35 | for k in keyPaths { 36 | webView.addObserver(self, forKeyPath: k.rawValue, options: .new, context: &context) 37 | } 38 | } 39 | 40 | deinit { 41 | for k in keyPaths { 42 | webView.removeObserver(self, forKeyPath: k.rawValue, context: &context) 43 | } 44 | } 45 | 46 | private func dispatchObserver(_ keyPath: KeyPath) { 47 | switch keyPath { 48 | case .title: onTitleChanged(webView.title) 49 | case .url: onURLChanged(webView.url) 50 | case .estimatedProgress: onProgressChanged(webView.estimatedProgress) 51 | case .canGoBack: onCanGoBackChanged(webView.canGoBack) 52 | case .canGoForward: onCanGoForwardChanged(webView.canGoForward) 53 | case .hasOnlySecureContent: onHasOnlySecureContentChanged(webView.hasOnlySecureContent) 54 | case .loading: onLoadingStatusChanged(webView.isLoading) 55 | } 56 | } 57 | 58 | // MARK: - Key Value Observation 59 | 60 | public override func observeValue(forKeyPath keyPath: String?, of ofObject: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) { 61 | guard context == &self.context else { 62 | return 63 | } 64 | if let keyPath = keyPath.flatMap(KeyPath.init) { 65 | dispatchObserver(keyPath) 66 | } 67 | } 68 | 69 | } 70 | 71 | public extension WebViewObserver { 72 | @available(*, unavailable, renamed: "init(obserbee:)") 73 | convenience init(_ webView: WKWebView) { fatalError() } 74 | 75 | } 76 | 77 | -------------------------------------------------------------------------------- /Sources/WebKitPlus/ZenWebViewController.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import WebKit 3 | 4 | /// Simple UIViewController with WKWebView 5 | open class ZenWebViewController: UIViewController { 6 | public lazy var configuration: WKWebViewConfiguration = WKWebViewConfiguration() 7 | public lazy var webView: WKWebView = WKWebView(frame: self.view.frame, configuration: self.configuration) 8 | public lazy var UIDelegate: WKUIDelegatePlus = WKUIDelegatePlus(parentViewController: self) 9 | public lazy var observer: WebViewObserver = WebViewObserver(obserbee: self.webView) 10 | 11 | override open func viewDidLoad() { 12 | super.viewDidLoad() 13 | webView.translatesAutoresizingMaskIntoConstraints = false 14 | webView.uiDelegate = UIDelegate 15 | view.insertSubview(webView, at: 0) 16 | 17 | webView.scrollView.contentInsetAdjustmentBehavior = .scrollableAxes 18 | 19 | let constraints = [ 20 | webView.topAnchor.constraint(equalTo: view.topAnchor), 21 | webView.bottomAnchor.constraint(equalTo: view.bottomAnchor), 22 | webView.leadingAnchor.constraint(equalTo: view.leadingAnchor), 23 | webView.trailingAnchor.constraint(equalTo: view.trailingAnchor) 24 | ] 25 | NSLayoutConstraint.activate(constraints) 26 | } 27 | 28 | // MARK: - IBAction 29 | 30 | @IBAction func goBack(_: AnyObject?) { 31 | webView.goBack() 32 | } 33 | 34 | @IBAction func goForward(_: AnyObject?) { 35 | webView.goForward() 36 | } 37 | 38 | @IBAction func reload(_: AnyObject?) { 39 | webView.reload() 40 | } 41 | 42 | @IBAction func reloadFromOrigin(_: AnyObject?) { 43 | webView.reloadFromOrigin() 44 | } 45 | 46 | @IBAction func stopLoading(_: AnyObject?) { 47 | webView.stopLoading() 48 | } 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /Tests/WebKitPlusTests/WebKitPlusTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import WebKitPlus 3 | 4 | final class WebKitPlusTests: XCTestCase { 5 | func testExample() throws { 6 | XCTAssert(true, "Pass") 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /WebKitPlus.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "WebKitPlus" 3 | s.version = "0.5.0" 4 | s.summary = "A support library for WKWebView." 5 | 6 | s.description = <<-DESC 7 | WebKitPlus is a support library for WKWebView in iOS Apps. 8 | DESC 9 | 10 | s.authors = { "yashigani" => "tai.fukui@gmail.com" } 11 | s.homepage = "https://github.com/yashigani/WebKitPlus" 12 | s.license = { :type => "MIT", :file => "LICENSE" } 13 | 14 | s.ios.deployment_target = "12.0" 15 | s.framework = "WebKit" 16 | s.source = { :git => "https://github.com/yashigani/WebKitPlus.git", :tag => "#{s.version}" } 17 | 18 | s.source_files = "Sources/WebKitPlus/**/*.{swift,h}" 19 | s.resource_bundles = { "WebKitPlus" => ["Sources/WebKitPlus/Resources/**/*.lproj"] } 20 | s.pod_target_xcconfig = { "APPLICATION_EXTENSION_API_ONLY" => "YES" } 21 | 22 | s.swift_version = "5.0" 23 | s.cocoapods_version = ">= 1.4.0" 24 | end 25 | 26 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | environment: 3 | LC_CTYPE: en_US.UTF-8 4 | xcode: 5 | version: "7.3" 6 | 7 | dependencies: 8 | override: 9 | - sudo gem install cocoapods 10 | - sudo gem install xcpretty 11 | 12 | test: 13 | override: 14 | - set -o pipefail && xcodebuild -scheme WebKitPlus-iOS -sdk iphonesimulator -derivedDataPath build | xcpretty -c 15 | --------------------------------------------------------------------------------