diff --git a/ios/CapacitorCordova/CapacitorCordova.xcodeproj/project.pbxproj b/ios/CapacitorCordova/CapacitorCordova.xcodeproj/project.pbxproj index 905dfd656..351524b82 100644 --- a/ios/CapacitorCordova/CapacitorCordova.xcodeproj/project.pbxproj +++ b/ios/CapacitorCordova/CapacitorCordova.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 0B61A7E52B114AA00035F2DB /* CDVWebViewProcessPoolFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B61A7E32B114A9F0035F2DB /* CDVWebViewProcessPoolFactory.m */; }; + 0B61A7E62B114AA00035F2DB /* CDVWebViewProcessPoolFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B61A7E42B114AA00035F2DB /* CDVWebViewProcessPoolFactory.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2F4F657C2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F4F657A2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.m */; }; 2F4F657D2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F4F657B2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2F5C86E11FE94845004B09C7 /* CapacitorCordova.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C86DF1FE94845004B09C7 /* CapacitorCordova.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -37,6 +39,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 0B61A7E32B114A9F0035F2DB /* CDVWebViewProcessPoolFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVWebViewProcessPoolFactory.m; sourceTree = ""; }; + 0B61A7E42B114AA00035F2DB /* CDVWebViewProcessPoolFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVWebViewProcessPoolFactory.h; sourceTree = ""; }; 2F4F657A2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+CordovaPreferences.m"; sourceTree = ""; }; 2F4F657B2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+CordovaPreferences.h"; sourceTree = ""; }; 2F5C86DC1FE94845004B09C7 /* Cordova.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cordova.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -144,6 +148,8 @@ 2F4F657A2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.m */, 2F856BFD203DEB320047344A /* CDVViewController.h */, 2F856BFE203DEB320047344A /* CDVViewController.m */, + 0B61A7E42B114AA00035F2DB /* CDVWebViewProcessPoolFactory.h */, + 0B61A7E32B114A9F0035F2DB /* CDVWebViewProcessPoolFactory.m */, ); path = Public; sourceTree = ""; @@ -169,6 +175,7 @@ 2F8AC284217F3A20008C2C33 /* CDVURLProtocol.h in Headers */, 2F92AB5324D9ABA000954A4A /* CDVPlugin+Resources.h in Headers */, 62959B66252524CD00A3D7F1 /* CDVScreenOrientationDelegate.h in Headers */, + 0B61A7E62B114AA00035F2DB /* CDVWebViewProcessPoolFactory.h in Headers */, 62959B6A252524D700A3D7F1 /* CDVPluginManager.h in Headers */, 2F5C86E11FE94845004B09C7 /* CapacitorCordova.h in Headers */, ); @@ -247,6 +254,7 @@ 2F5C871F1FE98418004B09C7 /* CDVCommandDelegateImpl.m in Sources */, 2F5C871D1FE98418004B09C7 /* CDVPluginResult.m in Sources */, 2F4F657C2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.m in Sources */, + 0B61A7E52B114AA00035F2DB /* CDVWebViewProcessPoolFactory.m in Sources */, 2F5C87211FE98418004B09C7 /* CDVPlugin.m in Sources */, 2F92AB5224D9ABA000954A4A /* CDVPlugin+Resources.m in Sources */, 2FAD9773203C77B9000D30F8 /* CDVConfigParser.m in Sources */, diff --git a/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h b/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h index bee4ca2ea..a2ce9d5db 100644 --- a/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h +++ b/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h @@ -20,4 +20,5 @@ FOUNDATION_EXPORT const unsigned char CapacitorCordovaVersionString[]; #import #import #import +#import #import diff --git a/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDV.h b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDV.h index c4d1d526f..8f8fc040f 100644 --- a/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDV.h +++ b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDV.h @@ -25,4 +25,4 @@ #import "CDVViewController.h" #import "CDVURLProtocol.h" #import "CDVScreenOrientationDelegate.h" - +#import "CDVWebViewProcessPoolFactory.h" diff --git a/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVWebViewProcessPoolFactory.h b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVWebViewProcessPoolFactory.h new file mode 100644 index 000000000..b15628914 --- /dev/null +++ b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVWebViewProcessPoolFactory.h @@ -0,0 +1,27 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + */ + +#import + +@interface CDVWebViewProcessPoolFactory : NSObject +@property (nonatomic, retain) WKProcessPool* sharedPool; + ++(instancetype) sharedFactory; +-(WKProcessPool*) sharedProcessPool; +@end diff --git a/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVWebViewProcessPoolFactory.m b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVWebViewProcessPoolFactory.m new file mode 100644 index 000000000..3781f48a4 --- /dev/null +++ b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVWebViewProcessPoolFactory.m @@ -0,0 +1,49 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + */ + +@import Foundation; +@import WebKit; +#import + +static CDVWebViewProcessPoolFactory *factory = nil; + +@implementation CDVWebViewProcessPoolFactory + ++ (instancetype)sharedFactory +{ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + factory = [[CDVWebViewProcessPoolFactory alloc] init]; + }); + + return factory; +} + +- (instancetype)init +{ + if (self = [super init]) { + _sharedPool = [[WKProcessPool alloc] init]; + } + return self; +} + +- (WKProcessPool*) sharedProcessPool { + return _sharedPool; +} +@end