From dfc4306d48d76608a84dc6882875665b726a4f78 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Thu, 1 Oct 2020 15:29:50 -0400 Subject: [PATCH 01/40] Minor cleanup to eliminate compiler warnings in Capacitor Cordova project --- .../CapacitorCordova/Classes/Public/CDVCommandDelegate.h | 2 +- .../CapacitorCordova/Classes/Public/CDVCommandDelegateImpl.m | 4 ++-- .../CapacitorCordova/Classes/Public/CDVPluginResult.m | 2 +- .../CapacitorCordova/Classes/Public/CDVViewController.m | 3 +++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegate.h b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegate.h index 543ef237d2..45869bdea8 100644 --- a/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegate.h +++ b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegate.h @@ -44,6 +44,6 @@ typedef NSURL* (^ UrlTransformerBlock)(NSURL*); // Run the javascript - (void)evalJsHelper2:(NSString*)js; // Runs the given block on a background thread using a shared thread-pool. -- (void)runInBackground:(void (^)())block; +- (void)runInBackground:(void (^)(void))block; @end diff --git a/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegateImpl.m b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegateImpl.m index 0225d84375..29a02b7da7 100644 --- a/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegateImpl.m +++ b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegateImpl.m @@ -70,7 +70,7 @@ - (void)flushCommandQueueWithDelayedJs - (void)evalJsHelper2:(NSString*)js { dispatch_async(dispatch_get_main_queue(), ^{ - [_webView evaluateJavaScript:js completionHandler:^(id obj, NSError* error) { + [self->_webView evaluateJavaScript:js completionHandler:^(id obj, NSError* error) { // TODO: obj can be something other than string if ([obj isKindOfClass:[NSString class]]) { NSString* commandsJSON = (NSString*)obj; @@ -136,7 +136,7 @@ - (id)getCommandInstance:(NSString*)pluginName return [_manager getCommandInstance:pluginName]; } -- (void)runInBackground:(void (^)())block +- (void)runInBackground:(void (^)(void))block { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block); } diff --git a/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginResult.m b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginResult.m index a2cd71e1bd..80e69144e6 100644 --- a/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginResult.m +++ b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginResult.m @@ -101,7 +101,7 @@ - (CDVPluginResult*)initWithStatus:(CDVCommandStatus)statusOrdinal message:(id)t { self = [super init]; if (self) { - status = [NSNumber numberWithInt:statusOrdinal]; + status = [NSNumber numberWithUnsignedLong:statusOrdinal]; message = theMessage; keepCallback = [NSNumber numberWithBool:NO]; } diff --git a/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVViewController.m b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVViewController.m index 86c76d9f29..1f233626bb 100644 --- a/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVViewController.m +++ b/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVViewController.m @@ -29,6 +29,9 @@ @interface CDVViewController () { @end +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wincomplete-implementation" @implementation CDVViewController @end +#pragma clang diagnostic pop From 1df74d6c6a3e4409b27690e3a2d0bdb3e22728b9 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Thu, 1 Oct 2020 15:33:07 -0400 Subject: [PATCH 02/40] Support direct building of the capacitor framework. Added modulemaps, updated umbrella headers, updated project settings, removed Capacitor project's Podfile. Updated respective podspecs to match. --- ios/Capacitor.podspec | 3 + .../Capacitor.xcodeproj/project.pbxproj | 352 +++++++++++++----- .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcshareddata/xcschemes/Capacitor.xcscheme | 77 ++++ .../contents.xcworkspacedata | 2 +- ios/Capacitor/Capacitor/Capacitor.h | 14 +- ios/Capacitor/Capacitor/Capacitor.modulemap | 7 + .../CapacitorTests/CapacitorTests.swift | 26 +- ios/Capacitor/Podfile | 11 - ios/Capacitor/Podfile.lock | 16 - ios/CapacitorCordova.podspec | 3 +- .../project.pbxproj | 119 +++--- .../CapacitorCordova/CapacitorCordova.h | 17 +- .../CapacitorCordova.modulemap | 6 + .../CapacitorCordova/Info.plist | 2 + 15 files changed, 470 insertions(+), 193 deletions(-) create mode 100644 ios/Capacitor/Capacitor.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 ios/Capacitor/Capacitor.xcodeproj/xcshareddata/xcschemes/Capacitor.xcscheme create mode 100644 ios/Capacitor/Capacitor/Capacitor.modulemap delete mode 100644 ios/Capacitor/Podfile delete mode 100644 ios/Capacitor/Podfile.lock create mode 100644 ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.modulemap diff --git a/ios/Capacitor.podspec b/ios/Capacitor.podspec index 74e2b98132..ede5d671d2 100644 --- a/ios/Capacitor.podspec +++ b/ios/Capacitor.podspec @@ -11,6 +11,9 @@ Pod::Spec.new do |s| s.authors = { 'Ionic Team' => 'hi@ionicframework.com' } s.source = { :git => 'https://github.com/ionic-team/capacitor.git', :tag => s.version.to_s } s.source_files = 'Capacitor/Capacitor/*.{swift,h,m}', 'Capacitor/Capacitor/Plugins/*.{swift,h,m}', 'Capacitor/Capacitor/Plugins/**/*.{swift,h,m}' + s.exclude_files = 'Capacitor/Capacitor/Plugins/DefaultPlugins.h', + 'Capacitor/Capacitor/Plugins/Keyboard.h' + s.module_map = 'Capacitor/Capacitor/Capacitor.modulemap' s.dependency 'CapacitorCordova' s.swift_version = '5.0' end diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj index e607d7f69c..d86e3b0f9d 100644 --- a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj +++ b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj @@ -8,11 +8,54 @@ /* Begin PBXBuildFile section */ 501CBAA71FC0A723009B0D4D /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 501CBAA61FC0A723009B0D4D /* WebKit.framework */; }; - 503422C42003E6950049A959 /* Capacitor in Resources */ = {isa = PBXBuildFile; fileRef = 503422C32003E6940049A959 /* Capacitor */; }; 50503EE91FC08595003606DC /* Capacitor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50503EDF1FC08594003606DC /* Capacitor.framework */; }; 50503EEE1FC08595003606DC /* CapacitorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50503EED1FC08595003606DC /* CapacitorTests.swift */; }; - BCFA72E81BB38E2E034791D7 /* Pods_CapacitorTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B975B0A166283500B55FD2E7 /* Pods_CapacitorTests.framework */; }; - EFD716F22CFA442BCB16ABAC /* Pods_Capacitor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9ABFE550E2358D6D2984A359 /* Pods_Capacitor.framework */; }; + 62959B162524DA7800A3D7F1 /* CAPPluginCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 62959B172524DA7800A3D7F1 /* JSExport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE32524DA7700A3D7F1 /* JSExport.swift */; }; + 62959B182524DA7800A3D7F1 /* CAPBridgedJSTypes.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE42524DA7700A3D7F1 /* CAPBridgedJSTypes.m */; }; + 62959B192524DA7800A3D7F1 /* CAPBridgedPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 62959B1A2524DA7800A3D7F1 /* CAPPluginCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */; }; + 62959B1B2524DA7800A3D7F1 /* CAPFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE72524DA7700A3D7F1 /* CAPFile.swift */; }; + 62959B1C2524DA7800A3D7F1 /* CAPPluginMethod.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */; }; + 62959B1D2524DA7800A3D7F1 /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE92524DA7700A3D7F1 /* UIColor.swift */; }; + 62959B1E2524DA7800A3D7F1 /* StatusBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AEB2524DA7700A3D7F1 /* StatusBar.swift */; }; + 62959B1F2524DA7800A3D7F1 /* Keyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AEC2524DA7700A3D7F1 /* Keyboard.m */; }; + 62959B222524DA7800A3D7F1 /* Console.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AEF2524DA7700A3D7F1 /* Console.swift */; }; + 62959B232524DA7800A3D7F1 /* DefaultPlugins.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */; }; + 62959B242524DA7800A3D7F1 /* Geolocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF12524DA7700A3D7F1 /* Geolocation.swift */; }; + 62959B252524DA7800A3D7F1 /* PushNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */; }; + 62959B262524DA7800A3D7F1 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF32524DA7700A3D7F1 /* WebView.swift */; }; + 62959B272524DA7800A3D7F1 /* Keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AF42524DA7700A3D7F1 /* Keyboard.h */; }; + 62959B282524DA7800A3D7F1 /* BackgroundTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */; }; + 62959B292524DA7800A3D7F1 /* SplashScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */; }; + 62959B2C2524DA7800A3D7F1 /* LocalNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */; }; + 62959B2D2524DA7800A3D7F1 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFB2524DA7700A3D7F1 /* App.swift */; }; + 62959B2F2524DA7800A3D7F1 /* DefaultPlugins.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */; }; + 62959B302524DA7800A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */; }; + 62959B312524DA7800A3D7F1 /* JS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFF2524DA7700A3D7F1 /* JS.swift */; }; + 62959B322524DA7800A3D7F1 /* CAPAppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B002524DA7700A3D7F1 /* CAPAppDelegate.swift */; }; + 62959B332524DA7800A3D7F1 /* CAPPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959B012524DA7700A3D7F1 /* CAPPlugin.m */; }; + 62959B342524DA7800A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B022524DA7700A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift */; }; + 62959B352524DA7800A3D7F1 /* CAPBridgedJSTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B032524DA7700A3D7F1 /* CAPBridgedJSTypes.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 62959B362524DA7800A3D7F1 /* CAPBridgeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */; }; + 62959B372524DA7800A3D7F1 /* CAPConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B052524DA7700A3D7F1 /* CAPConfig.swift */; }; + 62959B382524DA7800A3D7F1 /* CAPPluginCall.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959B062524DA7700A3D7F1 /* CAPPluginCall.m */; }; + 62959B392524DA7800A3D7F1 /* CapacitorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B072524DA7700A3D7F1 /* CapacitorExtension.swift */; }; + 62959B3A2524DA7800A3D7F1 /* CAPLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B082524DA7700A3D7F1 /* CAPLog.swift */; }; + 62959B3B2524DA7800A3D7F1 /* CAPPluginMethod.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B092524DA7700A3D7F1 /* CAPPluginMethod.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 62959B3C2524DA7800A3D7F1 /* CAPBridgeDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */; }; + 62959B3D2524DA7800A3D7F1 /* CAPMessageHandlerWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0B2524DA7700A3D7F1 /* CAPMessageHandlerWrapper.swift */; }; + 62959B3E2524DA7800A3D7F1 /* JSTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0C2524DA7700A3D7F1 /* JSTypes.swift */; }; + 62959B3F2524DA7800A3D7F1 /* CAPAssetHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0D2524DA7700A3D7F1 /* CAPAssetHandler.swift */; }; + 62959B402524DA7800A3D7F1 /* TmpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0E2524DA7700A3D7F1 /* TmpViewController.swift */; }; + 62959B412524DA7800A3D7F1 /* Capacitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B0F2524DA7700A3D7F1 /* Capacitor.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 62959B422524DA7800A3D7F1 /* DocLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B102524DA7700A3D7F1 /* DocLinks.swift */; }; + 62959B432524DA7800A3D7F1 /* Data+Capacitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B112524DA7700A3D7F1 /* Data+Capacitor.swift */; }; + 62959B452524DA7800A3D7F1 /* CAPPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B132524DA7700A3D7F1 /* CAPPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 62959B462524DA7800A3D7F1 /* CAPBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B142524DA7700A3D7F1 /* CAPBridge.swift */; }; + 62959B472524DA7800A3D7F1 /* CAPNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B152524DA7700A3D7F1 /* CAPNotifications.swift */; }; + 62959BA52526475A00A3D7F1 /* Cordova.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62959BA02526474300A3D7F1 /* Cordova.framework */; }; + 62959BA62526475A00A3D7F1 /* Cordova.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 62959BA02526474300A3D7F1 /* Cordova.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -23,26 +66,83 @@ remoteGlobalIDString = 50503EDE1FC08594003606DC; remoteInfo = Avocado; }; + 62959B9F2526474300A3D7F1 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 62959B9B2526474300A3D7F1 /* CapacitorCordova.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2F5C86DC1FE94845004B09C7; + remoteInfo = Cordova; + }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + 62959BA72526475A00A3D7F1 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 62959BA62526475A00A3D7F1 /* Cordova.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ - 3979367CC1BEE8D19B3C2F5A /* Pods-Capacitor.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Capacitor.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Capacitor/Pods-Capacitor.debug.xcconfig"; sourceTree = ""; }; - 40367A7722BCB186FA84278A /* Pods_Avocado.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Avocado.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 451BCB03DDD54A8F94065E22 /* Pods-AvocadoTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AvocadoTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AvocadoTests/Pods-AvocadoTests.release.xcconfig"; sourceTree = ""; }; 501CBAA61FC0A723009B0D4D /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; - 503422C32003E6940049A959 /* Capacitor */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Capacitor; sourceTree = ""; }; 50503EDF1FC08594003606DC /* Capacitor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Capacitor.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 50503EE81FC08595003606DC /* CapacitorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CapacitorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50503EED1FC08595003606DC /* CapacitorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapacitorTests.swift; sourceTree = ""; }; - 50503EEF1FC08595003606DC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 5D9EB44F3FB7707EC9A94675 /* Pods-Avocado.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Avocado.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Avocado/Pods-Avocado.debug.xcconfig"; sourceTree = ""; }; - 708D7D71020B2BF3A37B8712 /* Pods-Avocado.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Avocado.release.xcconfig"; path = "Pods/Target Support Files/Pods-Avocado/Pods-Avocado.release.xcconfig"; sourceTree = ""; }; - 98E0B0181FE097A9265019E2 /* Pods-CapacitorTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CapacitorTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CapacitorTests/Pods-CapacitorTests.debug.xcconfig"; sourceTree = ""; }; - 99A247C0890BD1F4E0E9E10D /* Pods-Capacitor.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Capacitor.release.xcconfig"; path = "Pods/Target Support Files/Pods-Capacitor/Pods-Capacitor.release.xcconfig"; sourceTree = ""; }; - 9ABFE550E2358D6D2984A359 /* Pods_Capacitor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Capacitor.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - B975B0A166283500B55FD2E7 /* Pods_CapacitorTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CapacitorTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - EC87A33DCE44DE1C0E1F321C /* Pods-CapacitorTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CapacitorTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CapacitorTests/Pods-CapacitorTests.release.xcconfig"; sourceTree = ""; }; - EDC8CE955F35972E94AD9EC3 /* Pods-AvocadoTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AvocadoTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AvocadoTests/Pods-AvocadoTests.debug.xcconfig"; sourceTree = ""; }; + 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPPluginCall.h; sourceTree = ""; }; + 62959AE32524DA7700A3D7F1 /* JSExport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSExport.swift; sourceTree = ""; }; + 62959AE42524DA7700A3D7F1 /* CAPBridgedJSTypes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPBridgedJSTypes.m; sourceTree = ""; }; + 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPBridgedPlugin.h; sourceTree = ""; }; + 62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPPluginCall.swift; sourceTree = ""; }; + 62959AE72524DA7700A3D7F1 /* CAPFile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPFile.swift; sourceTree = ""; }; + 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPPluginMethod.m; sourceTree = ""; }; + 62959AE92524DA7700A3D7F1 /* UIColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = ""; }; + 62959AEB2524DA7700A3D7F1 /* StatusBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBar.swift; sourceTree = ""; }; + 62959AEC2524DA7700A3D7F1 /* Keyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Keyboard.m; sourceTree = ""; }; + 62959AEF2524DA7700A3D7F1 /* Console.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Console.swift; sourceTree = ""; }; + 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultPlugins.h; sourceTree = ""; }; + 62959AF12524DA7700A3D7F1 /* Geolocation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Geolocation.swift; sourceTree = ""; }; + 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PushNotifications.swift; sourceTree = ""; }; + 62959AF32524DA7700A3D7F1 /* WebView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = ""; }; + 62959AF42524DA7700A3D7F1 /* Keyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Keyboard.h; sourceTree = ""; }; + 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundTask.swift; sourceTree = ""; }; + 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SplashScreen.swift; sourceTree = ""; }; + 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalNotifications.swift; sourceTree = ""; }; + 62959AFB2524DA7700A3D7F1 /* App.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = ""; }; + 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DefaultPlugins.m; sourceTree = ""; }; + 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIStatusBarManager+CAPHandleTapAction.m"; sourceTree = ""; }; + 62959AFF2524DA7700A3D7F1 /* JS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JS.swift; sourceTree = ""; }; + 62959B002524DA7700A3D7F1 /* CAPAppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPAppDelegate.swift; sourceTree = ""; }; + 62959B012524DA7700A3D7F1 /* CAPPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPPlugin.m; sourceTree = ""; }; + 62959B022524DA7700A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPUNUserNotificationCenterDelegate.swift; sourceTree = ""; }; + 62959B032524DA7700A3D7F1 /* CAPBridgedJSTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPBridgedJSTypes.h; sourceTree = ""; }; + 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPBridgeViewController.swift; sourceTree = ""; }; + 62959B052524DA7700A3D7F1 /* CAPConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPConfig.swift; sourceTree = ""; }; + 62959B062524DA7700A3D7F1 /* CAPPluginCall.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPPluginCall.m; sourceTree = ""; }; + 62959B072524DA7700A3D7F1 /* CapacitorExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CapacitorExtension.swift; sourceTree = ""; }; + 62959B082524DA7700A3D7F1 /* CAPLog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPLog.swift; sourceTree = ""; }; + 62959B092524DA7700A3D7F1 /* CAPPluginMethod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPPluginMethod.h; sourceTree = ""; }; + 62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPBridgeDelegate.swift; sourceTree = ""; }; + 62959B0B2524DA7700A3D7F1 /* CAPMessageHandlerWrapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPMessageHandlerWrapper.swift; sourceTree = ""; }; + 62959B0C2524DA7700A3D7F1 /* JSTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSTypes.swift; sourceTree = ""; }; + 62959B0D2524DA7700A3D7F1 /* CAPAssetHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPAssetHandler.swift; sourceTree = ""; }; + 62959B0E2524DA7700A3D7F1 /* TmpViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TmpViewController.swift; sourceTree = ""; }; + 62959B0F2524DA7700A3D7F1 /* Capacitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Capacitor.h; sourceTree = ""; }; + 62959B102524DA7700A3D7F1 /* DocLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DocLinks.swift; sourceTree = ""; }; + 62959B112524DA7700A3D7F1 /* Data+Capacitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Data+Capacitor.swift"; sourceTree = ""; }; + 62959B122524DA7700A3D7F1 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 62959B132524DA7700A3D7F1 /* CAPPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPPlugin.h; sourceTree = ""; }; + 62959B142524DA7700A3D7F1 /* CAPBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPBridge.swift; sourceTree = ""; }; + 62959B152524DA7700A3D7F1 /* CAPNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPNotifications.swift; sourceTree = ""; }; + 62959B56252518FB00A3D7F1 /* Cordova.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Cordova.framework; sourceTree = ""; }; + 62959B8225253A9500A3D7F1 /* Capacitor.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = Capacitor.modulemap; sourceTree = ""; }; + 62959B9B2526474300A3D7F1 /* CapacitorCordova.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CapacitorCordova.xcodeproj; path = ../CapacitorCordova/CapacitorCordova.xcodeproj; sourceTree = ""; }; + 62959BBD2526510200A3D7F1 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -51,7 +151,7 @@ buildActionMask = 2147483647; files = ( 501CBAA71FC0A723009B0D4D /* WebKit.framework in Frameworks */, - EFD716F22CFA442BCB16ABAC /* Pods_Capacitor.framework in Frameworks */, + 62959BA52526475A00A3D7F1 /* Cordova.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -60,7 +160,6 @@ buildActionMask = 2147483647; files = ( 50503EE91FC08595003606DC /* Capacitor.framework in Frameworks */, - BCFA72E81BB38E2E034791D7 /* Pods_CapacitorTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -70,10 +169,9 @@ 501CBAA51FC0A723009B0D4D /* Frameworks */ = { isa = PBXGroup; children = ( + 62959B9B2526474300A3D7F1 /* CapacitorCordova.xcodeproj */, + 62959B56252518FB00A3D7F1 /* Cordova.framework */, 501CBAA61FC0A723009B0D4D /* WebKit.framework */, - 40367A7722BCB186FA84278A /* Pods_Avocado.framework */, - 9ABFE550E2358D6D2984A359 /* Pods_Capacitor.framework */, - B975B0A166283500B55FD2E7 /* Pods_CapacitorTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -81,11 +179,10 @@ 50503ED51FC08594003606DC = { isa = PBXGroup; children = ( - 503422C32003E6940049A959 /* Capacitor */, + 62959AE12524DA7700A3D7F1 /* Capacitor */, 50503EEC1FC08595003606DC /* CapacitorTests */, 50503EE01FC08594003606DC /* Products */, 501CBAA51FC0A723009B0D4D /* Frameworks */, - 7B685293CE4975791E165F0D /* Pods */, ); sourceTree = ""; }; @@ -102,24 +199,78 @@ isa = PBXGroup; children = ( 50503EED1FC08595003606DC /* CapacitorTests.swift */, - 50503EEF1FC08595003606DC /* Info.plist */, + 62959BBD2526510200A3D7F1 /* Info.plist */, ); path = CapacitorTests; sourceTree = ""; }; - 7B685293CE4975791E165F0D /* Pods */ = { + 62959AE12524DA7700A3D7F1 /* Capacitor */ = { + isa = PBXGroup; + children = ( + 62959B0F2524DA7700A3D7F1 /* Capacitor.h */, + 62959B132524DA7700A3D7F1 /* CAPPlugin.h */, + 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */, + 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */, + 62959B092524DA7700A3D7F1 /* CAPPluginMethod.h */, + 62959AE32524DA7700A3D7F1 /* JSExport.swift */, + 62959B032524DA7700A3D7F1 /* CAPBridgedJSTypes.h */, + 62959AE42524DA7700A3D7F1 /* CAPBridgedJSTypes.m */, + 62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */, + 62959AE72524DA7700A3D7F1 /* CAPFile.swift */, + 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */, + 62959AE92524DA7700A3D7F1 /* UIColor.swift */, + 62959AEA2524DA7700A3D7F1 /* Plugins */, + 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */, + 62959AFF2524DA7700A3D7F1 /* JS.swift */, + 62959B002524DA7700A3D7F1 /* CAPAppDelegate.swift */, + 62959B012524DA7700A3D7F1 /* CAPPlugin.m */, + 62959B022524DA7700A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift */, + 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */, + 62959B052524DA7700A3D7F1 /* CAPConfig.swift */, + 62959B062524DA7700A3D7F1 /* CAPPluginCall.m */, + 62959B072524DA7700A3D7F1 /* CapacitorExtension.swift */, + 62959B082524DA7700A3D7F1 /* CAPLog.swift */, + 62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */, + 62959B0B2524DA7700A3D7F1 /* CAPMessageHandlerWrapper.swift */, + 62959B0C2524DA7700A3D7F1 /* JSTypes.swift */, + 62959B0D2524DA7700A3D7F1 /* CAPAssetHandler.swift */, + 62959B0E2524DA7700A3D7F1 /* TmpViewController.swift */, + 62959B102524DA7700A3D7F1 /* DocLinks.swift */, + 62959B112524DA7700A3D7F1 /* Data+Capacitor.swift */, + 62959B122524DA7700A3D7F1 /* Info.plist */, + 62959B142524DA7700A3D7F1 /* CAPBridge.swift */, + 62959B152524DA7700A3D7F1 /* CAPNotifications.swift */, + 62959B8225253A9500A3D7F1 /* Capacitor.modulemap */, + ); + path = Capacitor; + sourceTree = ""; + }; + 62959AEA2524DA7700A3D7F1 /* Plugins */ = { isa = PBXGroup; children = ( - 5D9EB44F3FB7707EC9A94675 /* Pods-Avocado.debug.xcconfig */, - 708D7D71020B2BF3A37B8712 /* Pods-Avocado.release.xcconfig */, - EDC8CE955F35972E94AD9EC3 /* Pods-AvocadoTests.debug.xcconfig */, - 451BCB03DDD54A8F94065E22 /* Pods-AvocadoTests.release.xcconfig */, - 3979367CC1BEE8D19B3C2F5A /* Pods-Capacitor.debug.xcconfig */, - 99A247C0890BD1F4E0E9E10D /* Pods-Capacitor.release.xcconfig */, - 98E0B0181FE097A9265019E2 /* Pods-CapacitorTests.debug.xcconfig */, - EC87A33DCE44DE1C0E1F321C /* Pods-CapacitorTests.release.xcconfig */, + 62959AFB2524DA7700A3D7F1 /* App.swift */, + 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */, + 62959AEF2524DA7700A3D7F1 /* Console.swift */, + 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */, + 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */, + 62959AF12524DA7700A3D7F1 /* Geolocation.swift */, + 62959AF42524DA7700A3D7F1 /* Keyboard.h */, + 62959AEC2524DA7700A3D7F1 /* Keyboard.m */, + 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */, + 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */, + 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */, + 62959AEB2524DA7700A3D7F1 /* StatusBar.swift */, + 62959AF32524DA7700A3D7F1 /* WebView.swift */, ); - name = Pods; + path = Plugins; + sourceTree = ""; + }; + 62959B9C2526474300A3D7F1 /* Products */ = { + isa = PBXGroup; + children = ( + 62959BA02526474300A3D7F1 /* Cordova.framework */, + ); + name = Products; sourceTree = ""; }; /* End PBXGroup section */ @@ -129,6 +280,14 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 62959B412524DA7800A3D7F1 /* Capacitor.h in Headers */, + 62959B452524DA7800A3D7F1 /* CAPPlugin.h in Headers */, + 62959B162524DA7800A3D7F1 /* CAPPluginCall.h in Headers */, + 62959B3B2524DA7800A3D7F1 /* CAPPluginMethod.h in Headers */, + 62959B192524DA7800A3D7F1 /* CAPBridgedPlugin.h in Headers */, + 62959B352524DA7800A3D7F1 /* CAPBridgedJSTypes.h in Headers */, + 62959B272524DA7800A3D7F1 /* Keyboard.h in Headers */, + 62959B232524DA7800A3D7F1 /* DefaultPlugins.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -139,11 +298,11 @@ isa = PBXNativeTarget; buildConfigurationList = 50503EF31FC08595003606DC /* Build configuration list for PBXNativeTarget "Capacitor" */; buildPhases = ( - 93213D04BDB3366A679E5DB2 /* [CP] Check Pods Manifest.lock */, 50503EDA1FC08594003606DC /* Sources */, 50503EDB1FC08594003606DC /* Frameworks */, 50503EDC1FC08594003606DC /* Headers */, 50503EDD1FC08594003606DC /* Resources */, + 62959BA72526475A00A3D7F1 /* Embed Frameworks */, ); buildRules = ( ); @@ -158,7 +317,6 @@ isa = PBXNativeTarget; buildConfigurationList = 50503EF61FC08595003606DC /* Build configuration list for PBXNativeTarget "CapacitorTests" */; buildPhases = ( - 4F9B8D131D6355067982814A /* [CP] Check Pods Manifest.lock */, 50503EE41FC08595003606DC /* Sources */, 50503EE51FC08595003606DC /* Frameworks */, 50503EE61FC08595003606DC /* Resources */, @@ -204,6 +362,12 @@ mainGroup = 50503ED51FC08594003606DC; productRefGroup = 50503EE01FC08594003606DC /* Products */; projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 62959B9C2526474300A3D7F1 /* Products */; + ProjectRef = 62959B9B2526474300A3D7F1 /* CapacitorCordova.xcodeproj */; + }, + ); projectRoot = ""; targets = ( 50503EDE1FC08594003606DC /* Capacitor */, @@ -212,12 +376,21 @@ }; /* End PBXProject section */ +/* Begin PBXReferenceProxy section */ + 62959BA02526474300A3D7F1 /* Cordova.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = Cordova.framework; + remoteRef = 62959B9F2526474300A3D7F1 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + /* Begin PBXResourcesBuildPhase section */ 50503EDD1FC08594003606DC /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 503422C42003E6950049A959 /* Capacitor in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -230,50 +403,47 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - 4F9B8D131D6355067982814A /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-CapacitorTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/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# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 93213D04BDB3366A679E5DB2 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Capacitor-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/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# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ 50503EDA1FC08594003606DC /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 62959B362524DA7800A3D7F1 /* CAPBridgeViewController.swift in Sources */, + 62959B402524DA7800A3D7F1 /* TmpViewController.swift in Sources */, + 62959B372524DA7800A3D7F1 /* CAPConfig.swift in Sources */, + 62959B432524DA7800A3D7F1 /* Data+Capacitor.swift in Sources */, + 62959B1E2524DA7800A3D7F1 /* StatusBar.swift in Sources */, + 62959B322524DA7800A3D7F1 /* CAPAppDelegate.swift in Sources */, + 62959B3E2524DA7800A3D7F1 /* JSTypes.swift in Sources */, + 62959B382524DA7800A3D7F1 /* CAPPluginCall.m in Sources */, + 62959B1B2524DA7800A3D7F1 /* CAPFile.swift in Sources */, + 62959B462524DA7800A3D7F1 /* CAPBridge.swift in Sources */, + 62959B1D2524DA7800A3D7F1 /* UIColor.swift in Sources */, + 62959B282524DA7800A3D7F1 /* BackgroundTask.swift in Sources */, + 62959B332524DA7800A3D7F1 /* CAPPlugin.m in Sources */, + 62959B1C2524DA7800A3D7F1 /* CAPPluginMethod.m in Sources */, + 62959B242524DA7800A3D7F1 /* Geolocation.swift in Sources */, + 62959B342524DA7800A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift in Sources */, + 62959B472524DA7800A3D7F1 /* CAPNotifications.swift in Sources */, + 62959B312524DA7800A3D7F1 /* JS.swift in Sources */, + 62959B252524DA7800A3D7F1 /* PushNotifications.swift in Sources */, + 62959B292524DA7800A3D7F1 /* SplashScreen.swift in Sources */, + 62959B1A2524DA7800A3D7F1 /* CAPPluginCall.swift in Sources */, + 62959B302524DA7800A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m in Sources */, + 62959B392524DA7800A3D7F1 /* CapacitorExtension.swift in Sources */, + 62959B3D2524DA7800A3D7F1 /* CAPMessageHandlerWrapper.swift in Sources */, + 62959B422524DA7800A3D7F1 /* DocLinks.swift in Sources */, + 62959B172524DA7800A3D7F1 /* JSExport.swift in Sources */, + 62959B2D2524DA7800A3D7F1 /* App.swift in Sources */, + 62959B3F2524DA7800A3D7F1 /* CAPAssetHandler.swift in Sources */, + 62959B1F2524DA7800A3D7F1 /* Keyboard.m in Sources */, + 62959B3C2524DA7800A3D7F1 /* CAPBridgeDelegate.swift in Sources */, + 62959B2C2524DA7800A3D7F1 /* LocalNotifications.swift in Sources */, + 62959B2F2524DA7800A3D7F1 /* DefaultPlugins.m in Sources */, + 62959B222524DA7800A3D7F1 /* Console.swift in Sources */, + 62959B3A2524DA7800A3D7F1 /* CAPLog.swift in Sources */, + 62959B182524DA7800A3D7F1 /* CAPBridgedJSTypes.m in Sources */, + 62959B262524DA7800A3D7F1 /* WebView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -413,9 +583,7 @@ }; 50503EF41FC08595003606DC /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 3979367CC1BEE8D19B3C2F5A /* Pods-Capacitor.debug.xcconfig */; buildSettings = { - CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; @@ -423,10 +591,15 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); INFOPLIST_FILE = Capacitor/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.ios.Capacitor; + MODULEMAP_FILE = Capacitor/Capacitor.modulemap; + PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.Capacitor; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; SWIFT_OBJC_BRIDGING_HEADER = ""; @@ -438,9 +611,7 @@ }; 50503EF51FC08595003606DC /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 99A247C0890BD1F4E0E9E10D /* Pods-Capacitor.release.xcconfig */; buildSettings = { - CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; @@ -448,10 +619,15 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); INFOPLIST_FILE = Capacitor/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.ios.Capacitor; + MODULEMAP_FILE = Capacitor/Capacitor.modulemap; + PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.Capacitor; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; SWIFT_OBJC_BRIDGING_HEADER = ""; @@ -462,13 +638,13 @@ }; 50503EF71FC08595003606DC /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 98E0B0181FE097A9265019E2 /* Pods-CapacitorTests.debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = AvocadoTests/Info.plist; + INFOPLIST_FILE = CapacitorTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.avocadojs.ios.AvocadoTests; + PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.CapacitorTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -477,13 +653,13 @@ }; 50503EF81FC08595003606DC /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = EC87A33DCE44DE1C0E1F321C /* Pods-CapacitorTests.release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = AvocadoTests/Info.plist; + INFOPLIST_FILE = CapacitorTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.avocadojs.ios.AvocadoTests; + PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.CapacitorTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/Capacitor/Capacitor.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/ios/Capacitor/Capacitor.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/Capacitor/Capacitor.xcodeproj/xcshareddata/xcschemes/Capacitor.xcscheme b/ios/Capacitor/Capacitor.xcodeproj/xcshareddata/xcschemes/Capacitor.xcscheme new file mode 100644 index 0000000000..58a998de33 --- /dev/null +++ b/ios/Capacitor/Capacitor.xcodeproj/xcshareddata/xcschemes/Capacitor.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Capacitor/Capacitor.xcworkspace/contents.xcworkspacedata b/ios/Capacitor/Capacitor.xcworkspace/contents.xcworkspacedata index 66b41d3e82..37b6585fc3 100644 --- a/ios/Capacitor/Capacitor.xcworkspace/contents.xcworkspacedata +++ b/ios/Capacitor/Capacitor.xcworkspace/contents.xcworkspacedata @@ -5,6 +5,6 @@ location = "group:Capacitor.xcodeproj"> + location = "group:../CapacitorCordova/CapacitorCordova.xcodeproj"> diff --git a/ios/Capacitor/Capacitor/Capacitor.h b/ios/Capacitor/Capacitor/Capacitor.h index 5bf25252e4..84e799f21a 100644 --- a/ios/Capacitor/Capacitor/Capacitor.h +++ b/ios/Capacitor/Capacitor/Capacitor.h @@ -6,13 +6,7 @@ FOUNDATION_EXPORT double CapacitorVersionNumber; //! Project version string for bridge. FOUNDATION_EXPORT const unsigned char CapacitorVersionString[]; -#import "CAPPlugin.h" -#import "CAPPluginCall.h" -#import "CAPBridgedPlugin.h" -#import "CAPPluginMethod.h" -#import "DefaultPlugins.h" - - -// In this header, you should import all the public headers of your framework using statements like #import - - +#import +#import +#import +#import diff --git a/ios/Capacitor/Capacitor/Capacitor.modulemap b/ios/Capacitor/Capacitor/Capacitor.modulemap new file mode 100644 index 0000000000..580ea550e5 --- /dev/null +++ b/ios/Capacitor/Capacitor/Capacitor.modulemap @@ -0,0 +1,7 @@ +framework module Capacitor { + umbrella header "Capacitor.h" + exclude header "CAPBridgedJSTypes.h" + + export * + module * { export * } +} diff --git a/ios/Capacitor/CapacitorTests/CapacitorTests.swift b/ios/Capacitor/CapacitorTests/CapacitorTests.swift index ea28e626ea..8be9150556 100644 --- a/ios/Capacitor/CapacitorTests/CapacitorTests.swift +++ b/ios/Capacitor/CapacitorTests/CapacitorTests.swift @@ -1,31 +1,27 @@ -// -// AvocadoTests.swift -// AvocadoTests -// -// Created by Max Lynch on 11/18/17. -// Copyright © 2017 Drifty Co. All rights reserved. -// - import XCTest @testable import Capacitor -class MockWebView: WKWebView { +class MockBridgeViewController: CAPBridgeViewController { +} + +class MockBridgeMessageHandler: CAPMessageHandlerWrapper { } -class MockBridgeViewController: BridgeViewController { +class MockConfig: CAPConfig { } -class MockBridge: Bridge { +class MockBridge: CAPBridge { override public func registerPlugins() { - print("REGISER PLUITTTINS") + print("REGISTER PLUGINS") } } -class AvocadoTests: XCTestCase { - +class CapacitorTests: XCTestCase { + var bridge: MockBridge? + override func setUp() { super.setUp() // Put setup code here. This method is called before the invocation of each test method in the class. - var bridge = MockBridge(MockBridgeViewController(), MockWebView()) + bridge = MockBridge(MockBridgeViewController(), MockBridgeMessageHandler(), MockConfig(), MockBridge.defaultScheme) } override func tearDown() { diff --git a/ios/Capacitor/Podfile b/ios/Capacitor/Podfile deleted file mode 100644 index a1ecb50efa..0000000000 --- a/ios/Capacitor/Podfile +++ /dev/null @@ -1,11 +0,0 @@ -platform :ios, '11.0' - -target 'Capacitor' do - use_frameworks! - pod 'CapacitorCordova', :path => '../' - target 'CapacitorTests' do - inherit! :search_paths - - end - -end diff --git a/ios/Capacitor/Podfile.lock b/ios/Capacitor/Podfile.lock deleted file mode 100644 index e20c8b4ffe..0000000000 --- a/ios/Capacitor/Podfile.lock +++ /dev/null @@ -1,16 +0,0 @@ -PODS: - - CapacitorCordova (3.0.0-alpha.0) - -DEPENDENCIES: - - CapacitorCordova (from `../`) - -EXTERNAL SOURCES: - CapacitorCordova: - :path: "../" - -SPEC CHECKSUMS: - CapacitorCordova: d5c0f46dfad616eed2dcf244ba8e3e830d584f06 - -PODFILE CHECKSUM: 4f22ac28adef9078831eb08f7ef13034566fefdf - -COCOAPODS: 1.9.3 diff --git a/ios/CapacitorCordova.podspec b/ios/CapacitorCordova.podspec index 04c35736a4..86e75f7aff 100644 --- a/ios/CapacitorCordova.podspec +++ b/ios/CapacitorCordova.podspec @@ -11,7 +11,8 @@ Pod::Spec.new do |s| s.source = { :git => 'https://github.com/ionic-team/capacitor', :tag => s.version.to_s } s.platform = :ios, 11.0 s.source_files = 'CapacitorCordova/**/*.{h,m}' - s.public_header_files = 'CapacitorCordova/CapacitorCordova/Classes/Public/*.h' + s.public_header_files = 'CapacitorCordova/CapacitorCordova/Classes/Public/*.h', 'CapacitorCordova/CapacitorCordova/CapacitorCordova.h' + s.module_map = 'CapacitorCordova/CapacitorCordova/CapacitorCordova.modulemap' s.requires_arc = true s.framework = "WebKit" end diff --git a/ios/CapacitorCordova/CapacitorCordova.xcodeproj/project.pbxproj b/ios/CapacitorCordova/CapacitorCordova.xcodeproj/project.pbxproj index bbb0a4130e..1d1ecb9daf 100644 --- a/ios/CapacitorCordova/CapacitorCordova.xcodeproj/project.pbxproj +++ b/ios/CapacitorCordova/CapacitorCordova.xcodeproj/project.pbxproj @@ -8,35 +8,40 @@ /* Begin PBXBuildFile section */ 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 */; }; + 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, ); }; }; 2F5C871D1FE98418004B09C7 /* CDVPluginResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F5C87121FE98417004B09C7 /* CDVPluginResult.m */; }; - 2F5C871E1FE98418004B09C7 /* CDV.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C87131FE98417004B09C7 /* CDV.h */; }; + 2F5C871E1FE98418004B09C7 /* CDV.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C87131FE98417004B09C7 /* CDV.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2F5C871F1FE98418004B09C7 /* CDVCommandDelegateImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F5C87141FE98417004B09C7 /* CDVCommandDelegateImpl.m */; }; 2F5C87201FE98418004B09C7 /* CDVInvokedUrlCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F5C87151FE98417004B09C7 /* CDVInvokedUrlCommand.m */; }; 2F5C87211FE98418004B09C7 /* CDVPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F5C87161FE98417004B09C7 /* CDVPlugin.m */; }; - 2F5C87221FE98418004B09C7 /* CDVCommandDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C87171FE98417004B09C7 /* CDVCommandDelegate.h */; }; - 2F5C87231FE98418004B09C7 /* CDVCommandDelegateImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C87181FE98417004B09C7 /* CDVCommandDelegateImpl.h */; }; - 2F5C87241FE98418004B09C7 /* CDVInvokedUrlCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C87191FE98418004B09C7 /* CDVInvokedUrlCommand.h */; }; - 2F5C87251FE98418004B09C7 /* CDVAvailability.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C871A1FE98418004B09C7 /* CDVAvailability.h */; }; - 2F5C87261FE98418004B09C7 /* CDVPluginResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C871B1FE98418004B09C7 /* CDVPluginResult.h */; }; - 2F5C87271FE98418004B09C7 /* CDVPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C871C1FE98418004B09C7 /* CDVPlugin.h */; }; - 2F856BFF203DEB320047344A /* CDVViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F856BFD203DEB320047344A /* CDVViewController.h */; }; + 2F5C87221FE98418004B09C7 /* CDVCommandDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C87171FE98417004B09C7 /* CDVCommandDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2F5C87231FE98418004B09C7 /* CDVCommandDelegateImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C87181FE98417004B09C7 /* CDVCommandDelegateImpl.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2F5C87241FE98418004B09C7 /* CDVInvokedUrlCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C87191FE98418004B09C7 /* CDVInvokedUrlCommand.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2F5C87251FE98418004B09C7 /* CDVAvailability.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C871A1FE98418004B09C7 /* CDVAvailability.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2F5C87261FE98418004B09C7 /* CDVPluginResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C871B1FE98418004B09C7 /* CDVPluginResult.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2F5C87271FE98418004B09C7 /* CDVPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F5C871C1FE98418004B09C7 /* CDVPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2F856BFF203DEB320047344A /* CDVViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F856BFD203DEB320047344A /* CDVViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2F856C00203DEB320047344A /* CDVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F856BFE203DEB320047344A /* CDVViewController.m */; }; 2F8AC283217F3A20008C2C33 /* CDVURLProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F8AC281217F3A20008C2C33 /* CDVURLProtocol.m */; }; - 2F8AC284217F3A20008C2C33 /* CDVURLProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F8AC282217F3A20008C2C33 /* CDVURLProtocol.h */; }; + 2F8AC284217F3A20008C2C33 /* CDVURLProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F8AC282217F3A20008C2C33 /* CDVURLProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2F92AB5224D9ABA000954A4A /* CDVPlugin+Resources.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F92AB5024D9ABA000954A4A /* CDVPlugin+Resources.m */; }; - 2F92AB5324D9ABA000954A4A /* CDVPlugin+Resources.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F92AB5124D9ABA000954A4A /* CDVPlugin+Resources.h */; }; - 2FAD9772203C77B9000D30F8 /* CDVConfigParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 2FAD9770203C77B8000D30F8 /* CDVConfigParser.h */; }; + 2F92AB5324D9ABA000954A4A /* CDVPlugin+Resources.h in Headers */ = {isa = PBXBuildFile; fileRef = 2F92AB5124D9ABA000954A4A /* CDVPlugin+Resources.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2FAD9772203C77B9000D30F8 /* CDVConfigParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 2FAD9770203C77B8000D30F8 /* CDVConfigParser.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2FAD9773203C77B9000D30F8 /* CDVConfigParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 2FAD9771203C77B9000D30F8 /* CDVConfigParser.m */; }; - 2FE19E2A20473160002A4E89 /* AppDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2FE19E2820473160002A4E89 /* AppDelegate.h */; }; + 2FE19E2A20473160002A4E89 /* AppDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2FE19E2820473160002A4E89 /* AppDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2FE19E2B20473160002A4E89 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2FE19E2920473160002A4E89 /* AppDelegate.m */; }; + 62959B66252524CD00A3D7F1 /* CDVScreenOrientationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B65252524CD00A3D7F1 /* CDVScreenOrientationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 62959B6A252524D700A3D7F1 /* CDVPluginManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B68252524D700A3D7F1 /* CDVPluginManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 62959B6B252524D700A3D7F1 /* CDVPluginManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959B69252524D700A3D7F1 /* CDVPluginManager.m */; }; + 62959B8B2526230C00A3D7F1 /* CDVUserAgentUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959B892526230C00A3D7F1 /* CDVUserAgentUtil.m */; }; + 62959B8C2526230C00A3D7F1 /* CDVUserAgentUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B8A2526230C00A3D7F1 /* CDVUserAgentUtil.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 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 /* CapacitorCordova.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CapacitorCordova.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 2F5C86DC1FE94845004B09C7 /* Cordova.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cordova.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 2F5C86DF1FE94845004B09C7 /* CapacitorCordova.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CapacitorCordova.h; sourceTree = ""; }; 2F5C86E01FE94845004B09C7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 2F5C87121FE98417004B09C7 /* CDVPluginResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVPluginResult.m; sourceTree = ""; }; @@ -60,6 +65,12 @@ 2FAD9771203C77B9000D30F8 /* CDVConfigParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVConfigParser.m; sourceTree = ""; }; 2FE19E2820473160002A4E89 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 2FE19E2920473160002A4E89 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 62959B5F252522CB00A3D7F1 /* CapacitorCordova.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = CapacitorCordova.modulemap; sourceTree = ""; }; + 62959B65252524CD00A3D7F1 /* CDVScreenOrientationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVScreenOrientationDelegate.h; sourceTree = ""; }; + 62959B68252524D700A3D7F1 /* CDVPluginManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVPluginManager.h; sourceTree = ""; }; + 62959B69252524D700A3D7F1 /* CDVPluginManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVPluginManager.m; sourceTree = ""; }; + 62959B892526230C00A3D7F1 /* CDVUserAgentUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVUserAgentUtil.m; sourceTree = ""; }; + 62959B8A2526230C00A3D7F1 /* CDVUserAgentUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVUserAgentUtil.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -84,7 +95,7 @@ 2F5C86DD1FE94845004B09C7 /* Products */ = { isa = PBXGroup; children = ( - 2F5C86DC1FE94845004B09C7 /* CapacitorCordova.framework */, + 2F5C86DC1FE94845004B09C7 /* Cordova.framework */, ); name = Products; sourceTree = ""; @@ -94,6 +105,7 @@ children = ( 2F5C86E71FE94859004B09C7 /* Classes */, 2F5C86DF1FE94845004B09C7 /* CapacitorCordova.h */, + 62959B5F252522CB00A3D7F1 /* CapacitorCordova.modulemap */, 2F5C86E01FE94845004B09C7 /* Info.plist */, ); path = CapacitorCordova; @@ -110,29 +122,34 @@ 2F5C86E81FE94861004B09C7 /* Public */ = { isa = PBXGroup; children = ( - 2F92AB5124D9ABA000954A4A /* CDVPlugin+Resources.h */, - 2F92AB5024D9ABA000954A4A /* CDVPlugin+Resources.m */, - 2F8AC282217F3A20008C2C33 /* CDVURLProtocol.h */, - 2F8AC281217F3A20008C2C33 /* CDVURLProtocol.m */, - 2F4F657B2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.h */, - 2F4F657A2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.m */, - 2F856BFD203DEB320047344A /* CDVViewController.h */, - 2F856BFE203DEB320047344A /* CDVViewController.m */, - 2FAD9770203C77B8000D30F8 /* CDVConfigParser.h */, - 2FAD9771203C77B9000D30F8 /* CDVConfigParser.m */, + 2FE19E2820473160002A4E89 /* AppDelegate.h */, + 2FE19E2920473160002A4E89 /* AppDelegate.m */, 2F5C87131FE98417004B09C7 /* CDV.h */, 2F5C871A1FE98418004B09C7 /* CDVAvailability.h */, 2F5C87171FE98417004B09C7 /* CDVCommandDelegate.h */, - 2F5C87181FE98417004B09C7 /* CDVCommandDelegateImpl.h */, 2F5C87141FE98417004B09C7 /* CDVCommandDelegateImpl.m */, + 2F5C87181FE98417004B09C7 /* CDVCommandDelegateImpl.h */, + 2FAD9770203C77B8000D30F8 /* CDVConfigParser.h */, + 2FAD9771203C77B9000D30F8 /* CDVConfigParser.m */, 2F5C87191FE98418004B09C7 /* CDVInvokedUrlCommand.h */, 2F5C87151FE98417004B09C7 /* CDVInvokedUrlCommand.m */, + 2F92AB5124D9ABA000954A4A /* CDVPlugin+Resources.h */, + 2F92AB5024D9ABA000954A4A /* CDVPlugin+Resources.m */, 2F5C871C1FE98418004B09C7 /* CDVPlugin.h */, 2F5C87161FE98417004B09C7 /* CDVPlugin.m */, + 62959B68252524D700A3D7F1 /* CDVPluginManager.h */, + 62959B69252524D700A3D7F1 /* CDVPluginManager.m */, 2F5C871B1FE98418004B09C7 /* CDVPluginResult.h */, 2F5C87121FE98417004B09C7 /* CDVPluginResult.m */, - 2FE19E2820473160002A4E89 /* AppDelegate.h */, - 2FE19E2920473160002A4E89 /* AppDelegate.m */, + 62959B65252524CD00A3D7F1 /* CDVScreenOrientationDelegate.h */, + 2F8AC282217F3A20008C2C33 /* CDVURLProtocol.h */, + 2F8AC281217F3A20008C2C33 /* CDVURLProtocol.m */, + 62959B8A2526230C00A3D7F1 /* CDVUserAgentUtil.h */, + 62959B892526230C00A3D7F1 /* CDVUserAgentUtil.m */, + 2F4F657B2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.h */, + 2F4F657A2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.m */, + 2F856BFD203DEB320047344A /* CDVViewController.h */, + 2F856BFE203DEB320047344A /* CDVViewController.m */, ); path = Public; sourceTree = ""; @@ -144,29 +161,32 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 2F5C87261FE98418004B09C7 /* CDVPluginResult.h in Headers */, - 2FAD9772203C77B9000D30F8 /* CDVConfigParser.h in Headers */, - 2F5C87221FE98418004B09C7 /* CDVCommandDelegate.h in Headers */, + 2FE19E2A20473160002A4E89 /* AppDelegate.h in Headers */, 2F5C871E1FE98418004B09C7 /* CDV.h in Headers */, - 2F5C86E11FE94845004B09C7 /* CapacitorCordova.h in Headers */, + 2F5C87231FE98418004B09C7 /* CDVCommandDelegateImpl.h in Headers */, 2F5C87251FE98418004B09C7 /* CDVAvailability.h in Headers */, 2F5C87271FE98418004B09C7 /* CDVPlugin.h in Headers */, - 2F856BFF203DEB320047344A /* CDVViewController.h in Headers */, - 2F5C87231FE98418004B09C7 /* CDVCommandDelegateImpl.h in Headers */, - 2F92AB5324D9ABA000954A4A /* CDVPlugin+Resources.h in Headers */, - 2F8AC284217F3A20008C2C33 /* CDVURLProtocol.h in Headers */, + 2F5C87261FE98418004B09C7 /* CDVPluginResult.h in Headers */, + 2F5C87221FE98418004B09C7 /* CDVCommandDelegate.h in Headers */, 2F5C87241FE98418004B09C7 /* CDVInvokedUrlCommand.h in Headers */, - 2FE19E2A20473160002A4E89 /* AppDelegate.h in Headers */, + 2FAD9772203C77B9000D30F8 /* CDVConfigParser.h in Headers */, + 2F856BFF203DEB320047344A /* CDVViewController.h in Headers */, 2F4F657D2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.h in Headers */, + 2F8AC284217F3A20008C2C33 /* CDVURLProtocol.h in Headers */, + 62959B8C2526230C00A3D7F1 /* CDVUserAgentUtil.h in Headers */, + 2F92AB5324D9ABA000954A4A /* CDVPlugin+Resources.h in Headers */, + 62959B66252524CD00A3D7F1 /* CDVScreenOrientationDelegate.h in Headers */, + 62959B6A252524D700A3D7F1 /* CDVPluginManager.h in Headers */, + 2F5C86E11FE94845004B09C7 /* CapacitorCordova.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ - 2F5C86DB1FE94845004B09C7 /* CapacitorCordova */ = { + 2F5C86DB1FE94845004B09C7 /* Cordova */ = { isa = PBXNativeTarget; - buildConfigurationList = 2F5C86E41FE94845004B09C7 /* Build configuration list for PBXNativeTarget "CapacitorCordova" */; + buildConfigurationList = 2F5C86E41FE94845004B09C7 /* Build configuration list for PBXNativeTarget "Cordova" */; buildPhases = ( 2F5C86D71FE94845004B09C7 /* Sources */, 2F5C86D81FE94845004B09C7 /* Frameworks */, @@ -177,9 +197,9 @@ ); dependencies = ( ); - name = CapacitorCordova; + name = Cordova; productName = AvocadoCordova; - productReference = 2F5C86DC1FE94845004B09C7 /* CapacitorCordova.framework */; + productReference = 2F5C86DC1FE94845004B09C7 /* Cordova.framework */; productType = "com.apple.product-type.framework"; }; /* End PBXNativeTarget section */ @@ -188,7 +208,7 @@ 2F5C86D31FE94845004B09C7 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0920; + LastUpgradeCheck = 1200; ORGANIZATIONNAME = jcesarmobile; TargetAttributes = { 2F5C86DB1FE94845004B09C7 = { @@ -203,13 +223,14 @@ hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = 2F5C86D21FE94845004B09C7; productRefGroup = 2F5C86DD1FE94845004B09C7 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( - 2F5C86DB1FE94845004B09C7 /* CapacitorCordova */, + 2F5C86DB1FE94845004B09C7 /* Cordova */, ); }; /* End PBXProject section */ @@ -229,7 +250,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 62959B6B252524D700A3D7F1 /* CDVPluginManager.m in Sources */, 2F5C871F1FE98418004B09C7 /* CDVCommandDelegateImpl.m in Sources */, + 62959B8B2526230C00A3D7F1 /* CDVUserAgentUtil.m in Sources */, 2F5C871D1FE98418004B09C7 /* CDVPluginResult.m in Sources */, 2F4F657C2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.m in Sources */, 2F5C87211FE98418004B09C7 /* CDVPlugin.m in Sources */, @@ -259,6 +282,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -266,8 +290,10 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -317,6 +343,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -324,8 +351,10 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -367,6 +396,7 @@ INFOPLIST_FILE = CapacitorCordova/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = CapacitorCordova/CapacitorCordova.modulemap; PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.ios.CapacitorCordova; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -386,6 +416,7 @@ INFOPLIST_FILE = CapacitorCordova/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = CapacitorCordova/CapacitorCordova.modulemap; PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.ios.CapacitorCordova; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -405,7 +436,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 2F5C86E41FE94845004B09C7 /* Build configuration list for PBXNativeTarget "CapacitorCordova" */ = { + 2F5C86E41FE94845004B09C7 /* Build configuration list for PBXNativeTarget "Cordova" */ = { isa = XCConfigurationList; buildConfigurations = ( 2F5C86E51FE94845004B09C7 /* Debug */, diff --git a/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h b/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h index 40f93f22eb..8b9d5fe0ed 100644 --- a/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h +++ b/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h @@ -6,16 +6,19 @@ FOUNDATION_EXPORT double CapacitorCordovaVersionNumber; //! Project version string for CapacitorCordova. FOUNDATION_EXPORT const unsigned char CapacitorCordovaVersionString[]; -// In this header, you should import all the public headers of your framework using statements like #import - +#import #import -#import #import -#import -#import #import -#import +#import #import +#import +#import +#import +#import +#import +#import +#import +#import #import #import -#import diff --git a/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.modulemap b/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.modulemap new file mode 100644 index 0000000000..32af43c122 --- /dev/null +++ b/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.modulemap @@ -0,0 +1,6 @@ +framework module Cordova { + umbrella header "CapacitorCordova.h" + + export * + module * { export * } +} diff --git a/ios/CapacitorCordova/CapacitorCordova/Info.plist b/ios/CapacitorCordova/CapacitorCordova/Info.plist index 1007fd9dd7..1483c473b4 100644 --- a/ios/CapacitorCordova/CapacitorCordova/Info.plist +++ b/ios/CapacitorCordova/CapacitorCordova/Info.plist @@ -4,6 +4,8 @@ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Cordova CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier From 413af81a62174710655db6e29c0465087da10bb8 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Thu, 1 Oct 2020 15:42:07 -0400 Subject: [PATCH 03/40] Removing unneeded pod install step so build will work. --- ios/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/package.json b/ios/package.json index b7e1d39f65..7b7f0aa521 100644 --- a/ios/package.json +++ b/ios/package.json @@ -7,7 +7,7 @@ "license": "MIT", "scripts": { "verify": "npm run xc:build:Capacitor && npm run xc:build:CapacitorCordova && npm run pod:lint:Capacitor && npm run pod:lint:CapacitorCordova", - "xc:build:Capacitor": "cd Capacitor && pod install && xcodebuild -workspace Capacitor.xcworkspace -scheme Capacitor && cd ..", + "xc:build:Capacitor": "cd Capacitor && xcodebuild -workspace Capacitor.xcworkspace -scheme Capacitor && cd ..", "xc:build:CapacitorCordova": "cd CapacitorCordova && xcodebuild && cd ..", "pod:lint:Capacitor": "pod lib lint --allow-warnings Capacitor.podspec", "pod:lint:CapacitorCordova": "pod lib lint --allow-warnings CapacitorCordova.podspec" From 5338f02c2baf466949de285cf3553a942d94276f Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Thu, 15 Oct 2020 10:52:06 -0400 Subject: [PATCH 04/40] Cleanup from cherry-picking commits --- .../Capacitor.xcodeproj/project.pbxproj | 28 ------------------- ios/Capacitor/Capacitor/Capacitor.modulemap | 1 - .../project.pbxproj | 8 ------ .../CapacitorCordova/CapacitorCordova.h | 1 - 4 files changed, 38 deletions(-) diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj index d86e3b0f9d..190d5dbcaf 100644 --- a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj +++ b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj @@ -12,20 +12,16 @@ 50503EEE1FC08595003606DC /* CapacitorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50503EED1FC08595003606DC /* CapacitorTests.swift */; }; 62959B162524DA7800A3D7F1 /* CAPPluginCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */; settings = {ATTRIBUTES = (Public, ); }; }; 62959B172524DA7800A3D7F1 /* JSExport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE32524DA7700A3D7F1 /* JSExport.swift */; }; - 62959B182524DA7800A3D7F1 /* CAPBridgedJSTypes.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE42524DA7700A3D7F1 /* CAPBridgedJSTypes.m */; }; 62959B192524DA7800A3D7F1 /* CAPBridgedPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; 62959B1A2524DA7800A3D7F1 /* CAPPluginCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */; }; 62959B1B2524DA7800A3D7F1 /* CAPFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE72524DA7700A3D7F1 /* CAPFile.swift */; }; 62959B1C2524DA7800A3D7F1 /* CAPPluginMethod.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */; }; 62959B1D2524DA7800A3D7F1 /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE92524DA7700A3D7F1 /* UIColor.swift */; }; - 62959B1E2524DA7800A3D7F1 /* StatusBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AEB2524DA7700A3D7F1 /* StatusBar.swift */; }; - 62959B1F2524DA7800A3D7F1 /* Keyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AEC2524DA7700A3D7F1 /* Keyboard.m */; }; 62959B222524DA7800A3D7F1 /* Console.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AEF2524DA7700A3D7F1 /* Console.swift */; }; 62959B232524DA7800A3D7F1 /* DefaultPlugins.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */; }; 62959B242524DA7800A3D7F1 /* Geolocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF12524DA7700A3D7F1 /* Geolocation.swift */; }; 62959B252524DA7800A3D7F1 /* PushNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */; }; 62959B262524DA7800A3D7F1 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF32524DA7700A3D7F1 /* WebView.swift */; }; - 62959B272524DA7800A3D7F1 /* Keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AF42524DA7700A3D7F1 /* Keyboard.h */; }; 62959B282524DA7800A3D7F1 /* BackgroundTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */; }; 62959B292524DA7800A3D7F1 /* SplashScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */; }; 62959B2C2524DA7800A3D7F1 /* LocalNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */; }; @@ -33,10 +29,8 @@ 62959B2F2524DA7800A3D7F1 /* DefaultPlugins.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */; }; 62959B302524DA7800A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */; }; 62959B312524DA7800A3D7F1 /* JS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFF2524DA7700A3D7F1 /* JS.swift */; }; - 62959B322524DA7800A3D7F1 /* CAPAppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B002524DA7700A3D7F1 /* CAPAppDelegate.swift */; }; 62959B332524DA7800A3D7F1 /* CAPPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959B012524DA7700A3D7F1 /* CAPPlugin.m */; }; 62959B342524DA7800A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B022524DA7700A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift */; }; - 62959B352524DA7800A3D7F1 /* CAPBridgedJSTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B032524DA7700A3D7F1 /* CAPBridgedJSTypes.h */; settings = {ATTRIBUTES = (Public, ); }; }; 62959B362524DA7800A3D7F1 /* CAPBridgeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */; }; 62959B372524DA7800A3D7F1 /* CAPConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B052524DA7700A3D7F1 /* CAPConfig.swift */; }; 62959B382524DA7800A3D7F1 /* CAPPluginCall.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959B062524DA7700A3D7F1 /* CAPPluginCall.m */; }; @@ -45,7 +39,6 @@ 62959B3B2524DA7800A3D7F1 /* CAPPluginMethod.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B092524DA7700A3D7F1 /* CAPPluginMethod.h */; settings = {ATTRIBUTES = (Public, ); }; }; 62959B3C2524DA7800A3D7F1 /* CAPBridgeDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */; }; 62959B3D2524DA7800A3D7F1 /* CAPMessageHandlerWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0B2524DA7700A3D7F1 /* CAPMessageHandlerWrapper.swift */; }; - 62959B3E2524DA7800A3D7F1 /* JSTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0C2524DA7700A3D7F1 /* JSTypes.swift */; }; 62959B3F2524DA7800A3D7F1 /* CAPAssetHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0D2524DA7700A3D7F1 /* CAPAssetHandler.swift */; }; 62959B402524DA7800A3D7F1 /* TmpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0E2524DA7700A3D7F1 /* TmpViewController.swift */; }; 62959B412524DA7800A3D7F1 /* Capacitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B0F2524DA7700A3D7F1 /* Capacitor.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -96,20 +89,16 @@ 50503EED1FC08595003606DC /* CapacitorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapacitorTests.swift; sourceTree = ""; }; 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPPluginCall.h; sourceTree = ""; }; 62959AE32524DA7700A3D7F1 /* JSExport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSExport.swift; sourceTree = ""; }; - 62959AE42524DA7700A3D7F1 /* CAPBridgedJSTypes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPBridgedJSTypes.m; sourceTree = ""; }; 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPBridgedPlugin.h; sourceTree = ""; }; 62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPPluginCall.swift; sourceTree = ""; }; 62959AE72524DA7700A3D7F1 /* CAPFile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPFile.swift; sourceTree = ""; }; 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPPluginMethod.m; sourceTree = ""; }; 62959AE92524DA7700A3D7F1 /* UIColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = ""; }; - 62959AEB2524DA7700A3D7F1 /* StatusBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBar.swift; sourceTree = ""; }; - 62959AEC2524DA7700A3D7F1 /* Keyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Keyboard.m; sourceTree = ""; }; 62959AEF2524DA7700A3D7F1 /* Console.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Console.swift; sourceTree = ""; }; 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultPlugins.h; sourceTree = ""; }; 62959AF12524DA7700A3D7F1 /* Geolocation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Geolocation.swift; sourceTree = ""; }; 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PushNotifications.swift; sourceTree = ""; }; 62959AF32524DA7700A3D7F1 /* WebView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = ""; }; - 62959AF42524DA7700A3D7F1 /* Keyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Keyboard.h; sourceTree = ""; }; 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundTask.swift; sourceTree = ""; }; 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SplashScreen.swift; sourceTree = ""; }; 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalNotifications.swift; sourceTree = ""; }; @@ -117,10 +106,8 @@ 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DefaultPlugins.m; sourceTree = ""; }; 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIStatusBarManager+CAPHandleTapAction.m"; sourceTree = ""; }; 62959AFF2524DA7700A3D7F1 /* JS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JS.swift; sourceTree = ""; }; - 62959B002524DA7700A3D7F1 /* CAPAppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPAppDelegate.swift; sourceTree = ""; }; 62959B012524DA7700A3D7F1 /* CAPPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPPlugin.m; sourceTree = ""; }; 62959B022524DA7700A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPUNUserNotificationCenterDelegate.swift; sourceTree = ""; }; - 62959B032524DA7700A3D7F1 /* CAPBridgedJSTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPBridgedJSTypes.h; sourceTree = ""; }; 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPBridgeViewController.swift; sourceTree = ""; }; 62959B052524DA7700A3D7F1 /* CAPConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPConfig.swift; sourceTree = ""; }; 62959B062524DA7700A3D7F1 /* CAPPluginCall.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPPluginCall.m; sourceTree = ""; }; @@ -129,7 +116,6 @@ 62959B092524DA7700A3D7F1 /* CAPPluginMethod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPPluginMethod.h; sourceTree = ""; }; 62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPBridgeDelegate.swift; sourceTree = ""; }; 62959B0B2524DA7700A3D7F1 /* CAPMessageHandlerWrapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPMessageHandlerWrapper.swift; sourceTree = ""; }; - 62959B0C2524DA7700A3D7F1 /* JSTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSTypes.swift; sourceTree = ""; }; 62959B0D2524DA7700A3D7F1 /* CAPAssetHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPAssetHandler.swift; sourceTree = ""; }; 62959B0E2524DA7700A3D7F1 /* TmpViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TmpViewController.swift; sourceTree = ""; }; 62959B0F2524DA7700A3D7F1 /* Capacitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Capacitor.h; sourceTree = ""; }; @@ -213,8 +199,6 @@ 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */, 62959B092524DA7700A3D7F1 /* CAPPluginMethod.h */, 62959AE32524DA7700A3D7F1 /* JSExport.swift */, - 62959B032524DA7700A3D7F1 /* CAPBridgedJSTypes.h */, - 62959AE42524DA7700A3D7F1 /* CAPBridgedJSTypes.m */, 62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */, 62959AE72524DA7700A3D7F1 /* CAPFile.swift */, 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */, @@ -222,7 +206,6 @@ 62959AEA2524DA7700A3D7F1 /* Plugins */, 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */, 62959AFF2524DA7700A3D7F1 /* JS.swift */, - 62959B002524DA7700A3D7F1 /* CAPAppDelegate.swift */, 62959B012524DA7700A3D7F1 /* CAPPlugin.m */, 62959B022524DA7700A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift */, 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */, @@ -232,7 +215,6 @@ 62959B082524DA7700A3D7F1 /* CAPLog.swift */, 62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */, 62959B0B2524DA7700A3D7F1 /* CAPMessageHandlerWrapper.swift */, - 62959B0C2524DA7700A3D7F1 /* JSTypes.swift */, 62959B0D2524DA7700A3D7F1 /* CAPAssetHandler.swift */, 62959B0E2524DA7700A3D7F1 /* TmpViewController.swift */, 62959B102524DA7700A3D7F1 /* DocLinks.swift */, @@ -254,12 +236,9 @@ 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */, 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */, 62959AF12524DA7700A3D7F1 /* Geolocation.swift */, - 62959AF42524DA7700A3D7F1 /* Keyboard.h */, - 62959AEC2524DA7700A3D7F1 /* Keyboard.m */, 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */, 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */, 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */, - 62959AEB2524DA7700A3D7F1 /* StatusBar.swift */, 62959AF32524DA7700A3D7F1 /* WebView.swift */, ); path = Plugins; @@ -285,8 +264,6 @@ 62959B162524DA7800A3D7F1 /* CAPPluginCall.h in Headers */, 62959B3B2524DA7800A3D7F1 /* CAPPluginMethod.h in Headers */, 62959B192524DA7800A3D7F1 /* CAPBridgedPlugin.h in Headers */, - 62959B352524DA7800A3D7F1 /* CAPBridgedJSTypes.h in Headers */, - 62959B272524DA7800A3D7F1 /* Keyboard.h in Headers */, 62959B232524DA7800A3D7F1 /* DefaultPlugins.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -412,9 +389,6 @@ 62959B402524DA7800A3D7F1 /* TmpViewController.swift in Sources */, 62959B372524DA7800A3D7F1 /* CAPConfig.swift in Sources */, 62959B432524DA7800A3D7F1 /* Data+Capacitor.swift in Sources */, - 62959B1E2524DA7800A3D7F1 /* StatusBar.swift in Sources */, - 62959B322524DA7800A3D7F1 /* CAPAppDelegate.swift in Sources */, - 62959B3E2524DA7800A3D7F1 /* JSTypes.swift in Sources */, 62959B382524DA7800A3D7F1 /* CAPPluginCall.m in Sources */, 62959B1B2524DA7800A3D7F1 /* CAPFile.swift in Sources */, 62959B462524DA7800A3D7F1 /* CAPBridge.swift in Sources */, @@ -436,13 +410,11 @@ 62959B172524DA7800A3D7F1 /* JSExport.swift in Sources */, 62959B2D2524DA7800A3D7F1 /* App.swift in Sources */, 62959B3F2524DA7800A3D7F1 /* CAPAssetHandler.swift in Sources */, - 62959B1F2524DA7800A3D7F1 /* Keyboard.m in Sources */, 62959B3C2524DA7800A3D7F1 /* CAPBridgeDelegate.swift in Sources */, 62959B2C2524DA7800A3D7F1 /* LocalNotifications.swift in Sources */, 62959B2F2524DA7800A3D7F1 /* DefaultPlugins.m in Sources */, 62959B222524DA7800A3D7F1 /* Console.swift in Sources */, 62959B3A2524DA7800A3D7F1 /* CAPLog.swift in Sources */, - 62959B182524DA7800A3D7F1 /* CAPBridgedJSTypes.m in Sources */, 62959B262524DA7800A3D7F1 /* WebView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/ios/Capacitor/Capacitor/Capacitor.modulemap b/ios/Capacitor/Capacitor/Capacitor.modulemap index 580ea550e5..f63e44af3c 100644 --- a/ios/Capacitor/Capacitor/Capacitor.modulemap +++ b/ios/Capacitor/Capacitor/Capacitor.modulemap @@ -1,6 +1,5 @@ framework module Capacitor { umbrella header "Capacitor.h" - exclude header "CAPBridgedJSTypes.h" export * module * { export * } diff --git a/ios/CapacitorCordova/CapacitorCordova.xcodeproj/project.pbxproj b/ios/CapacitorCordova/CapacitorCordova.xcodeproj/project.pbxproj index 1d1ecb9daf..7febec81ba 100644 --- a/ios/CapacitorCordova/CapacitorCordova.xcodeproj/project.pbxproj +++ b/ios/CapacitorCordova/CapacitorCordova.xcodeproj/project.pbxproj @@ -34,8 +34,6 @@ 62959B66252524CD00A3D7F1 /* CDVScreenOrientationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B65252524CD00A3D7F1 /* CDVScreenOrientationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 62959B6A252524D700A3D7F1 /* CDVPluginManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B68252524D700A3D7F1 /* CDVPluginManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; 62959B6B252524D700A3D7F1 /* CDVPluginManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959B69252524D700A3D7F1 /* CDVPluginManager.m */; }; - 62959B8B2526230C00A3D7F1 /* CDVUserAgentUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959B892526230C00A3D7F1 /* CDVUserAgentUtil.m */; }; - 62959B8C2526230C00A3D7F1 /* CDVUserAgentUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B8A2526230C00A3D7F1 /* CDVUserAgentUtil.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -69,8 +67,6 @@ 62959B65252524CD00A3D7F1 /* CDVScreenOrientationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVScreenOrientationDelegate.h; sourceTree = ""; }; 62959B68252524D700A3D7F1 /* CDVPluginManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVPluginManager.h; sourceTree = ""; }; 62959B69252524D700A3D7F1 /* CDVPluginManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVPluginManager.m; sourceTree = ""; }; - 62959B892526230C00A3D7F1 /* CDVUserAgentUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVUserAgentUtil.m; sourceTree = ""; }; - 62959B8A2526230C00A3D7F1 /* CDVUserAgentUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVUserAgentUtil.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -144,8 +140,6 @@ 62959B65252524CD00A3D7F1 /* CDVScreenOrientationDelegate.h */, 2F8AC282217F3A20008C2C33 /* CDVURLProtocol.h */, 2F8AC281217F3A20008C2C33 /* CDVURLProtocol.m */, - 62959B8A2526230C00A3D7F1 /* CDVUserAgentUtil.h */, - 62959B892526230C00A3D7F1 /* CDVUserAgentUtil.m */, 2F4F657B2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.h */, 2F4F657A2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.m */, 2F856BFD203DEB320047344A /* CDVViewController.h */, @@ -173,7 +167,6 @@ 2F856BFF203DEB320047344A /* CDVViewController.h in Headers */, 2F4F657D2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.h in Headers */, 2F8AC284217F3A20008C2C33 /* CDVURLProtocol.h in Headers */, - 62959B8C2526230C00A3D7F1 /* CDVUserAgentUtil.h in Headers */, 2F92AB5324D9ABA000954A4A /* CDVPlugin+Resources.h in Headers */, 62959B66252524CD00A3D7F1 /* CDVScreenOrientationDelegate.h in Headers */, 62959B6A252524D700A3D7F1 /* CDVPluginManager.h in Headers */, @@ -252,7 +245,6 @@ files = ( 62959B6B252524D700A3D7F1 /* CDVPluginManager.m in Sources */, 2F5C871F1FE98418004B09C7 /* CDVCommandDelegateImpl.m in Sources */, - 62959B8B2526230C00A3D7F1 /* CDVUserAgentUtil.m in Sources */, 2F5C871D1FE98418004B09C7 /* CDVPluginResult.m in Sources */, 2F4F657C2091F1FD00EAA994 /* NSDictionary+CordovaPreferences.m in Sources */, 2F5C87211FE98418004B09C7 /* CDVPlugin.m in Sources */, diff --git a/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h b/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h index 8b9d5fe0ed..bee4ca2ead 100644 --- a/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h +++ b/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h @@ -19,6 +19,5 @@ FOUNDATION_EXPORT const unsigned char CapacitorCordovaVersionString[]; #import #import #import -#import #import #import From 8a40a6ab6d1511187b58b0302a9021f7e1e02753 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Thu, 15 Oct 2020 11:28:18 -0400 Subject: [PATCH 05/40] Deleted exclusion of removed file. --- ios/Capacitor.podspec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ios/Capacitor.podspec b/ios/Capacitor.podspec index ede5d671d2..6e0890f6e0 100644 --- a/ios/Capacitor.podspec +++ b/ios/Capacitor.podspec @@ -11,8 +11,7 @@ Pod::Spec.new do |s| s.authors = { 'Ionic Team' => 'hi@ionicframework.com' } s.source = { :git => 'https://github.com/ionic-team/capacitor.git', :tag => s.version.to_s } s.source_files = 'Capacitor/Capacitor/*.{swift,h,m}', 'Capacitor/Capacitor/Plugins/*.{swift,h,m}', 'Capacitor/Capacitor/Plugins/**/*.{swift,h,m}' - s.exclude_files = 'Capacitor/Capacitor/Plugins/DefaultPlugins.h', - 'Capacitor/Capacitor/Plugins/Keyboard.h' + s.exclude_files = 'Capacitor/Capacitor/Plugins/DefaultPlugins.h' s.module_map = 'Capacitor/Capacitor/Capacitor.modulemap' s.dependency 'CapacitorCordova' s.swift_version = '5.0' From 6b0798e22ce689ffee1fa83b5ad56a58e0e6e3dd Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Tue, 4 Aug 2020 11:21:47 -0400 Subject: [PATCH 06/40] Defining new JS types and supporting protocols. --- ios/Capacitor/Capacitor/CAPBridgedJSTypes.h | 16 ++ ios/Capacitor/Capacitor/CAPBridgedJSTypes.m | 28 ++++ ios/Capacitor/Capacitor/JS.swift | 3 - ios/Capacitor/Capacitor/JSTypes.swift | 170 ++++++++++++++++++++ 4 files changed, 214 insertions(+), 3 deletions(-) create mode 100644 ios/Capacitor/Capacitor/CAPBridgedJSTypes.h create mode 100644 ios/Capacitor/Capacitor/CAPBridgedJSTypes.m create mode 100644 ios/Capacitor/Capacitor/JSTypes.swift diff --git a/ios/Capacitor/Capacitor/CAPBridgedJSTypes.h b/ios/Capacitor/Capacitor/CAPBridgedJSTypes.h new file mode 100644 index 0000000000..ecf3129642 --- /dev/null +++ b/ios/Capacitor/Capacitor/CAPBridgedJSTypes.h @@ -0,0 +1,16 @@ +// Convenience methods for bridging to/from JavaScript types. Deliberately hidden from +// Swift by omission (to avoid collisions with Swift protocols), use +// `#import ` if working in Objective-C. + +#import +#import + +@protocol BridgedJSValueContainerImplementation +@required +- (NSString * _Nullable)getString:(NSString * _Nonnull)key defaultValue:(NSString * _Nullable)defaultValue; +- (NSDate * _Nullable)getDate:(NSString * _Nonnull)key defaultValue:(NSDate * _Nullable)defaultValue; +- (NSDictionary * _Nullable)getObject:(NSString * _Nonnull)key defaultValue:(NSDictionary * _Nullable)defaultValue; +@end + +@interface CAPPluginCall (BridgedJSProtocol) +@end diff --git a/ios/Capacitor/Capacitor/CAPBridgedJSTypes.m b/ios/Capacitor/Capacitor/CAPBridgedJSTypes.m new file mode 100644 index 0000000000..686531a3a4 --- /dev/null +++ b/ios/Capacitor/Capacitor/CAPBridgedJSTypes.m @@ -0,0 +1,28 @@ +#import +#import "CAPBridgedJSTypes.h" + +@implementation CAPPluginCall (BridgedJSProtocol) +- (NSString * _Nullable)getString:(NSString * _Nonnull)key defaultValue:(NSString * _Nullable)defaultValue { + id value = [[self dictionaryRepresentation] objectForKey:key]; + if (value != nil && [value isKindOfClass:[NSString class]]) { + return value; + } + return defaultValue; +} + +- (NSDate * _Nullable)getDate:(NSString * _Nonnull)key defaultValue:(NSDate * _Nullable)defaultValue { + id value = [[self dictionaryRepresentation] objectForKey:key]; + if (value != nil && [value isKindOfClass:[NSString class]]) { + return [[[self class] jsDateFormatter] dateFromString:value]; + } + return defaultValue; +} + +- (NSDictionary * _Nullable)getObject:(NSString * _Nonnull)key defaultValue:(NSDictionary * _Nullable)defaultValue { + id value = [[self dictionaryRepresentation] objectForKey:key]; + if (value != nil && [value isKindOfClass:[NSDictionary class]]) { + return value; + } + return defaultValue; +} +@end diff --git a/ios/Capacitor/Capacitor/JS.swift b/ios/Capacitor/Capacitor/JS.swift index 4709dfdb86..0f33b95c86 100644 --- a/ios/Capacitor/Capacitor/JS.swift +++ b/ios/Capacitor/Capacitor/JS.swift @@ -10,9 +10,6 @@ enum JSProcessingError: LocalizedError { } } -public typealias JSObject = [String: Any] -public typealias JSArray = [JSObject] - public class JSDate { static func toString(_ date: Date) -> String { let formatter = ISO8601DateFormatter() diff --git a/ios/Capacitor/Capacitor/JSTypes.swift b/ios/Capacitor/Capacitor/JSTypes.swift new file mode 100644 index 0000000000..1d30bbefce --- /dev/null +++ b/ios/Capacitor/Capacitor/JSTypes.swift @@ -0,0 +1,170 @@ +import Foundation + +// declare our empty protocol, and conformance, for typing +public protocol JSValue {} +extension String: JSValue {} +extension Bool: JSValue {} +extension Int: JSValue {} +extension Float: JSValue {} +extension Double: JSValue {} +extension NSNumber: JSValue {} +extension Array: JSValue {} +extension Dictionary: JSValue where Key == String, Value == JSValue {} + +// convenience aliases +public typealias JSObject = Dictionary +public typealias JSArray = Array + +// string types +public protocol JSStringContainer { + func getString(_ key: String, _ defaultValue: String) -> String + func getString(_ key: String) -> String? +} + +extension JSStringContainer { + public func getString(_ key: String, _ defaultValue: String) -> String { + return getString(key) ?? defaultValue + } +} + +// boolean types +public protocol JSBoolContainer { + func getBool(_ key: String, _ defaultValue: Bool) -> Bool + func getBool(_ key: String) -> Bool? +} + +extension JSBoolContainer { + public func getBool(_ key: String, _ defaultValue: Bool) -> Bool { + return getBool(key) ?? defaultValue + } +} + +// integer types +public protocol JSIntContainer { + func getInt(_ key: String, _ defaultValue: Int) -> Int + func getInt(_ key: String) -> Int? +} + +extension JSIntContainer { + public func getInt(_ key: String, _ defaultValue: Int) -> Int { + return getInt(key) ?? defaultValue + } +} + +// float types +public protocol JSFloatContainer { + func getFloat(_ key: String, _ defaultValue: Float) -> Float + func getFloat(_ key: String) -> Float? +} + +extension JSFloatContainer { + public func getFloat(_ key: String, _ defaultValue: Float) -> Float { + return getFloat(key) ?? defaultValue + } +} + +// double types +public protocol JSDoubleContainer { + func getDouble(_ key: String, _ defaultValue: Double) -> Double + func getDouble(_ key: String) -> Double? +} + +extension JSDoubleContainer { + public func getDouble(_ key: String, _ defaultValue: Double) -> Double { + return getDouble(key) ?? defaultValue + } +} + +// date types +public protocol JSDateContainer { + func getDate(_ key: String, _ defaultValue: Date) -> Date + func getDate(_ key: String) -> Date? +} + +extension JSDateContainer { + public func getDate(_ key: String, _ defaultValue: Date) -> Date { + return getDate(key) ?? defaultValue + } +} + +// array types +public protocol JSArrayContainer { + func getArray(_ key: String, _ defaultValue: JSArray) -> JSArray + func getArray(_ key: String, _ ofType: T.Type) -> [T]? + func getArray(_ key: String) -> JSArray? +} + +extension JSArrayContainer { + public func getArray(_ key: String, _ defaultValue: JSArray) -> JSArray { + return getArray(key) ?? defaultValue + } + + public func getArray(_ key: String, _ ofType: T.Type) -> [T]? { + return getArray(key) as? [T] + } +} + +// dictionary types +public protocol JSObjectContainer { + func getObject(_ key: String, _ defaultValue: JSObject) -> JSObject + func getObject(_ key: String) -> JSObject? +} + +extension JSObjectContainer { + public func getObject(_ key: String, _ defaultValue: JSObject) -> JSObject { + return getObject(key) ?? defaultValue + } +} + +public protocol JSValueContainer: JSStringContainer, JSBoolContainer, JSIntContainer, JSFloatContainer, JSDoubleContainer, JSDateContainer, JSArrayContainer, JSObjectContainer { + static var jsDateFormatter: ISO8601DateFormatter { get } + var jsObjectRepresentation: JSObject { get } +} + +extension JSValueContainer { + public func getString(_ key: String) -> String? { + return jsObjectRepresentation[key] as? String + } + + public func getBool(_ key: String) -> Bool? { + return jsObjectRepresentation[key] as? Bool + } + + public func getInt(_ key: String) -> Int? { + return jsObjectRepresentation[key] as? Int + } + + public func getFloat(_ key: String) -> Float? { + if let floatValue = jsObjectRepresentation[key] as? Float { + return floatValue + } + else if let doubleValue = jsObjectRepresentation[key] as? Double { + return Float(doubleValue) + } + return nil + } + + public func getDouble(_ key: String) -> Double? { + return jsObjectRepresentation[key] as? Double + } + + public func getDate(_ key: String) -> Date? { + if let isoString = jsObjectRepresentation[key] as? String { + return Self.jsDateFormatter.date(from: isoString) + } + return nil + } + + public func getArray(_ key: String) -> JSArray? { + return jsObjectRepresentation[key] as? JSArray + } + + public func getObject(_ key: String) -> JSObject? { + return jsObjectRepresentation[key] as? JSObject + } +} + +@objc protocol BridgedJSValueContainer: NSObjectProtocol { + static var jsDateFormatter: ISO8601DateFormatter { get } + var dictionaryRepresentation: NSDictionary { get } +} From 005ccb8282e989b2f86432eb6007076015c33e92 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Tue, 4 Aug 2020 11:22:23 -0400 Subject: [PATCH 07/40] Updating CAPPluginCall to use new types. --- ios/Capacitor/Capacitor/CAPPluginCall.swift | 59 +++++---------------- 1 file changed, 13 insertions(+), 46 deletions(-) diff --git a/ios/Capacitor/Capacitor/CAPPluginCall.swift b/ios/Capacitor/Capacitor/CAPPluginCall.swift index da5c50e734..550da8fa2a 100644 --- a/ios/Capacitor/Capacitor/CAPPluginCall.swift +++ b/ios/Capacitor/Capacitor/CAPPluginCall.swift @@ -5,58 +5,25 @@ public typealias PluginEventListener = CAPPluginCall /** * Swift niceties for CAPPluginCall */ -@objc public extension CAPPluginCall { - - private static let UNIMPLEMENTED = "not implemented" - - @nonobjc func get(_ key: String, _ ofType: T.Type, _ defaultValue: T? = nil) -> T? { - return self.options[key] as? T ?? defaultValue - } - @nonobjc func getArray(_ key: String, _ ofType: T.Type, _ defaultValue: [T]? = nil) -> [T]? { - return self.options[key] as? [T] ?? defaultValue - } - - @nonobjc func getBool(_ key: String, _ defaultValue: Bool? = nil) -> Bool? { - return self.options[key] as? Bool ?? defaultValue - } - - @nonobjc func getInt(_ key: String, _ defaultValue: Int? = nil) -> Int? { - return self.options[key] as? Int ?? defaultValue - } - - @nonobjc func getFloat(_ key: String, _ defaultValue: Float? = nil) -> Float? { - if let floatValue = self.options[key] as? Float { - return floatValue - } - if let doubleValue = self.options[key] as? Double { - return Float(doubleValue) - } - return defaultValue - } - - @nonobjc func getDouble(_ key: String, _ defaultValue: Double? = nil) -> Double? { - return self.options[key] as? Double ?? defaultValue +extension CAPPluginCall: JSValueContainer { + public var jsObjectRepresentation: JSObject { + return options as? JSObject ?? [:] } +} - func getString(_ key: String, _ defaultValue: String? = nil) -> String? { - return self.options[key] as? String ?? defaultValue +@objc extension CAPPluginCall: BridgedJSValueContainer { + public var dictionaryRepresentation: NSDictionary { + return options as NSDictionary } - func getDate(_ key: String, _ defaultValue: Date? = nil) -> Date? { - guard let isoString = self.options[key] as? String else { - return defaultValue - } - let dateFormatter = DateFormatter() - dateFormatter.locale = Locale(identifier: "en_US_POSIX") - dateFormatter.timeZone = TimeZone.autoupdatingCurrent - dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" - return dateFormatter.date(from: isoString) - } + public static var jsDateFormatter: ISO8601DateFormatter = { + return ISO8601DateFormatter() + }() +} - func getObject(_ key: String, defaultValue: [String: Any]? = nil) -> [String: Any]? { - return self.options[key] as? [String: Any] ?? defaultValue - } +@objc public extension CAPPluginCall { + private static let UNIMPLEMENTED = "not implemented" func hasOption(_ key: String) -> Bool { return self.options.index(forKey: key) != nil From 216bb707fb979ad6d7768d1e54f400a62d0c682c Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Tue, 4 Aug 2020 11:23:33 -0400 Subject: [PATCH 08/40] Updating existing code to use new types and accessors. --- .../CAPUNUserNotificationCenterDelegate.swift | 4 ++-- .../Capacitor/Plugins/LocalNotifications.swift | 13 +++++++++++-- .../Capacitor/Plugins/PushNotifications.swift | 2 +- ios/Capacitor/Capacitor/Plugins/SplashScreen.swift | 10 +++++----- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/ios/Capacitor/Capacitor/CAPUNUserNotificationCenterDelegate.swift b/ios/Capacitor/Capacitor/CAPUNUserNotificationCenterDelegate.swift index cf3de4b882..7a86509fa4 100644 --- a/ios/Capacitor/Capacitor/CAPUNUserNotificationCenterDelegate.swift +++ b/ios/Capacitor/Capacitor/CAPUNUserNotificationCenterDelegate.swift @@ -144,7 +144,7 @@ public class CAPUNUserNotificationCenterDelegate: NSObject, UNUserNotificationCe "title": request.content.title, "sound": notificationRequest["sound"] ?? "", "body": request.content.body, - "extra": request.content.userInfo, + "extra": request.content.userInfo as? JSObject ?? [:], "actionTypeId": request.content.categoryIdentifier, "attachments": notificationRequest["attachments"] ?? [] ] @@ -161,7 +161,7 @@ public class CAPUNUserNotificationCenterDelegate: NSObject, UNUserNotificationCe "subtitle": content.subtitle, "body": content.body, "badge": content.badge ?? 1, - "data": content.userInfo + "data": content.userInfo as? JSObject ?? [:] ] } diff --git a/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift b/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift index 2c331e2f93..0579e65338 100644 --- a/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift +++ b/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift @@ -32,7 +32,7 @@ public class CAPLocalNotificationsPlugin: CAPPlugin { * Schedule a notification. */ @objc func schedule(_ call: CAPPluginCall) { - guard let notifications = call.getArray("notifications", [String: Any].self) else { + guard let notifications = call.getArray("notifications", JSObject.self) else { call.error("Must provide notifications array as notifications option") return } @@ -109,7 +109,7 @@ public class CAPLocalNotificationsPlugin: CAPPlugin { * Cancel notifications by id */ @objc func cancel(_ call: CAPPluginCall) { - guard let notifications = call.getArray("notifications", JSObject.self, []), notifications.count > 0 else { + guard let notifications = call.getArray("notifications", JSObject.self), notifications.count > 0 else { call.error("Must supply notifications to cancel") return } @@ -338,6 +338,9 @@ public class CAPLocalNotificationsPlugin: CAPPlugin { createdCategories.append(generalCategory) for type in actionTypes { + guard let type = type as? JSObject else { + continue + } guard let id = type["id"] as? String else { bridge?.modulePrint(self, "Action type must have an id field") continue @@ -370,6 +373,9 @@ public class CAPLocalNotificationsPlugin: CAPPlugin { var createdActions = [UNNotificationAction]() for action in actions { + guard let action = action as? JSObject else { + continue + } guard let id = action["id"] as? String else { bridge?.modulePrint(self, "Action must have an id field") continue @@ -456,6 +462,9 @@ public class CAPLocalNotificationsPlugin: CAPPlugin { var createdAttachments = [UNNotificationAttachment]() for attachment in attachments { + guard let attachment = attachment as? JSObject else { + continue + } guard let id = attachment["id"] as? String else { throw LocalNotificationError.attachmentNoId } diff --git a/ios/Capacitor/Capacitor/Plugins/PushNotifications.swift b/ios/Capacitor/Capacitor/Plugins/PushNotifications.swift index de47a7f3f5..43aca31238 100644 --- a/ios/Capacitor/Capacitor/Plugins/PushNotifications.swift +++ b/ios/Capacitor/Capacitor/Plugins/PushNotifications.swift @@ -66,7 +66,7 @@ public class CAPPushNotificationsPlugin: CAPPlugin { * Remove specified notifications from Notification Center */ @objc func removeDeliveredNotifications(_ call: CAPPluginCall) { - guard let notifications = call.getArray("notifications", JSObject.self, []) else { + guard let notifications = call.getArray("notifications", JSObject.self) else { call.error("Must supply notifications to remove") return } diff --git a/ios/Capacitor/Capacitor/Plugins/SplashScreen.swift b/ios/Capacitor/Capacitor/Plugins/SplashScreen.swift index bb605dddd1..f628e11809 100644 --- a/ios/Capacitor/Capacitor/Plugins/SplashScreen.swift +++ b/ios/Capacitor/Capacitor/Plugins/SplashScreen.swift @@ -33,10 +33,10 @@ public class CAPSplashScreenPlugin: CAPPlugin { return } - let showDuration = call.get("showDuration", Int.self, defaultShowDuration)! - let fadeInDuration = call.get("fadeInDuration", Int.self, defaultFadeInDuration)! - let fadeOutDuration = call.get("fadeOutDuration", Int.self, defaultFadeOutDuration)! - let autoHide = call.get("autoHide", Bool.self, defaultAutoHide)! + let showDuration = call.getInt("showDuration", defaultShowDuration) + let fadeInDuration = call.getInt("fadeInDuration", defaultFadeInDuration) + let fadeOutDuration = call.getInt("fadeOutDuration", defaultFadeOutDuration) + let autoHide = call.getBool("autoHide", defaultAutoHide) let backgroundColor = getConfigValue("backgroundColor") as? String ?? nil let spinnerStyle = getConfigValue("iosSpinnerStyle") as? String ?? nil let spinnerColor = getConfigValue("spinnerColor") as? String ?? nil @@ -57,7 +57,7 @@ public class CAPSplashScreenPlugin: CAPPlugin { // Hide the splash screen @objc public func hide(_ call: CAPPluginCall) { self.call = call - let fadeDuration = call.get("fadeOutDuration", Int.self, defaultFadeOutDuration)! + let fadeDuration = call.getInt("fadeOutDuration", defaultFadeOutDuration) hideSplash(fadeOutDuration: fadeDuration) call.success() } From 5274e81e23f70098d18beb60aa6d80ad25c2310b Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Fri, 2 Oct 2020 11:27:09 -0400 Subject: [PATCH 09/40] Swiftlint changes --- ios/Capacitor/Capacitor/JSTypes.swift | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ios/Capacitor/Capacitor/JSTypes.swift b/ios/Capacitor/Capacitor/JSTypes.swift index 1d30bbefce..d77e2353b0 100644 --- a/ios/Capacitor/Capacitor/JSTypes.swift +++ b/ios/Capacitor/Capacitor/JSTypes.swift @@ -12,8 +12,8 @@ extension Array: JSValue {} extension Dictionary: JSValue where Key == String, Value == JSValue {} // convenience aliases -public typealias JSObject = Dictionary -public typealias JSArray = Array +public typealias JSObject = [String: JSValue] +public typealias JSArray = [JSValue] // string types public protocol JSStringContainer { @@ -98,7 +98,7 @@ extension JSArrayContainer { public func getArray(_ key: String, _ defaultValue: JSArray) -> JSArray { return getArray(key) ?? defaultValue } - + public func getArray(_ key: String, _ ofType: T.Type) -> [T]? { return getArray(key) as? [T] } @@ -116,7 +116,7 @@ extension JSObjectContainer { } } -public protocol JSValueContainer: JSStringContainer, JSBoolContainer, JSIntContainer, JSFloatContainer, JSDoubleContainer, JSDateContainer, JSArrayContainer, JSObjectContainer { +public protocol JSValueContainer: JSStringContainer, JSBoolContainer, JSIntContainer, JSFloatContainer, JSDoubleContainer, JSDateContainer, JSArrayContainer, JSObjectContainer { static var jsDateFormatter: ISO8601DateFormatter { get } var jsObjectRepresentation: JSObject { get } } @@ -125,40 +125,39 @@ extension JSValueContainer { public func getString(_ key: String) -> String? { return jsObjectRepresentation[key] as? String } - + public func getBool(_ key: String) -> Bool? { return jsObjectRepresentation[key] as? Bool } - + public func getInt(_ key: String) -> Int? { return jsObjectRepresentation[key] as? Int } - + public func getFloat(_ key: String) -> Float? { if let floatValue = jsObjectRepresentation[key] as? Float { return floatValue - } - else if let doubleValue = jsObjectRepresentation[key] as? Double { + } else if let doubleValue = jsObjectRepresentation[key] as? Double { return Float(doubleValue) } return nil } - + public func getDouble(_ key: String) -> Double? { return jsObjectRepresentation[key] as? Double } - + public func getDate(_ key: String) -> Date? { if let isoString = jsObjectRepresentation[key] as? String { return Self.jsDateFormatter.date(from: isoString) } return nil } - + public func getArray(_ key: String) -> JSArray? { return jsObjectRepresentation[key] as? JSArray } - + public func getObject(_ key: String) -> JSObject? { return jsObjectRepresentation[key] as? JSObject } From 1597b404fb22ccb58626f4772b8fe17d77efffaf Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Thu, 15 Oct 2020 11:47:10 -0400 Subject: [PATCH 10/40] Adding excluded header, file references in project. --- .../Capacitor.xcodeproj/project.pbxproj | 40 ++++++++++++------- ios/Capacitor/Capacitor/Capacitor.modulemap | 3 +- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj index 190d5dbcaf..d6ba653b08 100644 --- a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj +++ b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj @@ -10,6 +10,9 @@ 501CBAA71FC0A723009B0D4D /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 501CBAA61FC0A723009B0D4D /* WebKit.framework */; }; 50503EE91FC08595003606DC /* Capacitor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50503EDF1FC08594003606DC /* Capacitor.framework */; }; 50503EEE1FC08595003606DC /* CapacitorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50503EED1FC08595003606DC /* CapacitorTests.swift */; }; + 620850322538A3FC003BC41B /* CAPBridgedJSTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6208502F2538A3FC003BC41B /* CAPBridgedJSTypes.h */; }; + 620850332538A3FC003BC41B /* CAPBridgedJSTypes.m in Sources */ = {isa = PBXBuildFile; fileRef = 620850312538A3FC003BC41B /* CAPBridgedJSTypes.m */; }; + 620850362538A409003BC41B /* JSTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 620850352538A409003BC41B /* JSTypes.swift */; }; 62959B162524DA7800A3D7F1 /* CAPPluginCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */; settings = {ATTRIBUTES = (Public, ); }; }; 62959B172524DA7800A3D7F1 /* JSExport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE32524DA7700A3D7F1 /* JSExport.swift */; }; 62959B192524DA7800A3D7F1 /* CAPBridgedPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -87,6 +90,9 @@ 50503EDF1FC08594003606DC /* Capacitor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Capacitor.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 50503EE81FC08595003606DC /* CapacitorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CapacitorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50503EED1FC08595003606DC /* CapacitorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapacitorTests.swift; sourceTree = ""; }; + 6208502F2538A3FC003BC41B /* CAPBridgedJSTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPBridgedJSTypes.h; sourceTree = ""; }; + 620850312538A3FC003BC41B /* CAPBridgedJSTypes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPBridgedJSTypes.m; sourceTree = ""; }; + 620850352538A409003BC41B /* JSTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSTypes.swift; sourceTree = ""; }; 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPPluginCall.h; sourceTree = ""; }; 62959AE32524DA7700A3D7F1 /* JSExport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSExport.swift; sourceTree = ""; }; 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPBridgedPlugin.h; sourceTree = ""; }; @@ -195,33 +201,36 @@ children = ( 62959B0F2524DA7700A3D7F1 /* Capacitor.h */, 62959B132524DA7700A3D7F1 /* CAPPlugin.h */, - 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */, + 62959B012524DA7700A3D7F1 /* CAPPlugin.m */, 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */, - 62959B092524DA7700A3D7F1 /* CAPPluginMethod.h */, - 62959AE32524DA7700A3D7F1 /* JSExport.swift */, + 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */, + 62959B062524DA7700A3D7F1 /* CAPPluginCall.m */, 62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */, - 62959AE72524DA7700A3D7F1 /* CAPFile.swift */, + 62959B092524DA7700A3D7F1 /* CAPPluginMethod.h */, 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */, - 62959AE92524DA7700A3D7F1 /* UIColor.swift */, + 6208502F2538A3FC003BC41B /* CAPBridgedJSTypes.h */, + 620850312538A3FC003BC41B /* CAPBridgedJSTypes.m */, + 62959AE32524DA7700A3D7F1 /* JSExport.swift */, + 620850352538A409003BC41B /* JSTypes.swift */, 62959AEA2524DA7700A3D7F1 /* Plugins */, - 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */, + 62959B142524DA7700A3D7F1 /* CAPBridge.swift */, + 62959B052524DA7700A3D7F1 /* CAPConfig.swift */, + 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */, + 62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */, + 62959AE72524DA7700A3D7F1 /* CAPFile.swift */, 62959AFF2524DA7700A3D7F1 /* JS.swift */, - 62959B012524DA7700A3D7F1 /* CAPPlugin.m */, 62959B022524DA7700A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift */, - 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */, - 62959B052524DA7700A3D7F1 /* CAPConfig.swift */, - 62959B062524DA7700A3D7F1 /* CAPPluginCall.m */, - 62959B072524DA7700A3D7F1 /* CapacitorExtension.swift */, 62959B082524DA7700A3D7F1 /* CAPLog.swift */, - 62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */, 62959B0B2524DA7700A3D7F1 /* CAPMessageHandlerWrapper.swift */, 62959B0D2524DA7700A3D7F1 /* CAPAssetHandler.swift */, 62959B0E2524DA7700A3D7F1 /* TmpViewController.swift */, 62959B102524DA7700A3D7F1 /* DocLinks.swift */, + 62959B152524DA7700A3D7F1 /* CAPNotifications.swift */, + 62959B072524DA7700A3D7F1 /* CapacitorExtension.swift */, + 62959AE92524DA7700A3D7F1 /* UIColor.swift */, 62959B112524DA7700A3D7F1 /* Data+Capacitor.swift */, + 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */, 62959B122524DA7700A3D7F1 /* Info.plist */, - 62959B142524DA7700A3D7F1 /* CAPBridge.swift */, - 62959B152524DA7700A3D7F1 /* CAPNotifications.swift */, 62959B8225253A9500A3D7F1 /* Capacitor.modulemap */, ); path = Capacitor; @@ -261,6 +270,7 @@ files = ( 62959B412524DA7800A3D7F1 /* Capacitor.h in Headers */, 62959B452524DA7800A3D7F1 /* CAPPlugin.h in Headers */, + 620850322538A3FC003BC41B /* CAPBridgedJSTypes.h in Headers */, 62959B162524DA7800A3D7F1 /* CAPPluginCall.h in Headers */, 62959B3B2524DA7800A3D7F1 /* CAPPluginMethod.h in Headers */, 62959B192524DA7800A3D7F1 /* CAPBridgedPlugin.h in Headers */, @@ -390,6 +400,7 @@ 62959B372524DA7800A3D7F1 /* CAPConfig.swift in Sources */, 62959B432524DA7800A3D7F1 /* Data+Capacitor.swift in Sources */, 62959B382524DA7800A3D7F1 /* CAPPluginCall.m in Sources */, + 620850332538A3FC003BC41B /* CAPBridgedJSTypes.m in Sources */, 62959B1B2524DA7800A3D7F1 /* CAPFile.swift in Sources */, 62959B462524DA7800A3D7F1 /* CAPBridge.swift in Sources */, 62959B1D2524DA7800A3D7F1 /* UIColor.swift in Sources */, @@ -406,6 +417,7 @@ 62959B302524DA7800A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m in Sources */, 62959B392524DA7800A3D7F1 /* CapacitorExtension.swift in Sources */, 62959B3D2524DA7800A3D7F1 /* CAPMessageHandlerWrapper.swift in Sources */, + 620850362538A409003BC41B /* JSTypes.swift in Sources */, 62959B422524DA7800A3D7F1 /* DocLinks.swift in Sources */, 62959B172524DA7800A3D7F1 /* JSExport.swift in Sources */, 62959B2D2524DA7800A3D7F1 /* App.swift in Sources */, diff --git a/ios/Capacitor/Capacitor/Capacitor.modulemap b/ios/Capacitor/Capacitor/Capacitor.modulemap index f63e44af3c..3ecf37e505 100644 --- a/ios/Capacitor/Capacitor/Capacitor.modulemap +++ b/ios/Capacitor/Capacitor/Capacitor.modulemap @@ -1,6 +1,7 @@ framework module Capacitor { umbrella header "Capacitor.h" + exclude header "CAPBridgedJSTypes.h" export * module * { export * } -} +} \ No newline at end of file From f88cbe293466e49e061bffc1a05d9ea6f2a7241f Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Wed, 14 Oct 2020 14:22:28 -0400 Subject: [PATCH 11/40] WIP --- .../Capacitor.xcodeproj/project.pbxproj | 70 ++++--- .../CAPApplicationDelegateProxy.swift | 32 ++++ ios/Capacitor/Capacitor/CAPAssetHandler.swift | 4 +- ios/Capacitor/Capacitor/CAPBridge.swift | 177 ++++++++++-------- .../Capacitor/CAPBridgeDelegate.swift | 4 +- .../Capacitor/CAPBridgeProtocol.swift | 115 ++++++++++++ .../Capacitor/CAPBridgeViewController.swift | 19 +- ios/Capacitor/Capacitor/CAPFile.swift | 2 +- .../Capacitor/CAPMessageHandlerWrapper.swift | 8 +- .../Capacitor/CAPNotifications.swift | 7 +- ios/Capacitor/Capacitor/CAPPlugin.h | 6 +- .../CAPUNUserNotificationCenterDelegate.swift | 7 +- ios/Capacitor/Capacitor/JS.swift | 2 +- ios/Capacitor/Capacitor/Plugins/App.swift | 12 +- .../Capacitor/TmpViewController.swift | 2 +- 15 files changed, 336 insertions(+), 131 deletions(-) create mode 100644 ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift create mode 100644 ios/Capacitor/Capacitor/CAPBridgeProtocol.swift diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj index d6ba653b08..1ae20d4817 100644 --- a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj +++ b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj @@ -10,21 +10,24 @@ 501CBAA71FC0A723009B0D4D /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 501CBAA61FC0A723009B0D4D /* WebKit.framework */; }; 50503EE91FC08595003606DC /* Capacitor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50503EDF1FC08594003606DC /* Capacitor.framework */; }; 50503EEE1FC08595003606DC /* CapacitorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50503EED1FC08595003606DC /* CapacitorTests.swift */; }; - 620850322538A3FC003BC41B /* CAPBridgedJSTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6208502F2538A3FC003BC41B /* CAPBridgedJSTypes.h */; }; - 620850332538A3FC003BC41B /* CAPBridgedJSTypes.m in Sources */ = {isa = PBXBuildFile; fileRef = 620850312538A3FC003BC41B /* CAPBridgedJSTypes.m */; }; - 620850362538A409003BC41B /* JSTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 620850352538A409003BC41B /* JSTypes.swift */; }; + 6209430A2527C87D0072A562 /* CAPBridgeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 620943092527C87D0072A562 /* CAPBridgeProtocol.swift */; }; + 626B289725364A6500FFF7CB /* CAPApplicationDelegateProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 626B289625364A6500FFF7CB /* CAPApplicationDelegateProxy.swift */; }; 62959B162524DA7800A3D7F1 /* CAPPluginCall.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */; settings = {ATTRIBUTES = (Public, ); }; }; 62959B172524DA7800A3D7F1 /* JSExport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE32524DA7700A3D7F1 /* JSExport.swift */; }; + 62959B182524DA7800A3D7F1 /* CAPBridgedJSTypes.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE42524DA7700A3D7F1 /* CAPBridgedJSTypes.m */; }; 62959B192524DA7800A3D7F1 /* CAPBridgedPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; 62959B1A2524DA7800A3D7F1 /* CAPPluginCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */; }; 62959B1B2524DA7800A3D7F1 /* CAPFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE72524DA7700A3D7F1 /* CAPFile.swift */; }; 62959B1C2524DA7800A3D7F1 /* CAPPluginMethod.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */; }; 62959B1D2524DA7800A3D7F1 /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE92524DA7700A3D7F1 /* UIColor.swift */; }; + 62959B1E2524DA7800A3D7F1 /* StatusBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AEB2524DA7700A3D7F1 /* StatusBar.swift */; }; + 62959B1F2524DA7800A3D7F1 /* Keyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AEC2524DA7700A3D7F1 /* Keyboard.m */; }; 62959B222524DA7800A3D7F1 /* Console.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AEF2524DA7700A3D7F1 /* Console.swift */; }; 62959B232524DA7800A3D7F1 /* DefaultPlugins.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */; }; 62959B242524DA7800A3D7F1 /* Geolocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF12524DA7700A3D7F1 /* Geolocation.swift */; }; 62959B252524DA7800A3D7F1 /* PushNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */; }; 62959B262524DA7800A3D7F1 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF32524DA7700A3D7F1 /* WebView.swift */; }; + 62959B272524DA7800A3D7F1 /* Keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AF42524DA7700A3D7F1 /* Keyboard.h */; }; 62959B282524DA7800A3D7F1 /* BackgroundTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */; }; 62959B292524DA7800A3D7F1 /* SplashScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */; }; 62959B2C2524DA7800A3D7F1 /* LocalNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */; }; @@ -34,6 +37,7 @@ 62959B312524DA7800A3D7F1 /* JS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFF2524DA7700A3D7F1 /* JS.swift */; }; 62959B332524DA7800A3D7F1 /* CAPPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959B012524DA7700A3D7F1 /* CAPPlugin.m */; }; 62959B342524DA7800A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B022524DA7700A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift */; }; + 62959B352524DA7800A3D7F1 /* CAPBridgedJSTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B032524DA7700A3D7F1 /* CAPBridgedJSTypes.h */; settings = {ATTRIBUTES = (Public, ); }; }; 62959B362524DA7800A3D7F1 /* CAPBridgeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */; }; 62959B372524DA7800A3D7F1 /* CAPConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B052524DA7700A3D7F1 /* CAPConfig.swift */; }; 62959B382524DA7800A3D7F1 /* CAPPluginCall.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959B062524DA7700A3D7F1 /* CAPPluginCall.m */; }; @@ -42,6 +46,7 @@ 62959B3B2524DA7800A3D7F1 /* CAPPluginMethod.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B092524DA7700A3D7F1 /* CAPPluginMethod.h */; settings = {ATTRIBUTES = (Public, ); }; }; 62959B3C2524DA7800A3D7F1 /* CAPBridgeDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */; }; 62959B3D2524DA7800A3D7F1 /* CAPMessageHandlerWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0B2524DA7700A3D7F1 /* CAPMessageHandlerWrapper.swift */; }; + 62959B3E2524DA7800A3D7F1 /* JSTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0C2524DA7700A3D7F1 /* JSTypes.swift */; }; 62959B3F2524DA7800A3D7F1 /* CAPAssetHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0D2524DA7700A3D7F1 /* CAPAssetHandler.swift */; }; 62959B402524DA7800A3D7F1 /* TmpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B0E2524DA7700A3D7F1 /* TmpViewController.swift */; }; 62959B412524DA7800A3D7F1 /* Capacitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959B0F2524DA7700A3D7F1 /* Capacitor.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -90,21 +95,24 @@ 50503EDF1FC08594003606DC /* Capacitor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Capacitor.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 50503EE81FC08595003606DC /* CapacitorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CapacitorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50503EED1FC08595003606DC /* CapacitorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapacitorTests.swift; sourceTree = ""; }; - 6208502F2538A3FC003BC41B /* CAPBridgedJSTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPBridgedJSTypes.h; sourceTree = ""; }; - 620850312538A3FC003BC41B /* CAPBridgedJSTypes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPBridgedJSTypes.m; sourceTree = ""; }; - 620850352538A409003BC41B /* JSTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSTypes.swift; sourceTree = ""; }; + 620943092527C87D0072A562 /* CAPBridgeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CAPBridgeProtocol.swift; sourceTree = ""; }; + 626B289625364A6500FFF7CB /* CAPApplicationDelegateProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CAPApplicationDelegateProxy.swift; sourceTree = ""; }; 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPPluginCall.h; sourceTree = ""; }; 62959AE32524DA7700A3D7F1 /* JSExport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSExport.swift; sourceTree = ""; }; + 62959AE42524DA7700A3D7F1 /* CAPBridgedJSTypes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPBridgedJSTypes.m; sourceTree = ""; }; 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPBridgedPlugin.h; sourceTree = ""; }; 62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPPluginCall.swift; sourceTree = ""; }; 62959AE72524DA7700A3D7F1 /* CAPFile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPFile.swift; sourceTree = ""; }; 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPPluginMethod.m; sourceTree = ""; }; 62959AE92524DA7700A3D7F1 /* UIColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = ""; }; + 62959AEB2524DA7700A3D7F1 /* StatusBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBar.swift; sourceTree = ""; }; + 62959AEC2524DA7700A3D7F1 /* Keyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Keyboard.m; sourceTree = ""; }; 62959AEF2524DA7700A3D7F1 /* Console.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Console.swift; sourceTree = ""; }; 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultPlugins.h; sourceTree = ""; }; 62959AF12524DA7700A3D7F1 /* Geolocation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Geolocation.swift; sourceTree = ""; }; 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PushNotifications.swift; sourceTree = ""; }; 62959AF32524DA7700A3D7F1 /* WebView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = ""; }; + 62959AF42524DA7700A3D7F1 /* Keyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Keyboard.h; sourceTree = ""; }; 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundTask.swift; sourceTree = ""; }; 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SplashScreen.swift; sourceTree = ""; }; 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalNotifications.swift; sourceTree = ""; }; @@ -114,6 +122,7 @@ 62959AFF2524DA7700A3D7F1 /* JS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JS.swift; sourceTree = ""; }; 62959B012524DA7700A3D7F1 /* CAPPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPPlugin.m; sourceTree = ""; }; 62959B022524DA7700A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPUNUserNotificationCenterDelegate.swift; sourceTree = ""; }; + 62959B032524DA7700A3D7F1 /* CAPBridgedJSTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPBridgedJSTypes.h; sourceTree = ""; }; 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPBridgeViewController.swift; sourceTree = ""; }; 62959B052524DA7700A3D7F1 /* CAPConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPConfig.swift; sourceTree = ""; }; 62959B062524DA7700A3D7F1 /* CAPPluginCall.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPPluginCall.m; sourceTree = ""; }; @@ -122,6 +131,7 @@ 62959B092524DA7700A3D7F1 /* CAPPluginMethod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPPluginMethod.h; sourceTree = ""; }; 62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPBridgeDelegate.swift; sourceTree = ""; }; 62959B0B2524DA7700A3D7F1 /* CAPMessageHandlerWrapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPMessageHandlerWrapper.swift; sourceTree = ""; }; + 62959B0C2524DA7700A3D7F1 /* JSTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSTypes.swift; sourceTree = ""; }; 62959B0D2524DA7700A3D7F1 /* CAPAssetHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPAssetHandler.swift; sourceTree = ""; }; 62959B0E2524DA7700A3D7F1 /* TmpViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TmpViewController.swift; sourceTree = ""; }; 62959B0F2524DA7700A3D7F1 /* Capacitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Capacitor.h; sourceTree = ""; }; @@ -202,35 +212,37 @@ 62959B0F2524DA7700A3D7F1 /* Capacitor.h */, 62959B132524DA7700A3D7F1 /* CAPPlugin.h */, 62959B012524DA7700A3D7F1 /* CAPPlugin.m */, - 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */, 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */, 62959B062524DA7700A3D7F1 /* CAPPluginCall.m */, - 62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */, + 620943092527C87D0072A562 /* CAPBridgeProtocol.swift */, + 62959B142524DA7700A3D7F1 /* CAPBridge.swift */, + 626B289625364A6500FFF7CB /* CAPApplicationDelegateProxy.swift */, + 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */, 62959B092524DA7700A3D7F1 /* CAPPluginMethod.h */, - 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */, - 6208502F2538A3FC003BC41B /* CAPBridgedJSTypes.h */, - 620850312538A3FC003BC41B /* CAPBridgedJSTypes.m */, 62959AE32524DA7700A3D7F1 /* JSExport.swift */, - 620850352538A409003BC41B /* JSTypes.swift */, - 62959AEA2524DA7700A3D7F1 /* Plugins */, - 62959B142524DA7700A3D7F1 /* CAPBridge.swift */, - 62959B052524DA7700A3D7F1 /* CAPConfig.swift */, - 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */, - 62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */, + 62959B032524DA7700A3D7F1 /* CAPBridgedJSTypes.h */, + 62959AE42524DA7700A3D7F1 /* CAPBridgedJSTypes.m */, + 62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */, 62959AE72524DA7700A3D7F1 /* CAPFile.swift */, + 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */, + 62959AE92524DA7700A3D7F1 /* UIColor.swift */, + 62959AEA2524DA7700A3D7F1 /* Plugins */, + 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */, 62959AFF2524DA7700A3D7F1 /* JS.swift */, 62959B022524DA7700A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift */, + 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */, + 62959B052524DA7700A3D7F1 /* CAPConfig.swift */, + 62959B072524DA7700A3D7F1 /* CapacitorExtension.swift */, 62959B082524DA7700A3D7F1 /* CAPLog.swift */, + 62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */, 62959B0B2524DA7700A3D7F1 /* CAPMessageHandlerWrapper.swift */, + 62959B0C2524DA7700A3D7F1 /* JSTypes.swift */, 62959B0D2524DA7700A3D7F1 /* CAPAssetHandler.swift */, 62959B0E2524DA7700A3D7F1 /* TmpViewController.swift */, 62959B102524DA7700A3D7F1 /* DocLinks.swift */, - 62959B152524DA7700A3D7F1 /* CAPNotifications.swift */, - 62959B072524DA7700A3D7F1 /* CapacitorExtension.swift */, - 62959AE92524DA7700A3D7F1 /* UIColor.swift */, 62959B112524DA7700A3D7F1 /* Data+Capacitor.swift */, - 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */, 62959B122524DA7700A3D7F1 /* Info.plist */, + 62959B152524DA7700A3D7F1 /* CAPNotifications.swift */, 62959B8225253A9500A3D7F1 /* Capacitor.modulemap */, ); path = Capacitor; @@ -245,9 +257,12 @@ 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */, 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */, 62959AF12524DA7700A3D7F1 /* Geolocation.swift */, + 62959AF42524DA7700A3D7F1 /* Keyboard.h */, + 62959AEC2524DA7700A3D7F1 /* Keyboard.m */, 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */, 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */, 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */, + 62959AEB2524DA7700A3D7F1 /* StatusBar.swift */, 62959AF32524DA7700A3D7F1 /* WebView.swift */, ); path = Plugins; @@ -270,10 +285,11 @@ files = ( 62959B412524DA7800A3D7F1 /* Capacitor.h in Headers */, 62959B452524DA7800A3D7F1 /* CAPPlugin.h in Headers */, - 620850322538A3FC003BC41B /* CAPBridgedJSTypes.h in Headers */, 62959B162524DA7800A3D7F1 /* CAPPluginCall.h in Headers */, 62959B3B2524DA7800A3D7F1 /* CAPPluginMethod.h in Headers */, 62959B192524DA7800A3D7F1 /* CAPBridgedPlugin.h in Headers */, + 62959B352524DA7800A3D7F1 /* CAPBridgedJSTypes.h in Headers */, + 62959B272524DA7800A3D7F1 /* Keyboard.h in Headers */, 62959B232524DA7800A3D7F1 /* DefaultPlugins.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -399,10 +415,13 @@ 62959B402524DA7800A3D7F1 /* TmpViewController.swift in Sources */, 62959B372524DA7800A3D7F1 /* CAPConfig.swift in Sources */, 62959B432524DA7800A3D7F1 /* Data+Capacitor.swift in Sources */, + 62959B1E2524DA7800A3D7F1 /* StatusBar.swift in Sources */, + 62959B3E2524DA7800A3D7F1 /* JSTypes.swift in Sources */, 62959B382524DA7800A3D7F1 /* CAPPluginCall.m in Sources */, - 620850332538A3FC003BC41B /* CAPBridgedJSTypes.m in Sources */, 62959B1B2524DA7800A3D7F1 /* CAPFile.swift in Sources */, + 6209430A2527C87D0072A562 /* CAPBridgeProtocol.swift in Sources */, 62959B462524DA7800A3D7F1 /* CAPBridge.swift in Sources */, + 626B289725364A6500FFF7CB /* CAPApplicationDelegateProxy.swift in Sources */, 62959B1D2524DA7800A3D7F1 /* UIColor.swift in Sources */, 62959B282524DA7800A3D7F1 /* BackgroundTask.swift in Sources */, 62959B332524DA7800A3D7F1 /* CAPPlugin.m in Sources */, @@ -417,16 +436,17 @@ 62959B302524DA7800A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m in Sources */, 62959B392524DA7800A3D7F1 /* CapacitorExtension.swift in Sources */, 62959B3D2524DA7800A3D7F1 /* CAPMessageHandlerWrapper.swift in Sources */, - 620850362538A409003BC41B /* JSTypes.swift in Sources */, 62959B422524DA7800A3D7F1 /* DocLinks.swift in Sources */, 62959B172524DA7800A3D7F1 /* JSExport.swift in Sources */, 62959B2D2524DA7800A3D7F1 /* App.swift in Sources */, 62959B3F2524DA7800A3D7F1 /* CAPAssetHandler.swift in Sources */, + 62959B1F2524DA7800A3D7F1 /* Keyboard.m in Sources */, 62959B3C2524DA7800A3D7F1 /* CAPBridgeDelegate.swift in Sources */, 62959B2C2524DA7800A3D7F1 /* LocalNotifications.swift in Sources */, 62959B2F2524DA7800A3D7F1 /* DefaultPlugins.m in Sources */, 62959B222524DA7800A3D7F1 /* Console.swift in Sources */, 62959B3A2524DA7800A3D7F1 /* CAPLog.swift in Sources */, + 62959B182524DA7800A3D7F1 /* CAPBridgedJSTypes.m in Sources */, 62959B262524DA7800A3D7F1 /* WebView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -586,6 +606,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.Capacitor; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -614,6 +635,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.Capacitor; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift b/ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift new file mode 100644 index 0000000000..9b4368682a --- /dev/null +++ b/ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift @@ -0,0 +1,32 @@ + +import Foundation + +@objc public class CAPApplicationDelegateProxy: NSObject, UIApplicationDelegate { + static let shared = CAPApplicationDelegateProxy() + + private(set) var lastURL: URL? + + public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { + NotificationCenter.default.post(name: Notification.Name(CAPNotifications.URLOpen.name()), object: [ + "url": url, + "options": options + ]) + NotificationCenter.default.post(name: NSNotification.Name.CDVPluginHandleOpenURL, object: url) + lastURL = url + return true + } + + public func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { + // TODO: Support other types, emit to rest of plugins + if userActivity.activityType != NSUserActivityTypeBrowsingWeb || userActivity.webpageURL == nil { + return false + } + + let url = userActivity.webpageURL + lastURL = url + NotificationCenter.default.post(name: Notification.Name(CAPNotifications.UniversalLinkOpen.name()), object: [ + "url": url + ]) + return true + } +} diff --git a/ios/Capacitor/Capacitor/CAPAssetHandler.swift b/ios/Capacitor/Capacitor/CAPAssetHandler.swift index 7115cf65c4..b9a5b71a39 100644 --- a/ios/Capacitor/Capacitor/CAPAssetHandler.swift +++ b/ios/Capacitor/Capacitor/CAPAssetHandler.swift @@ -14,8 +14,8 @@ class CAPAssetHandler: NSObject, WKURLSchemeHandler { let url = urlSchemeTask.request.url! let stringToLoad = url.path - if stringToLoad.starts(with: CAPBridge.fileStartIdentifier) { - startPath = stringToLoad.replacingOccurrences(of: CAPBridge.fileStartIdentifier, with: "") + if stringToLoad.starts(with: CapacitorBridge.fileStartIdentifier) { + startPath = stringToLoad.replacingOccurrences(of: CapacitorBridge.fileStartIdentifier, with: "") } else if stringToLoad.isEmpty || url.pathExtension.isEmpty { startPath.append("/index.html") } else { diff --git a/ios/Capacitor/Capacitor/CAPBridge.swift b/ios/Capacitor/Capacitor/CAPBridge.swift index 92487d5ac3..7246db0677 100644 --- a/ios/Capacitor/Capacitor/CAPBridge.swift +++ b/ios/Capacitor/Capacitor/CAPBridge.swift @@ -7,8 +7,68 @@ enum BridgeError: Error { case errorExportingCoreJS } -@objc public class CAPBridge: NSObject { - +internal class CapacitorBridge: NSObject, CAPBridgeProtocol { + + // MARK: - CAPBridgeProtocol Properties + + public var webView: WKWebView? { + return bridgeDelegate?.bridgedWebView + } + + public var isSimEnvironment: Bool { + #if targetEnvironment(simulator) + return true + #else + return false + #endif + } + + public var isDevEnvironment: Bool { + #if DEBUG + return true + #else + return false + #endif + } + + @available(iOS 12.0, *) + public var userInterfaceStyle: UIUserInterfaceStyle { + return viewController?.traitCollection.userInterfaceStyle ?? .unspecified + } + + public var statusBarVisible: Bool { + get { + return !(viewController?.prefersStatusBarHidden ?? true) + } + set { + DispatchQueue.main.async { [weak self] in + (self?.viewController as? CAPBridgeViewController)?.setStatusBarVisible(newValue) + } + } + } + + public var statusBarStyle: UIStatusBarStyle { + get { + return viewController?.preferredStatusBarStyle ?? .default + } + set { + DispatchQueue.main.async { [weak self] in + (self?.viewController as? CAPBridgeViewController)?.setStatusBarStyle(newValue) + } + } + } + + public var statusBarAnimation: UIStatusBarAnimation { + get { + return (viewController as? CAPBridgeViewController)?.statusBarAnimation ?? .slide + } + set { + DispatchQueue.main.async { [weak self] in + (self?.viewController as? CAPBridgeViewController)?.setStatusBarAnimation(newValue) + } + } + } + var tmpWindow: UIWindow? @objc public static let statusBarTappedNotification = Notification(name: Notification.Name(rawValue: "statusBarTappedNotification")) @objc public static let tmpVCAppeared = Notification(name: Notification.Name(rawValue: "tmpViewControllerAppeared")) @@ -17,7 +77,7 @@ enum BridgeError: Error { public static let defaultScheme = "capacitor" // The last URL that caused the app to open - private static var lastUrl: URL? + public var lastUrl: URL? public var messageHandlerWrapper: CAPMessageHandlerWrapper public weak var bridgeDelegate: CAPBridgeDelegate? @@ -66,7 +126,7 @@ enum BridgeError: Error { registerPlugins() setupCordovaCompatibility() bindObservers() - NotificationCenter.default.addObserver(forName: CAPBridge.tmpVCAppeared.name, object: .none, queue: .none) { [weak self] _ in + NotificationCenter.default.addObserver(forName: type(of: self).tmpVCAppeared.name, object: .none, queue: .none) { [weak self] _ in self?.tmpWindow = nil } } @@ -75,60 +135,51 @@ enum BridgeError: Error { // the message handler needs to removed to avoid any retain cycles messageHandlerWrapper.cleanUp() } - - public func setStatusBarVisible(_ isStatusBarVisible: Bool) { - guard let bridgeVC = self.viewController as? CAPBridgeViewController else { - return - } - DispatchQueue.main.async { - bridgeVC.setStatusBarVisible(isStatusBarVisible) - } + + // MARK: - Deprecated + + public func getWebView() -> WKWebView? { + return webView } - - public func setStatusBarStyle(_ statusBarStyle: UIStatusBarStyle) { - guard let bridgeVC = self.viewController as? CAPBridgeViewController else { - return - } - DispatchQueue.main.async { - bridgeVC.setStatusBarStyle(statusBarStyle) - } + + public func isSimulator() -> Bool { + return isSimEnvironment } - - public func setStatusBarAnimation(_ statusBarAnimation: UIStatusBarAnimation) { - guard let bridgeVC = self.viewController as? CAPBridgeViewController else { - return - } - DispatchQueue.main.async { - bridgeVC.setStatusBarAnimation(statusBarAnimation) - } + + public func isDevMode() -> Bool { + return isDevEnvironment } - + public func getStatusBarVisible() -> Bool { - guard let bridgeVC = self.viewController as? CAPBridgeViewController else { - return false - } - return !bridgeVC.prefersStatusBarHidden + return statusBarVisible } - + + @nonobjc public func setStatusBarVisible(_ visible:Bool) { + statusBarVisible = visible + } + public func getStatusBarStyle() -> UIStatusBarStyle { - guard let bridgeVC = self.viewController as? CAPBridgeViewController else { - return UIStatusBarStyle.default - } - return bridgeVC.preferredStatusBarStyle + return statusBarStyle } - + @nonobjc public func setStatusBarStyle(_ style:UIStatusBarStyle) { + statusBarStyle = style + } + @available(iOS 12.0, *) public func getUserInterfaceStyle() -> UIUserInterfaceStyle { - guard let bridgeVC = self.viewController as? CAPBridgeViewController else { - return UIUserInterfaceStyle.unspecified - } - return bridgeVC.traitCollection.userInterfaceStyle + return userInterfaceStyle } - + + @nonobjc public func setStatusBarAnimation(_ animation:UIStatusBarAnimation) { + statusBarAnimation = animation + } + + + /** * Get the last URL that triggered an open or continue activity event. */ - public static func getLastUrl() -> URL? { + public func getLastUrl() -> URL? { return lastUrl } @@ -141,7 +192,7 @@ enum BridgeError: Error { "options": options ]) NotificationCenter.default.post(name: NSNotification.Name.CDVPluginHandleOpenURL, object: url) - CAPBridge.lastUrl = url + //CAPBridge.lastUrl = url return true } @@ -155,7 +206,7 @@ enum BridgeError: Error { } let url = userActivity.webpageURL - CAPBridge.lastUrl = url + //CAPBridge.lastUrl = url NotificationCenter.default.post(name: Notification.Name(CAPNotifications.UniversalLinkOpen.name()), object: [ "url": url ]) @@ -224,7 +275,7 @@ enum BridgeError: Error { try JSExport.exportCapacitorGlobalJS(userContentController: self.messageHandlerWrapper.contentController, isDebug: isDevMode(), localUrl: localUrl) try JSExport.exportCapacitorJS(userContentController: self.messageHandlerWrapper.contentController) } catch { - CAPBridge.fatalError(error, error) + type(of: self).fatalError(error, error) } } @@ -246,7 +297,7 @@ enum BridgeError: Error { do { try JSExport.exportCordovaJS(userContentController: self.messageHandlerWrapper.contentController) } catch { - CAPBridge.fatalError(error, error) + type(of: self).fatalError(error, error) } } @@ -352,26 +403,10 @@ enum BridgeError: Error { do { try JSExport.exportCordovaPluginsJS(userContentController: self.messageHandlerWrapper.contentController) } catch { - CAPBridge.fatalError(error, error) + type(of: self).fatalError(error, error) } } - public func isSimulator() -> Bool { - var isSimulator = false - #if arch(i386) || arch(x86_64) - isSimulator = true - #endif - return isSimulator - } - - public func isDevMode() -> Bool { - #if DEBUG - return true - #else - return false - #endif - } - public func reload() { self.getWebView()?.reload() } @@ -380,15 +415,15 @@ enum BridgeError: Error { let output = items.map { "\($0)" }.joined(separator: " ") CAPLog.print("⚡️ ", plugin.pluginId, "-", output) } - - public func alert(_ title: String, _ message: String, _ buttonTitle: String = "OK") { + + public func showAlertWith(title: String, message: String, buttonTitle: String) { let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert) alert.addAction(UIAlertAction(title: buttonTitle, style: UIAlertAction.Style.default, handler: nil)) self.viewController?.present(alert, animated: true, completion: nil) } func docLink(_ url: String) -> String { - return "\(CAPBridge.capacitorSite)docs/\(url)" + return "\(type(of: self).capacitorSite)docs/\(url)" } /** @@ -589,10 +624,6 @@ enum BridgeError: Error { } } - @objc public func getWebView() -> WKWebView? { - return self.bridgeDelegate?.bridgedWebView - } - public func getLocalUrl() -> String { return localUrl! } diff --git a/ios/Capacitor/Capacitor/CAPBridgeDelegate.swift b/ios/Capacitor/Capacitor/CAPBridgeDelegate.swift index ebe1b8c805..5fe52bd687 100644 --- a/ios/Capacitor/Capacitor/CAPBridgeDelegate.swift +++ b/ios/Capacitor/Capacitor/CAPBridgeDelegate.swift @@ -1,12 +1,12 @@ import Foundation -public protocol CAPBridgeDelegate: class { +internal protocol CAPBridgeDelegate: class { var bridgedWebView: WKWebView? { get } var bridgedViewController: UIViewController? { get } } extension CAPBridgeDelegate { - public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage, bridge: CAPBridge) { + func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage, bridge: CapacitorBridge) { let body = message.body if let dict = body as? [String: Any] { let type = dict["type"] as? String ?? "" diff --git a/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift b/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift new file mode 100644 index 0000000000..ce7f079eb4 --- /dev/null +++ b/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift @@ -0,0 +1,115 @@ +import Foundation +import WebKit + +public enum CAPBridgeError: Error { + case errorExportingCoreJS +} + +@objc public protocol CAPBridgeProtocol: NSObjectProtocol { + // MARK: Environment Properties + var viewController: UIViewController? { get } + var config: CAPConfig { get } + var webView: WKWebView? { get } + var lastUrl: URL? { get } + var isSimEnvironment: Bool { get } + var isDevEnvironment: Bool { get } + @available(iOS 12.0, *) + var userInterfaceStyle: UIUserInterfaceStyle { get } + var notificationDelegationHandler: CAPUNUserNotificationCenterDelegate { get } + var statusBarVisible: Bool { get set } + var statusBarStyle: UIStatusBarStyle { get set } + var statusBarAnimation: UIStatusBarAnimation { get set } + + // MARK: - Deprecated + @available(*, deprecated, renamed: "webView") + func getWebView() -> WKWebView? + + @available(*, deprecated, renamed: "isSimEnvironment") + func isSimulator() -> Bool + + @available(*, deprecated, renamed: "isDevEnvironment") + func isDevMode() -> Bool + + @available(*, deprecated, renamed: "statusBarVisible") + func getStatusBarVisible() -> Bool + + @available(*, deprecated, renamed: "statusBarStyle") + func getStatusBarStyle() -> UIStatusBarStyle + + @available(iOS 12.0, *) + @available(*, deprecated, renamed: "userInterfaceStyle") + func getUserInterfaceStyle() -> UIUserInterfaceStyle + + // MARK: Call Management + func getSavedCall(_ callbackId: String) -> CAPPluginCall? + func releaseCall(_ call: CAPPluginCall) + func releaseCall(callbackId: String) + + // MARK: JavaScript Handling + func evalWithPlugin(_ plugin: CAPPlugin, js: String) + func eval(js: String) + + func triggerJSEvent(eventName: String, target: String) + func triggerJSEvent(eventName: String, target: String, data: String) + + func triggerWindowJSEvent(eventName: String) + func triggerWindowJSEvent(eventName: String, data: String) + + func triggerDocumentJSEvent(eventName: String) + func triggerDocumentJSEvent(eventName: String, data: String) + + // MARK: View Presentation + func showAlertWith(title: String, message: String, buttonTitle: String) + func presentVC(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?) + func dismissVC(animated flag: Bool, completion: (() -> Void)?) +} + +/* + Extensions to Obj-C protocols are not exposed to Obj-C code because of limitations in the runtime. Therefore these methods + are implicitly Swift-only. + + The ones marked as deprecated are here because they can be declared without interfering with the synthesized Obj-C setters + for the respective properties (e.g. `setStatusBarVisible:` for 'statusBarVisible`). + */ +extension CAPBridgeProtocol { + func modulePrint(_ plugin: CAPPlugin, _ items: Any...) { + } + + func alert(_ title: String, _ message: String, _ buttonTitle: String = "OK") { + showAlertWith(title: title, message: message, buttonTitle: buttonTitle) + } + + @available(*, deprecated, renamed: "statusBarVisible") + public func setStatusBarVisible(_ visible:Bool) { + statusBarVisible = visible + } + + @available(*, deprecated, renamed: "statusBarStyle") + public func setStatusBarStyle(_ style:UIStatusBarStyle) { + statusBarStyle = style + } + + @available(*, deprecated, renamed: "statusBarAnimation") + public func setStatusBarAnimation(_ animation:UIStatusBarAnimation) { + statusBarAnimation = animation + } +} + +extension CAPBridgeError: CustomNSError { + static public var errorDomain: String { "CapacitorBridge" } + public var errorCode: Int { + switch self { + case .errorExportingCoreJS: + return 0 + } + } + public var errorUserInfo: [String: Any] { + return ["info": String(describing: self)] + } +} + +extension CAPBridgeError: LocalizedError { + public var errorDescription: String? { + return NSLocalizedString("Unable to export JavaScript bridge code to webview", comment: "Capacitor bridge initialization error") + } +} diff --git a/ios/Capacitor/Capacitor/CAPBridgeViewController.swift b/ios/Capacitor/Capacitor/CAPBridgeViewController.swift index bfef032c84..15205bc017 100644 --- a/ios/Capacitor/Capacitor/CAPBridgeViewController.swift +++ b/ios/Capacitor/Capacitor/CAPBridgeViewController.swift @@ -33,14 +33,17 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKUID private var isStatusBarVisible = true private var statusBarStyle: UIStatusBarStyle = .default - private var statusBarAnimation: UIStatusBarAnimation = .slide + private(set) var statusBarAnimation: UIStatusBarAnimation = .slide @objc public var supportedOrientations: [Int] = [] @objc public var startDir = "" @objc public var config: String? // Construct the Capacitor runtime - public var bridge: CAPBridge? + private var capacitorBridge: CapacitorBridge? + var bridge: CAPBridgeProtocol? { + return capacitorBridge + } private var handler: CAPAssetHandler? override public func loadView() { @@ -61,8 +64,8 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKUID let messageHandler = CAPMessageHandlerWrapper() self.handler = CAPAssetHandler() self.handler!.setAssetPath(startPath) - var specifiedScheme = CAPBridge.defaultScheme - let configScheme = capConfig.getString("server.iosScheme") ?? CAPBridge.defaultScheme + var specifiedScheme = CapacitorBridge.defaultScheme + let configScheme = capConfig.getString("server.iosScheme") ?? CapacitorBridge.defaultScheme // check if WebKit handles scheme and if it is valid according to Apple's documentation if !WKWebView.handlesURLScheme(configScheme) && configScheme.range(of: "^[a-z][a-z0-9.+-]*$", options: [.regularExpression, .caseInsensitive], range: nil, locale: nil) != nil { specifiedScheme = configScheme.lowercased() @@ -96,7 +99,7 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKUID setKeyboardRequiresUserInteraction(false) - bridge = CAPBridge(self, messageHandler, capConfig, specifiedScheme) + capacitorBridge = CapacitorBridge(self, messageHandler, capConfig, specifiedScheme) if let scrollEnabled = bridge!.config.getValue("ios.scrollEnabled") as? Bool { webView?.scrollView.isScrollEnabled = scrollEnabled @@ -201,7 +204,7 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKUID fatalLoadError() } - hostname = bridge!.config.getString("server.url") ?? "\(bridge!.getLocalUrl())" + hostname = capacitorBridge!.config.getString("server.url") ?? "\(capacitorBridge!.getLocalUrl())" allowNavigationConfig = bridge!.config.getValue("server.allowNavigation") as? [String] CAPLog.print("⚡️ Loading app at \(hostname!)...") @@ -268,7 +271,7 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKUID public func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) { // Reset the bridge on each navigation - bridge!.reset() + capacitorBridge!.reset() } public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { @@ -278,7 +281,7 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKUID /* * Give plugins the chance to handle the url */ - if let plugins = bridge?.plugins { + if let plugins = capacitorBridge?.plugins { for pluginObject in plugins { let plugin = pluginObject.value let selector = NSSelectorFromString("shouldOverrideLoad:") diff --git a/ios/Capacitor/Capacitor/CAPFile.swift b/ios/Capacitor/Capacitor/CAPFile.swift index 466c8c5a71..c753ff67a5 100644 --- a/ios/Capacitor/Capacitor/CAPFile.swift +++ b/ios/Capacitor/Capacitor/CAPFile.swift @@ -30,7 +30,7 @@ public class CAPFile { public static func getPortablePath(host: String, uri: URL?) -> String? { if let uri = uri { let uriWithoutFile = uri.absoluteString.replacingOccurrences(of: "file://", with: "") - return host + CAPBridge.fileStartIdentifier + uriWithoutFile + return host + CapacitorBridge.fileStartIdentifier + uriWithoutFile } return nil } diff --git a/ios/Capacitor/Capacitor/CAPMessageHandlerWrapper.swift b/ios/Capacitor/Capacitor/CAPMessageHandlerWrapper.swift index 01774772de..91a0ce7b1f 100644 --- a/ios/Capacitor/Capacitor/CAPMessageHandlerWrapper.swift +++ b/ios/Capacitor/Capacitor/CAPMessageHandlerWrapper.swift @@ -5,12 +5,12 @@ import Foundation import WebKit -public class CAPMessageHandlerWrapper: NSObject, WKScriptMessageHandler { - weak var bridge: CAPBridge? +internal class CAPMessageHandlerWrapper: NSObject, WKScriptMessageHandler { + weak var bridge: CapacitorBridge? fileprivate(set) var contentController = WKUserContentController() let handlerName = "bridge" - public init(bridge: CAPBridge? = nil) { + init(bridge: CapacitorBridge? = nil) { super.init() self.bridge = bridge contentController.add(self, name: handlerName) @@ -20,7 +20,7 @@ public class CAPMessageHandlerWrapper: NSObject, WKScriptMessageHandler { contentController.removeScriptMessageHandler(forName: handlerName) } - public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { + func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { guard let bridge = bridge else { return } diff --git a/ios/Capacitor/Capacitor/CAPNotifications.swift b/ios/Capacitor/Capacitor/CAPNotifications.swift index 9888193210..413c177882 100644 --- a/ios/Capacitor/Capacitor/CAPNotifications.swift +++ b/ios/Capacitor/Capacitor/CAPNotifications.swift @@ -10,7 +10,8 @@ case DidFailToRegisterForRemoteNotificationsWithError case DecidePolicyForNavigationAction // swiftlint:enable identifier_name - + + @available(*, deprecated, message: "Notifications have been moved") public func name() -> String { switch self { case .URLOpen: @@ -28,3 +29,7 @@ } } } + + +// @objc public static let statusBarTappedNotification = Notification(name: Notification.Name(rawValue: "statusBarTappedNotification")) + diff --git a/ios/Capacitor/Capacitor/CAPPlugin.h b/ios/Capacitor/Capacitor/CAPPlugin.h index dd8b10d651..e66eace880 100644 --- a/ios/Capacitor/Capacitor/CAPPlugin.h +++ b/ios/Capacitor/Capacitor/CAPPlugin.h @@ -1,20 +1,20 @@ #import #import -@class CAPBridge; +@protocol CAPBridgeProtocol; @class CAPPluginCall; @class CAPConfig; @interface CAPPlugin : NSObject @property (nonatomic, weak, nullable) WKWebView *webView; -@property (nonatomic, weak, nullable) CAPBridge *bridge; +@property (nonatomic, weak, nullable) id bridge; @property (nonatomic, strong, nonnull) NSString *pluginId; @property (nonatomic, strong, nonnull) NSString *pluginName; @property (nonatomic, strong, nullable) NSMutableDictionary*> *eventListeners; @property (nonatomic, strong, nullable) NSMutableDictionary *retainedEventArguments; -- (instancetype _Nonnull) initWithBridge:(CAPBridge* _Nonnull) bridge pluginId:(NSString* _Nonnull) pluginId pluginName:(NSString* _Nonnull) pluginName; +- (instancetype _Nonnull) initWithBridge:(id _Nonnull) bridge pluginId:(NSString* _Nonnull) pluginId pluginName:(NSString* _Nonnull) pluginName; - (void)addEventListener:(NSString* _Nonnull)eventName listener:(CAPPluginCall* _Nonnull)listener; - (void)removeEventListener:(NSString* _Nonnull)eventName listener:(CAPPluginCall* _Nonnull)listener; - (void)notifyListeners:(NSString* _Nonnull)eventName data:(NSDictionary* _Nullable)data; diff --git a/ios/Capacitor/Capacitor/CAPUNUserNotificationCenterDelegate.swift b/ios/Capacitor/Capacitor/CAPUNUserNotificationCenterDelegate.swift index 7a86509fa4..7c2b228d48 100644 --- a/ios/Capacitor/Capacitor/CAPUNUserNotificationCenterDelegate.swift +++ b/ios/Capacitor/Capacitor/CAPUNUserNotificationCenterDelegate.swift @@ -2,7 +2,7 @@ import UserNotifications public class CAPUNUserNotificationCenterDelegate: NSObject, UNUserNotificationCenterDelegate { - public weak var bridge: CAPBridge? + internal weak var bridge: CapacitorBridge? // Local list of notification id -> JSObject for storing options // between notification requets var notificationRequestLookup = [String: JSObject]() @@ -14,10 +14,7 @@ public class CAPUNUserNotificationCenterDelegate: NSObject, UNUserNotificationCe center.delegate = self } } - - public func setBridge(bridge: CAPBridge) { - self.bridge = bridge - } + /** * Request permissions to send notifications */ diff --git a/ios/Capacitor/Capacitor/JS.swift b/ios/Capacitor/Capacitor/JS.swift index 0f33b95c86..f912cba691 100644 --- a/ios/Capacitor/Capacitor/JS.swift +++ b/ios/Capacitor/Capacitor/JS.swift @@ -99,7 +99,7 @@ public class JSResultError { return nil } - return "\(CAPBridge.capacitorSite)error/ios?m=\(data)" + return "\(CapacitorBridge.capacitorSite)error/ios?m=\(data)" } public func toJson() -> String { diff --git a/ios/Capacitor/Capacitor/Plugins/App.swift b/ios/Capacitor/Capacitor/Plugins/App.swift index 86cbaa7565..930f02b4f2 100644 --- a/ios/Capacitor/Capacitor/Plugins/App.swift +++ b/ios/Capacitor/Capacitor/Plugins/App.swift @@ -55,12 +55,12 @@ public class CAPAppPlugin: CAPPlugin { } @objc func getLaunchUrl(_ call: CAPPluginCall) { - if let lastUrl = CAPBridge.getLastUrl() { - let urlValue = lastUrl.absoluteString - call.resolve([ - "url": urlValue - ]) - } +// if let lastUrl = CAPBridge.getLastUrl() { +// let urlValue = lastUrl.absoluteString +// call.resolve([ +// "url": urlValue +// ]) +// } call.resolve() } diff --git a/ios/Capacitor/Capacitor/TmpViewController.swift b/ios/Capacitor/Capacitor/TmpViewController.swift index eb28df374b..664cf1ade4 100644 --- a/ios/Capacitor/Capacitor/TmpViewController.swift +++ b/ios/Capacitor/Capacitor/TmpViewController.swift @@ -14,7 +14,7 @@ class TmpViewController: UIViewController { count += 1 } if count > 1 { - NotificationCenter.default.post(CAPBridge.tmpVCAppeared) + NotificationCenter.default.post(CapacitorBridge.tmpVCAppeared) } } } From 9ea44b6978a8af312a04b2622d6e98cf2e53231c Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Wed, 14 Oct 2020 17:46:28 -0400 Subject: [PATCH 12/40] Cleanup from merge. --- ios/Capacitor/Capacitor.xcodeproj/project.pbxproj | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj index 1ae20d4817..e2bc9575bf 100644 --- a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj +++ b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj @@ -20,14 +20,11 @@ 62959B1B2524DA7800A3D7F1 /* CAPFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE72524DA7700A3D7F1 /* CAPFile.swift */; }; 62959B1C2524DA7800A3D7F1 /* CAPPluginMethod.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */; }; 62959B1D2524DA7800A3D7F1 /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE92524DA7700A3D7F1 /* UIColor.swift */; }; - 62959B1E2524DA7800A3D7F1 /* StatusBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AEB2524DA7700A3D7F1 /* StatusBar.swift */; }; - 62959B1F2524DA7800A3D7F1 /* Keyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AEC2524DA7700A3D7F1 /* Keyboard.m */; }; 62959B222524DA7800A3D7F1 /* Console.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AEF2524DA7700A3D7F1 /* Console.swift */; }; 62959B232524DA7800A3D7F1 /* DefaultPlugins.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */; }; 62959B242524DA7800A3D7F1 /* Geolocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF12524DA7700A3D7F1 /* Geolocation.swift */; }; 62959B252524DA7800A3D7F1 /* PushNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */; }; 62959B262524DA7800A3D7F1 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF32524DA7700A3D7F1 /* WebView.swift */; }; - 62959B272524DA7800A3D7F1 /* Keyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AF42524DA7700A3D7F1 /* Keyboard.h */; }; 62959B282524DA7800A3D7F1 /* BackgroundTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */; }; 62959B292524DA7800A3D7F1 /* SplashScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */; }; 62959B2C2524DA7800A3D7F1 /* LocalNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */; }; @@ -105,14 +102,11 @@ 62959AE72524DA7700A3D7F1 /* CAPFile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPFile.swift; sourceTree = ""; }; 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPPluginMethod.m; sourceTree = ""; }; 62959AE92524DA7700A3D7F1 /* UIColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = ""; }; - 62959AEB2524DA7700A3D7F1 /* StatusBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBar.swift; sourceTree = ""; }; - 62959AEC2524DA7700A3D7F1 /* Keyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Keyboard.m; sourceTree = ""; }; 62959AEF2524DA7700A3D7F1 /* Console.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Console.swift; sourceTree = ""; }; 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultPlugins.h; sourceTree = ""; }; 62959AF12524DA7700A3D7F1 /* Geolocation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Geolocation.swift; sourceTree = ""; }; 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PushNotifications.swift; sourceTree = ""; }; 62959AF32524DA7700A3D7F1 /* WebView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = ""; }; - 62959AF42524DA7700A3D7F1 /* Keyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Keyboard.h; sourceTree = ""; }; 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundTask.swift; sourceTree = ""; }; 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SplashScreen.swift; sourceTree = ""; }; 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalNotifications.swift; sourceTree = ""; }; @@ -257,12 +251,9 @@ 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */, 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */, 62959AF12524DA7700A3D7F1 /* Geolocation.swift */, - 62959AF42524DA7700A3D7F1 /* Keyboard.h */, - 62959AEC2524DA7700A3D7F1 /* Keyboard.m */, 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */, 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */, 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */, - 62959AEB2524DA7700A3D7F1 /* StatusBar.swift */, 62959AF32524DA7700A3D7F1 /* WebView.swift */, ); path = Plugins; @@ -289,7 +280,6 @@ 62959B3B2524DA7800A3D7F1 /* CAPPluginMethod.h in Headers */, 62959B192524DA7800A3D7F1 /* CAPBridgedPlugin.h in Headers */, 62959B352524DA7800A3D7F1 /* CAPBridgedJSTypes.h in Headers */, - 62959B272524DA7800A3D7F1 /* Keyboard.h in Headers */, 62959B232524DA7800A3D7F1 /* DefaultPlugins.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -415,7 +405,6 @@ 62959B402524DA7800A3D7F1 /* TmpViewController.swift in Sources */, 62959B372524DA7800A3D7F1 /* CAPConfig.swift in Sources */, 62959B432524DA7800A3D7F1 /* Data+Capacitor.swift in Sources */, - 62959B1E2524DA7800A3D7F1 /* StatusBar.swift in Sources */, 62959B3E2524DA7800A3D7F1 /* JSTypes.swift in Sources */, 62959B382524DA7800A3D7F1 /* CAPPluginCall.m in Sources */, 62959B1B2524DA7800A3D7F1 /* CAPFile.swift in Sources */, @@ -440,7 +429,6 @@ 62959B172524DA7800A3D7F1 /* JSExport.swift in Sources */, 62959B2D2524DA7800A3D7F1 /* App.swift in Sources */, 62959B3F2524DA7800A3D7F1 /* CAPAssetHandler.swift in Sources */, - 62959B1F2524DA7800A3D7F1 /* Keyboard.m in Sources */, 62959B3C2524DA7800A3D7F1 /* CAPBridgeDelegate.swift in Sources */, 62959B2C2524DA7800A3D7F1 /* LocalNotifications.swift in Sources */, 62959B2F2524DA7800A3D7F1 /* DefaultPlugins.m in Sources */, From e54a284c66121fe93643cb6492571988976de877 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Wed, 14 Oct 2020 17:47:55 -0400 Subject: [PATCH 13/40] Notifications update. --- .../CAPApplicationDelegateProxy.swift | 9 ++-- .../Capacitor/CAPBridgeViewController.swift | 2 +- .../Capacitor/CAPNotifications.swift | 49 ++++++++++++++----- ios/Capacitor/Capacitor/Plugins/App.swift | 4 +- .../Capacitor/Plugins/PushNotifications.swift | 4 +- .../UIStatusBarManager+CAPHandleTapAction.m | 2 +- 6 files changed, 48 insertions(+), 22 deletions(-) diff --git a/ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift b/ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift index 9b4368682a..80cf5d8371 100644 --- a/ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift +++ b/ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift @@ -1,13 +1,14 @@ import Foundation -@objc public class CAPApplicationDelegateProxy: NSObject, UIApplicationDelegate { - static let shared = CAPApplicationDelegateProxy() +@objc(CAPApplicationDelegateProxy) +public class ApplicationDelegateProxy: NSObject, UIApplicationDelegate { + static let shared = ApplicationDelegateProxy() private(set) var lastURL: URL? public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { - NotificationCenter.default.post(name: Notification.Name(CAPNotifications.URLOpen.name()), object: [ + NotificationCenter.default.post(name: .capacitorOpenURL, object: [ "url": url, "options": options ]) @@ -24,7 +25,7 @@ import Foundation let url = userActivity.webpageURL lastURL = url - NotificationCenter.default.post(name: Notification.Name(CAPNotifications.UniversalLinkOpen.name()), object: [ + NotificationCenter.default.post(name: .capacitorOpenUniversalLink, object: [ "url": url ]) return true diff --git a/ios/Capacitor/Capacitor/CAPBridgeViewController.swift b/ios/Capacitor/Capacitor/CAPBridgeViewController.swift index 15205bc017..a44a38131f 100644 --- a/ios/Capacitor/Capacitor/CAPBridgeViewController.swift +++ b/ios/Capacitor/Capacitor/CAPBridgeViewController.swift @@ -275,7 +275,7 @@ public class CAPBridgeViewController: UIViewController, CAPBridgeDelegate, WKUID } public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { - NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DecidePolicyForNavigationAction.name()), object: navigationAction) + NotificationCenter.default.post(name: .capacitorDecidePolicyForNavigationAction, object: navigationAction) let navUrl = navigationAction.request.url! /* diff --git a/ios/Capacitor/Capacitor/CAPNotifications.swift b/ios/Capacitor/Capacitor/CAPNotifications.swift index 413c177882..c61f06b6e1 100644 --- a/ios/Capacitor/Capacitor/CAPNotifications.swift +++ b/ios/Capacitor/Capacitor/CAPNotifications.swift @@ -1,35 +1,60 @@ /** - * Notificaton types for NSNotificationCenter + * Notificaton types for NotificationCenter and NSNotificationCenter + */ + +extension Notification.Name { + public static let capacitorOpenURL = Notification.Name(rawValue: "CapacitorOpenURLNotification") + public static let capacitorOpenUniversalLink = Notification.Name(rawValue: "CapacitorOpenUniversalLinkNotification") + public static let capacitorContinueActivity = Notification.Name(rawValue: "CapacitorContinueActivityNotification") + public static let capacitorDidRegisterForRemoteNotifications = Notification.Name(rawValue: "CapacitorDidRegisterForRemoteNotificationsNotification") + public static let capacitorDidFailToRegisterForRemoteNotifications = Notification.Name(rawValue: "CapacitorDidFailToRegisterForRemoteNotificationsNotification") + public static let capacitorDecidePolicyForNavigationAction = Notification.Name(rawValue: "CapacitorDecidePolicyForNavigationActionNotification") + public static let capacitorStatusBarTapped = Notification.Name(rawValue: "CapacitorStatusBarTappedNotification") +} + +@objc extension NSNotification { + public static let capacitorOpenURL = Notification.Name.capacitorOpenURL + public static let capacitorOpenUniversalLink = Notification.Name.capacitorOpenUniversalLink + public static let capacitorContinueActivity = Notification.Name.capacitorContinueActivity + public static let capacitorDidRegisterForRemoteNotifications = Notification.Name.capacitorDidRegisterForRemoteNotifications + public static let capacitorDidFailToRegisterForRemoteNotifications = Notification.Name.capacitorDidFailToRegisterForRemoteNotifications + public static let capacitorDecidePolicyForNavigationAction = Notification.Name.capacitorDecidePolicyForNavigationAction + public static let capacitorStatusBarTapped = Notification.Name.capacitorStatusBarTapped +} + +/* + Deprecated, will be removed */ @objc public enum CAPNotifications: Int { // swiftlint:disable identifier_name + @available(*, deprecated, renamed: "Notification.Name.capacitorOpenURL") case URLOpen + @available(*, deprecated, renamed: "Notification.Name.capacitorOpenUniversalLink") case UniversalLinkOpen + @available(*, deprecated, renamed: "Notification.Name.capacitorContinueActivity") case ContinueActivity + @available(*, deprecated, renamed: "Notification.Name.capacitorDidRegisterForRemoteNotifications") case DidRegisterForRemoteNotificationsWithDeviceToken + @available(*, deprecated, renamed: "Notification.Name.capacitorDidFailToRegisterForRemoteNotifications") case DidFailToRegisterForRemoteNotificationsWithError + @available(*, deprecated, renamed: "Notification.Name.capacitorDecidePolicyForNavigationAction") case DecidePolicyForNavigationAction // swiftlint:enable identifier_name - @available(*, deprecated, message: "Notifications have been moved") public func name() -> String { switch self { case .URLOpen: - return "CAPNotificationsURLOpen" + return Notification.Name.capacitorOpenURL.rawValue case .UniversalLinkOpen: - return "CAPUniversalLinkOpen" + return Notification.Name.capacitorOpenUniversalLink.rawValue case .ContinueActivity: - return "CAPNotificationsContinueActivity" + return Notification.Name.capacitorContinueActivity.rawValue case .DidRegisterForRemoteNotificationsWithDeviceToken: - return "CAPDidRegisterForRemoteNotificationsWithDeviceToken" + return Notification.Name.capacitorDidRegisterForRemoteNotifications.rawValue case .DidFailToRegisterForRemoteNotificationsWithError: - return "CAPDidFailToRegisterForRemoteNotificationsWithError" + return Notification.Name.capacitorDidFailToRegisterForRemoteNotifications.rawValue case .DecidePolicyForNavigationAction: - return "CAPDecidePolicyForNavigationAction" + return Notification.Name.capacitorDecidePolicyForNavigationAction.rawValue } } } - - -// @objc public static let statusBarTappedNotification = Notification(name: Notification.Name(rawValue: "statusBarTappedNotification")) - diff --git a/ios/Capacitor/Capacitor/Plugins/App.swift b/ios/Capacitor/Capacitor/Plugins/App.swift index 930f02b4f2..5875bf1f35 100644 --- a/ios/Capacitor/Capacitor/Plugins/App.swift +++ b/ios/Capacitor/Capacitor/Plugins/App.swift @@ -5,8 +5,8 @@ public class CAPAppPlugin: CAPPlugin { var lastUrlOpenOptions: [String: Any?]? override public func load() { - NotificationCenter.default.addObserver(self, selector: #selector(self.handleUrlOpened(notification:)), name: Notification.Name(CAPNotifications.URLOpen.name()), object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(self.handleUniversalLink(notification:)), name: Notification.Name(CAPNotifications.UniversalLinkOpen.name()), object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(self.handleUrlOpened(notification:)), name: .capacitorOpenURL, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(self.handleUniversalLink(notification:)), name: .capacitorOpenUniversalLink, object: nil) } @objc func handleUrlOpened(notification: NSNotification) { diff --git a/ios/Capacitor/Capacitor/Plugins/PushNotifications.swift b/ios/Capacitor/Capacitor/Plugins/PushNotifications.swift index 43aca31238..87b0de8397 100644 --- a/ios/Capacitor/Capacitor/Plugins/PushNotifications.swift +++ b/ios/Capacitor/Capacitor/Plugins/PushNotifications.swift @@ -17,11 +17,11 @@ public class CAPPushNotificationsPlugin: CAPPlugin { override public func load() { NotificationCenter.default.addObserver(self, selector: #selector(self.didRegisterForRemoteNotificationsWithDeviceToken(notification:)), - name: Notification.Name(CAPNotifications.DidRegisterForRemoteNotificationsWithDeviceToken.name()), + name: .capacitorDidRegisterForRemoteNotifications, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(self.didFailToRegisterForRemoteNotificationsWithError(notification:)), - name: Notification.Name(CAPNotifications.DidFailToRegisterForRemoteNotificationsWithError.name()), + name: .capacitorDidFailToRegisterForRemoteNotifications, object: nil) } diff --git a/ios/Capacitor/Capacitor/UIStatusBarManager+CAPHandleTapAction.m b/ios/Capacitor/Capacitor/UIStatusBarManager+CAPHandleTapAction.m index b11f608f82..44272a33ba 100644 --- a/ios/Capacitor/Capacitor/UIStatusBarManager+CAPHandleTapAction.m +++ b/ios/Capacitor/Capacitor/UIStatusBarManager+CAPHandleTapAction.m @@ -30,7 +30,7 @@ + (void)load { } -(void)nofity_handleTapAction:(id)arg1 { - [[NSNotificationCenter defaultCenter] postNotification:CAPBridge.statusBarTappedNotification]; + [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:NSNotification.capacitorStatusBarTapped object:nil]]; [self nofity_handleTapAction:arg1]; } From 36e4978845e767919b59af7f6867c8b9b92151fa Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Wed, 14 Oct 2020 17:48:39 -0400 Subject: [PATCH 14/40] Marking additional classes internal --- ios/Capacitor/Capacitor/CAPAssetHandler.swift | 2 +- ios/Capacitor/Capacitor/JSExport.swift | 2 +- ios/Capacitor/Capacitor/TmpViewController.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ios/Capacitor/Capacitor/CAPAssetHandler.swift b/ios/Capacitor/Capacitor/CAPAssetHandler.swift index b9a5b71a39..9271ab7179 100644 --- a/ios/Capacitor/Capacitor/CAPAssetHandler.swift +++ b/ios/Capacitor/Capacitor/CAPAssetHandler.swift @@ -1,7 +1,7 @@ import Foundation import MobileCoreServices -class CAPAssetHandler: NSObject, WKURLSchemeHandler { +internal class CAPAssetHandler: NSObject, WKURLSchemeHandler { private var basePath: String = "" diff --git a/ios/Capacitor/Capacitor/JSExport.swift b/ios/Capacitor/Capacitor/JSExport.swift index 51d6205d90..2203f3b952 100644 --- a/ios/Capacitor/Capacitor/JSExport.swift +++ b/ios/Capacitor/Capacitor/JSExport.swift @@ -2,7 +2,7 @@ * PluginExport handles defining JS APIs that map to registered * plugins and are responsible for proxying calls to our bridge. */ -public class JSExport { +internal class JSExport { static let catchallOptionsParameter = "_options" static let callbackParameter = "_callback" diff --git a/ios/Capacitor/Capacitor/TmpViewController.swift b/ios/Capacitor/Capacitor/TmpViewController.swift index 664cf1ade4..5fafcb19e4 100644 --- a/ios/Capacitor/Capacitor/TmpViewController.swift +++ b/ios/Capacitor/Capacitor/TmpViewController.swift @@ -1,6 +1,6 @@ import UIKit -class TmpViewController: UIViewController { +internal class TmpViewController: UIViewController { var count = 0 override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) From 66eac4b9b6d24db3a5d3199c99943780a8638f3a Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Wed, 14 Oct 2020 17:49:26 -0400 Subject: [PATCH 15/40] Updating plugin implementation to match interface. --- ios/Capacitor/Capacitor/CAPPlugin.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ios/Capacitor/Capacitor/CAPPlugin.m b/ios/Capacitor/Capacitor/CAPPlugin.m index 2f1f268b26..10b2bfa143 100644 --- a/ios/Capacitor/Capacitor/CAPPlugin.m +++ b/ios/Capacitor/Capacitor/CAPPlugin.m @@ -1,13 +1,12 @@ #import "CAPPlugin.h" #import - #import @implementation CAPPlugin --(instancetype) initWithBridge:(CAPBridge *)bridge pluginId:(NSString *)pluginId pluginName:(NSString *)pluginName { +-(instancetype) initWithBridge:(id)bridge pluginId:(NSString *)pluginId pluginName:(NSString *)pluginName { self.bridge = bridge; - self.webView = bridge.getWebView; + self.webView = bridge.webView; self.pluginId = pluginId; self.pluginName = pluginName; self.eventListeners = [[NSMutableDictionary alloc] init]; From 34b62472ea93ccea611cae541b297beb49da4728 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Wed, 14 Oct 2020 17:51:18 -0400 Subject: [PATCH 16/40] Updating bridge protocol, moving CapacitorBridge, adding deprecated stub for CAPBridge. --- .../Capacitor.xcodeproj/project.pbxproj | 4 + ios/Capacitor/Capacitor/CAPBridge.swift | 645 +----------------- .../Capacitor/CAPBridgeProtocol.swift | 29 +- ios/Capacitor/Capacitor/CapacitorBridge.swift | 612 +++++++++++++++++ ios/Capacitor/Capacitor/JSExport.swift | 10 +- 5 files changed, 648 insertions(+), 652 deletions(-) create mode 100644 ios/Capacitor/Capacitor/CapacitorBridge.swift diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj index e2bc9575bf..12bfbebe8b 100644 --- a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj +++ b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj @@ -54,6 +54,7 @@ 62959B472524DA7800A3D7F1 /* CAPNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B152524DA7700A3D7F1 /* CAPNotifications.swift */; }; 62959BA52526475A00A3D7F1 /* Cordova.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62959BA02526474300A3D7F1 /* Cordova.framework */; }; 62959BA62526475A00A3D7F1 /* Cordova.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 62959BA02526474300A3D7F1 /* Cordova.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 62C0A97925377AED004384F8 /* CapacitorBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62C0A97825377AED004384F8 /* CapacitorBridge.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -139,6 +140,7 @@ 62959B8225253A9500A3D7F1 /* Capacitor.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = Capacitor.modulemap; sourceTree = ""; }; 62959B9B2526474300A3D7F1 /* CapacitorCordova.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CapacitorCordova.xcodeproj; path = ../CapacitorCordova/CapacitorCordova.xcodeproj; sourceTree = ""; }; 62959BBD2526510200A3D7F1 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 62C0A97825377AED004384F8 /* CapacitorBridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapacitorBridge.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -209,6 +211,7 @@ 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */, 62959B062524DA7700A3D7F1 /* CAPPluginCall.m */, 620943092527C87D0072A562 /* CAPBridgeProtocol.swift */, + 62C0A97825377AED004384F8 /* CapacitorBridge.swift */, 62959B142524DA7700A3D7F1 /* CAPBridge.swift */, 626B289625364A6500FFF7CB /* CAPApplicationDelegateProxy.swift */, 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */, @@ -424,6 +427,7 @@ 62959B1A2524DA7800A3D7F1 /* CAPPluginCall.swift in Sources */, 62959B302524DA7800A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m in Sources */, 62959B392524DA7800A3D7F1 /* CapacitorExtension.swift in Sources */, + 62C0A97925377AED004384F8 /* CapacitorBridge.swift in Sources */, 62959B3D2524DA7800A3D7F1 /* CAPMessageHandlerWrapper.swift in Sources */, 62959B422524DA7800A3D7F1 /* DocLinks.swift in Sources */, 62959B172524DA7800A3D7F1 /* JSExport.swift in Sources */, diff --git a/ios/Capacitor/Capacitor/CAPBridge.swift b/ios/Capacitor/Capacitor/CAPBridge.swift index 7246db0677..5095ecef15 100644 --- a/ios/Capacitor/Capacitor/CAPBridge.swift +++ b/ios/Capacitor/Capacitor/CAPBridge.swift @@ -1,651 +1,18 @@ import Foundation -import Dispatch -import WebKit -import Cordova -enum BridgeError: Error { - case errorExportingCoreJS -} - -internal class CapacitorBridge: NSObject, CAPBridgeProtocol { - - // MARK: - CAPBridgeProtocol Properties - - public var webView: WKWebView? { - return bridgeDelegate?.bridgedWebView - } - - public var isSimEnvironment: Bool { - #if targetEnvironment(simulator) - return true - #else - return false - #endif - } - - public var isDevEnvironment: Bool { - #if DEBUG - return true - #else - return false - #endif - } - - @available(iOS 12.0, *) - public var userInterfaceStyle: UIUserInterfaceStyle { - return viewController?.traitCollection.userInterfaceStyle ?? .unspecified - } - - public var statusBarVisible: Bool { - get { - return !(viewController?.prefersStatusBarHidden ?? true) - } - set { - DispatchQueue.main.async { [weak self] in - (self?.viewController as? CAPBridgeViewController)?.setStatusBarVisible(newValue) - } - } - } - - public var statusBarStyle: UIStatusBarStyle { - get { - return viewController?.preferredStatusBarStyle ?? .default - } - set { - DispatchQueue.main.async { [weak self] in - (self?.viewController as? CAPBridgeViewController)?.setStatusBarStyle(newValue) - } - } - } - - public var statusBarAnimation: UIStatusBarAnimation { - get { - return (viewController as? CAPBridgeViewController)?.statusBarAnimation ?? .slide - } - set { - DispatchQueue.main.async { [weak self] in - (self?.viewController as? CAPBridgeViewController)?.setStatusBarAnimation(newValue) - } - } - } - - var tmpWindow: UIWindow? - @objc public static let statusBarTappedNotification = Notification(name: Notification.Name(rawValue: "statusBarTappedNotification")) - @objc public static let tmpVCAppeared = Notification(name: Notification.Name(rawValue: "tmpViewControllerAppeared")) - public static let capacitorSite = "https://capacitorjs.com/" - public static let fileStartIdentifier = "/_capacitor_file_" - public static let defaultScheme = "capacitor" - - // The last URL that caused the app to open - public var lastUrl: URL? - - public var messageHandlerWrapper: CAPMessageHandlerWrapper - public weak var bridgeDelegate: CAPBridgeDelegate? - @objc public var viewController: UIViewController? { - return bridgeDelegate?.bridgedViewController - } - - private var localUrl: String? - - public var lastPlugin: CAPPlugin? - - @objc public var config: CAPConfig - // Map of all loaded and instantiated plugins by pluginId -> instance - public var plugins = [String: CAPPlugin]() - // List of known plugins by pluginId -> Plugin Type - public var knownPlugins = [String: CAPPlugin.Type]() - // Manager for getting Cordova plugins - public var cordovaPluginManager: CDVPluginManager? - // Calls we are storing to resolve later - public var storedCalls = [String: CAPPluginCall]() - // Scheme to use when serving content - public var scheme: String - // Whether the app is active - private var isActive = true - // Wheter to inject the Cordova files - private var injectCordovaFiles = false - - // Background dispatch queue for plugin calls - public var dispatchQueue = DispatchQueue(label: "bridge") - - public var notificationDelegationHandler: CAPUNUserNotificationCenterDelegate - - public init(_ bridgeDelegate: CAPBridgeDelegate, _ messageHandlerWrapper: CAPMessageHandlerWrapper, _ config: CAPConfig, _ scheme: String) { - self.bridgeDelegate = bridgeDelegate - self.messageHandlerWrapper = messageHandlerWrapper - self.notificationDelegationHandler = CAPUNUserNotificationCenterDelegate() - self.config = config - self.scheme = scheme - - super.init() - - self.messageHandlerWrapper.bridge = self - self.notificationDelegationHandler.bridge = self - localUrl = "\(self.scheme)://\(config.getString("server.hostname") ?? "localhost")" - exportCoreJS(localUrl: localUrl!) - registerPlugins() - setupCordovaCompatibility() - bindObservers() - NotificationCenter.default.addObserver(forName: type(of: self).tmpVCAppeared.name, object: .none, queue: .none) { [weak self] _ in - self?.tmpWindow = nil - } - } - - deinit { - // the message handler needs to removed to avoid any retain cycles - messageHandlerWrapper.cleanUp() - } - - // MARK: - Deprecated - - public func getWebView() -> WKWebView? { - return webView - } - - public func isSimulator() -> Bool { - return isSimEnvironment - } - - public func isDevMode() -> Bool { - return isDevEnvironment - } +@available(*, deprecated, message: "CAPBridge is deprecated. statusBarTappedNotification has been moved to Notification.Name.capacitorStatusBarTapped. Application delegate methods have been moved to ApplicationDelegateProxy.") +@objc public class CAPBridge: NSObject { + @objc public static let statusBarTappedNotification = Notification(name: .capacitorStatusBarTapped) - public func getStatusBarVisible() -> Bool { - return statusBarVisible - } - - @nonobjc public func setStatusBarVisible(_ visible:Bool) { - statusBarVisible = visible - } - - public func getStatusBarStyle() -> UIStatusBarStyle { - return statusBarStyle - } - @nonobjc public func setStatusBarStyle(_ style:UIStatusBarStyle) { - statusBarStyle = style - } - - @available(iOS 12.0, *) - public func getUserInterfaceStyle() -> UIUserInterfaceStyle { - return userInterfaceStyle - } - - @nonobjc public func setStatusBarAnimation(_ animation:UIStatusBarAnimation) { - statusBarAnimation = animation - } - - - - /** - * Get the last URL that triggered an open or continue activity event. - */ - public func getLastUrl() -> URL? { - return lastUrl - } - - /** - * Handle an openUrl action and dispatch a notification. - */ public static func handleOpenUrl(_ url: URL, _ options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool { - NotificationCenter.default.post(name: Notification.Name(CAPNotifications.URLOpen.name()), object: [ - "url": url, - "options": options - ]) - NotificationCenter.default.post(name: NSNotification.Name.CDVPluginHandleOpenURL, object: url) - //CAPBridge.lastUrl = url - return true + return ApplicationDelegateProxy.shared.application(UIApplication.shared, open: url, options: options) } - - /** - * Handle continueUserActivity, for now this just provides universal link responding support. - */ + public static func handleContinueActivity(_ userActivity: NSUserActivity, _ restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { - // TODO: Support other types, emit to rest of plugins - if userActivity.activityType != NSUserActivityTypeBrowsingWeb || userActivity.webpageURL == nil { - return false - } - - let url = userActivity.webpageURL - //CAPBridge.lastUrl = url - NotificationCenter.default.post(name: Notification.Name(CAPNotifications.UniversalLinkOpen.name()), object: [ - "url": url - ]) - return true + return ApplicationDelegateProxy.shared.application(UIApplication.shared, continue: userActivity, restorationHandler: restorationHandler) } public static func handleAppBecameActive(_ application: UIApplication) { // no-op for now } - - /** - * Print a hopefully informative error message to the log when something - * particularly dreadful happens. - */ - static func fatalError(_ error: Error, _ originalError: Error) { - CAPLog.print("⚡️ ❌ Capacitor: FATAL ERROR") - CAPLog.print("⚡️ ❌ Error was: ", originalError.localizedDescription) - switch error { - case BridgeError.errorExportingCoreJS: - CAPLog.print("⚡️ ❌ Unable to export required Bridge JavaScript. Bridge will not function.") - CAPLog.print("⚡️ ❌ You should run \"npx capacitor copy\" to ensure the Bridge JS is added to your project.") - if let wke = originalError as? WKError { - CAPLog.print("⚡️ ❌ ", wke.userInfo) - } - default: - CAPLog.print("⚡️ ❌ Unknown error") - } - - CAPLog.print("⚡️ ❌ Please verify your installation or file an issue") - } - - /** - * Bind notification center observers to watch for app active/inactive status - */ - func bindObservers() { - let appStatePlugin = getOrLoadPlugin(pluginName: "App") as? CAPAppPlugin - - NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification, object: nil, queue: OperationQueue.main) { [weak self, weak appStatePlugin] (_) in - CAPLog.print("APP ACTIVE") - self?.isActive = true - if let strongSelf = self { - appStatePlugin?.fireChange(isActive: strongSelf.isActive) - } - } - NotificationCenter.default.addObserver(forName: UIApplication.willResignActiveNotification, object: nil, queue: OperationQueue.main) { [weak self, weak appStatePlugin] (_) in - CAPLog.print("APP INACTIVE") - self?.isActive = false - if let strongSelf = self { - appStatePlugin?.fireChange(isActive: strongSelf.isActive) - } - } - } - - /** - * - Returns: whether the app is currently active - */ - func isAppActive() -> Bool { - return isActive - } - - /** - * Export core JavaScript to the webview - */ - func exportCoreJS(localUrl: String) { - do { - try JSExport.exportCapacitorGlobalJS(userContentController: self.messageHandlerWrapper.contentController, isDebug: isDevMode(), localUrl: localUrl) - try JSExport.exportCapacitorJS(userContentController: self.messageHandlerWrapper.contentController) - } catch { - type(of: self).fatalError(error, error) - } - } - - /** - * Set up our Cordova compat by loading all known Cordova plugins and injecting - * their JS. - */ - func setupCordovaCompatibility() { - if injectCordovaFiles { - exportCordovaJS() - registerCordovaPlugins() - } - } - - /** - * Export the core Cordova JS runtime - */ - func exportCordovaJS() { - do { - try JSExport.exportCordovaJS(userContentController: self.messageHandlerWrapper.contentController) - } catch { - type(of: self).fatalError(error, error) - } - } - - /** - * Reset the state of the bridge between navigations to avoid - * sending data back to the page from a previous page. - */ - func reset() { - storedCalls = [String: CAPPluginCall]() - } - - /** - * Register all plugins that have been declared - */ - func registerPlugins() { - let classCount = objc_getClassList(nil, 0) - let classes = UnsafeMutablePointer.allocate(capacity: Int(classCount)) - - let releasingClasses = AutoreleasingUnsafeMutablePointer(classes) - let numClasses: Int32 = objc_getClassList(releasingClasses, classCount) - - for classIndex in 0.. CAPPlugin? { - guard let plugin = self.getPlugin(pluginName: pluginName) ?? self.loadPlugin(pluginName: pluginName) else { - return nil - } - return plugin - } - - public func getPlugin(pluginName: String) -> CAPPlugin? { - return self.plugins[pluginName] - } - - public func loadPlugin(pluginName: String) -> CAPPlugin? { - guard let pluginType = knownPlugins[pluginName], let bridgeType = pluginType as? CAPBridgedPlugin.Type else { - CAPLog.print("⚡️ Unable to load plugin \(pluginName). No such module found.") - return nil - } - - let plugin = pluginType.init(bridge: self, pluginId: bridgeType.pluginId(), pluginName: bridgeType.jsName()) - plugin.load() - self.plugins[bridgeType.jsName()] = plugin - return plugin - } - - func savePluginCall(_ call: CAPPluginCall) { - storedCalls[call.callbackId] = call - } - - @objc public func getSavedCall(_ callbackId: String) -> CAPPluginCall? { - return storedCalls[callbackId] - } - - @objc public func releaseCall(_ call: CAPPluginCall) { - storedCalls.removeValue(forKey: call.callbackId) - } - - @objc public func releaseCall(callbackId: String) { - storedCalls.removeValue(forKey: callbackId) - } - - public func getDispatchQueue() -> DispatchQueue { - return self.dispatchQueue - } - - func registerCordovaPlugins() { - guard let bridgeVC = self.viewController as? CAPBridgeViewController else { - return - } - cordovaPluginManager = CDVPluginManager.init(parser: bridgeVC.cordovaParser, viewController: self.viewController, webView: self.getWebView()) - if bridgeVC.cordovaParser.startupPluginNames.count > 0 { - for pluginName in bridgeVC.cordovaParser.startupPluginNames { - _ = cordovaPluginManager?.getCommandInstance(pluginName as? String) - } - } - do { - try JSExport.exportCordovaPluginsJS(userContentController: self.messageHandlerWrapper.contentController) - } catch { - type(of: self).fatalError(error, error) - } - } - - public func reload() { - self.getWebView()?.reload() - } - - public func modulePrint(_ plugin: CAPPlugin, _ items: Any...) { - let output = items.map { "\($0)" }.joined(separator: " ") - CAPLog.print("⚡️ ", plugin.pluginId, "-", output) - } - - public func showAlertWith(title: String, message: String, buttonTitle: String) { - let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert) - alert.addAction(UIAlertAction(title: buttonTitle, style: UIAlertAction.Style.default, handler: nil)) - self.viewController?.present(alert, animated: true, completion: nil) - } - - func docLink(_ url: String) -> String { - return "\(type(of: self).capacitorSite)docs/\(url)" - } - - /** - * Handle a call from JavaScript. First, find the corresponding plugin, - * construct a selector, and perform that selector on the plugin instance. - */ - public func handleJSCall(call: JSCall) { - guard let plugin = self.getPlugin(pluginName: call.pluginId) ?? self.loadPlugin(pluginName: call.pluginId) else { - CAPLog.print("⚡️ Error loading plugin \(call.pluginId) for call. Check that the pluginId is correct") - return - } - guard let pluginType = knownPlugins[plugin.getId()] else { - return - } - - var selector: Selector? - if call.method == "addListener" || call.method == "removeListener" { - selector = NSSelectorFromString(call.method + ":") - } else { - guard let bridgeType = pluginType as? CAPBridgedPlugin.Type, let method = bridgeType.getMethod(call.method) else { - CAPLog.print("⚡️ Error calling method \(call.method) on plugin \(call.pluginId): No method found.") - CAPLog.print("⚡️ Ensure plugin method exists and uses @objc in its declaration, and has been defined") - return - } - - //CAPLog.print("\n⚡️ Calling method \"\(call.method)\" on plugin \"\(plugin.getId()!)\"") - - selector = method.selector - } - - if !plugin.responds(to: selector) { - CAPLog.print("⚡️ Error: Plugin \(plugin.getId()) does not respond to method call \"\(call.method)\" using selector \"\(selector!)\".") - CAPLog.print("⚡️ Ensure plugin method exists, uses @objc in its declaration, and arguments match selector without callbacks in CAP_PLUGIN_METHOD.") - CAPLog.print("⚡️ Learn more: \(docLink(DocLinks.CAPPluginMethodSelector.rawValue))") - return - } - - // Create a plugin call object and handle the success/error callbacks - dispatchQueue.async { [weak self] in - //let startTime = CFAbsoluteTimeGetCurrent() - - let pluginCall = CAPPluginCall(callbackId: call.callbackId, options: call.options, success: {(result: CAPPluginCallResult?, pluginCall: CAPPluginCall?) -> Void in - if result != nil { - self?.toJs(result: JSResult(call: call, result: result!.data), save: pluginCall?.isSaved ?? false) - } else { - self?.toJs(result: JSResult(call: call, result: [:]), save: pluginCall?.isSaved ?? false) - } - }, error: {(error: CAPPluginCallError?) -> Void in - let description = error?.error?.localizedDescription ?? "" - self?.toJsError(error: JSResultError(call: call, message: error!.message, errorMessage: description, error: error!.data, code: error!.code)) - })! - - plugin.perform(selector, with: pluginCall) - - if pluginCall.isSaved { - self?.savePluginCall(pluginCall) - } - - //let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime - //CAPLog.print("Native call took", timeElapsed) - } - } - - /** - * Handle a Cordova call from JavaScript. First, find the corresponding plugin, - * construct a selector, and perform that selector on the plugin instance. - */ - public func handleCordovaJSCall(call: JSCall) { - // Create a selector to send to the plugin - - if let plugin = self.cordovaPluginManager?.getCommandInstance(call.pluginId.lowercased()) { - let selector = NSSelectorFromString("\(call.method):") - if !plugin.responds(to: selector) { - CAPLog.print("Error: Plugin \(plugin.className!) does not respond to method call \(selector).") - CAPLog.print("Ensure plugin method exists and uses @objc in its declaration") - return - } - - let arguments: [Any] = call.options["options"] as? [Any] ?? [] - let pluginCall = CDVInvokedUrlCommand(arguments: arguments, callbackId: call.callbackId, className: plugin.className, methodName: call.method) - plugin.perform(selector, with: pluginCall) - - } else { - CAPLog.print("Error: Cordova Plugin mapping not found") - return - } - } - - /** - * Send a successful result to the JavaScript layer. - */ - public func toJs(result: JSResult, save: Bool) { - do { - let resultJson = try result.toJson() - CAPLog.print("⚡️ TO JS", resultJson.prefix(256)) - - DispatchQueue.main.async { - self.getWebView()?.evaluateJavaScript(""" - window.Capacitor.fromNative({ - callbackId: '\(result.call.callbackId)', - pluginId: '\(result.call.pluginId)', - methodName: '\(result.call.method)', - save: \(save), - success: true, - data: \(resultJson) - }) - """) { (result, error) in - if error != nil && result != nil { - CAPLog.print(result!) - } - } - } - } catch { - if let jsError = error as? JSProcessingError, let appState = getOrLoadPlugin(pluginName: "App") as? CAPAppPlugin { - appState.firePluginError(jsError) - } - } - - } - - /** - * Send an error result to the JavaScript layer. - */ - public func toJsError(error: JSResultError) { - DispatchQueue.main.async { - self.getWebView()?.evaluateJavaScript("window.Capacitor.fromNative({ callbackId: '\(error.call.callbackId)', pluginId: '\(error.call.pluginId)', methodName: '\(error.call.method)', success: false, error: \(error.toJson())})") { (result, error) in - if error != nil && result != nil { - CAPLog.print(result!) - } - } - } - } - - /** - * Eval JS for a specific plugin. - */ - @objc public func evalWithPlugin(_ plugin: CAPPlugin, js: String) { - let wrappedJs = """ - window.Capacitor.withPlugin('\(plugin.getId())', function(plugin) { - if(!plugin) { console.error('Unable to execute JS in plugin, no such plugin found for id \(plugin.getId())'); } - \(js) - }); - """ - - DispatchQueue.main.async { - self.getWebView()?.evaluateJavaScript(wrappedJs, completionHandler: { (_, error) in - if error != nil { - CAPLog.print("⚡️ JS Eval error", error!.localizedDescription) - } - }) - } - } - - /** - * Eval JS in the web view - */ - @objc public func eval(js: String) { - DispatchQueue.main.async { - self.getWebView()?.evaluateJavaScript(js, completionHandler: { (_, error) in - if error != nil { - CAPLog.print("⚡️ JS Eval error", error!.localizedDescription) - } - }) - } - } - - @objc public func triggerJSEvent(eventName: String, target: String) { - self.eval(js: "window.Capacitor.triggerEvent('\(eventName)', '\(target)')") - } - - @objc public func triggerJSEvent(eventName: String, target: String, data: String) { - self.eval(js: "window.Capacitor.triggerEvent('\(eventName)', '\(target)', \(data))") - } - - @objc public func triggerWindowJSEvent(eventName: String) { - self.triggerJSEvent(eventName: eventName, target: "window") - } - - @objc public func triggerWindowJSEvent(eventName: String, data: String) { - self.triggerJSEvent(eventName: eventName, target: "window", data: data) - } - - @objc public func triggerDocumentJSEvent(eventName: String) { - self.triggerJSEvent(eventName: eventName, target: "document") - } - - @objc public func triggerDocumentJSEvent(eventName: String, data: String) { - self.triggerJSEvent(eventName: eventName, target: "document", data: data) - } - - public func logToJs(_ message: String, _ level: String = "log") { - DispatchQueue.main.async { - self.getWebView()?.evaluateJavaScript("window.Capacitor.logJs('\(message)', '\(level)')") { (result, error) in - if error != nil && result != nil { - CAPLog.print(result!) - } - } - } - } - - public func getLocalUrl() -> String { - return localUrl! - } - - @objc public func presentVC(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) { - if viewControllerToPresent.modalPresentationStyle == .popover { - self.viewController?.present(viewControllerToPresent, animated: flag, completion: completion) - } else { - self.tmpWindow = UIWindow.init(frame: UIScreen.main.bounds) - self.tmpWindow!.rootViewController = TmpViewController.init() - self.tmpWindow!.makeKeyAndVisible() - self.tmpWindow!.rootViewController!.present(viewControllerToPresent, animated: flag, completion: completion) - } - } - - @objc public func dismissVC(animated flag: Bool, completion: (() -> Void)? = nil) { - if self.tmpWindow == nil { - self.viewController?.dismiss(animated: flag, completion: completion) - } else { - self.tmpWindow!.rootViewController!.dismiss(animated: flag, completion: completion) - self.tmpWindow = nil - } - } - } diff --git a/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift b/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift index ce7f079eb4..abafa5b5d1 100644 --- a/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift +++ b/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift @@ -1,16 +1,11 @@ import Foundation import WebKit -public enum CAPBridgeError: Error { - case errorExportingCoreJS -} - @objc public protocol CAPBridgeProtocol: NSObjectProtocol { // MARK: Environment Properties var viewController: UIViewController? { get } var config: CAPConfig { get } var webView: WKWebView? { get } - var lastUrl: URL? { get } var isSimEnvironment: Bool { get } var isDevEnvironment: Bool { get } @available(iOS 12.0, *) @@ -40,6 +35,9 @@ public enum CAPBridgeError: Error { @available(*, deprecated, renamed: "userInterfaceStyle") func getUserInterfaceStyle() -> UIUserInterfaceStyle + @available(*, deprecated, message: "Moved to ApplicationDelegateProxy") + func getLastUrl() -> URL? + // MARK: Call Management func getSavedCall(_ callbackId: String) -> CAPPluginCall? func releaseCall(_ call: CAPPluginCall) @@ -58,6 +56,9 @@ public enum CAPBridgeError: Error { func triggerDocumentJSEvent(eventName: String) func triggerDocumentJSEvent(eventName: String, data: String) + // MARK: - Logging + func print(message: String, for plugin: CAPPlugin) + // MARK: View Presentation func showAlertWith(title: String, message: String, buttonTitle: String) func presentVC(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?) @@ -68,13 +69,17 @@ public enum CAPBridgeError: Error { Extensions to Obj-C protocols are not exposed to Obj-C code because of limitations in the runtime. Therefore these methods are implicitly Swift-only. - The ones marked as deprecated are here because they can be declared without interfering with the synthesized Obj-C setters + The methods marked as deprecated are here because they can be declared without interfering with the synthesized Obj-C setters for the respective properties (e.g. `setStatusBarVisible:` for 'statusBarVisible`). */ extension CAPBridgeProtocol { + // varidic parameters cannot be exposed to Obj-C func modulePrint(_ plugin: CAPPlugin, _ items: Any...) { + let output = items.map { String(describing: $0) }.joined(separator: " ") + print(message: output, for: plugin) } + // default arguments are not permitted in protocol declarations func alert(_ title: String, _ message: String, _ buttonTitle: String = "OK") { showAlertWith(title: title, message: message, buttonTitle: buttonTitle) } @@ -95,7 +100,15 @@ extension CAPBridgeProtocol { } } -extension CAPBridgeError: CustomNSError { +/* + Error(s) potentially exported by the bridge. + */ + +public enum CapacitorBridgeError: Error { + case errorExportingCoreJS +} + +extension CapacitorBridgeError: CustomNSError { static public var errorDomain: String { "CapacitorBridge" } public var errorCode: Int { switch self { @@ -108,7 +121,7 @@ extension CAPBridgeError: CustomNSError { } } -extension CAPBridgeError: LocalizedError { +extension CapacitorBridgeError: LocalizedError { public var errorDescription: String? { return NSLocalizedString("Unable to export JavaScript bridge code to webview", comment: "Capacitor bridge initialization error") } diff --git a/ios/Capacitor/Capacitor/CapacitorBridge.swift b/ios/Capacitor/Capacitor/CapacitorBridge.swift new file mode 100644 index 0000000000..f99b0b1967 --- /dev/null +++ b/ios/Capacitor/Capacitor/CapacitorBridge.swift @@ -0,0 +1,612 @@ +import Foundation +import Dispatch +import WebKit +import Cordova + +import Foundation +import Dispatch +import WebKit +import Cordova + +//enum BridgeError: Error { +// case errorExportingCoreJS +//} + +internal class CapacitorBridge: NSObject, CAPBridgeProtocol { + + // MARK: - CAPBridgeProtocol Properties + + public var webView: WKWebView? { + return bridgeDelegate?.bridgedWebView + } + + public var isSimEnvironment: Bool { + #if targetEnvironment(simulator) + return true + #else + return false + #endif + } + + public var isDevEnvironment: Bool { + #if DEBUG + return true + #else + return false + #endif + } + + @available(iOS 12.0, *) + public var userInterfaceStyle: UIUserInterfaceStyle { + return viewController?.traitCollection.userInterfaceStyle ?? .unspecified + } + + public var statusBarVisible: Bool { + get { + return !(viewController?.prefersStatusBarHidden ?? true) + } + set { + DispatchQueue.main.async { [weak self] in + (self?.viewController as? CAPBridgeViewController)?.setStatusBarVisible(newValue) + } + } + } + + public var statusBarStyle: UIStatusBarStyle { + get { + return viewController?.preferredStatusBarStyle ?? .default + } + set { + DispatchQueue.main.async { [weak self] in + (self?.viewController as? CAPBridgeViewController)?.setStatusBarStyle(newValue) + } + } + } + + public var statusBarAnimation: UIStatusBarAnimation { + get { + return (viewController as? CAPBridgeViewController)?.statusBarAnimation ?? .slide + } + set { + DispatchQueue.main.async { [weak self] in + (self?.viewController as? CAPBridgeViewController)?.setStatusBarAnimation(newValue) + } + } + } + + var tmpWindow: UIWindow? + static let tmpVCAppeared = Notification(name: Notification.Name(rawValue: "tmpViewControllerAppeared")) + public static let capacitorSite = "https://capacitorjs.com/" + public static let fileStartIdentifier = "/_capacitor_file_" + public static let defaultScheme = "capacitor" + + var messageHandlerWrapper: CAPMessageHandlerWrapper + weak var bridgeDelegate: CAPBridgeDelegate? + @objc public var viewController: UIViewController? { + return bridgeDelegate?.bridgedViewController + } + + private var localUrl: String? + + var lastPlugin: CAPPlugin? + + @objc public var config: CAPConfig + // Map of all loaded and instantiated plugins by pluginId -> instance + var plugins = [String: CAPPlugin]() + // List of known plugins by pluginId -> Plugin Type + var knownPlugins = [String: CAPPlugin.Type]() + // Manager for getting Cordova plugins + var cordovaPluginManager: CDVPluginManager? + // Calls we are storing to resolve later + var storedCalls = [String: CAPPluginCall]() + // Scheme to use when serving content + var scheme: String + // Whether the app is active + private var isActive = true + // Wheter to inject the Cordova files + private var injectCordovaFiles = false + + // Background dispatch queue for plugin calls + var dispatchQueue = DispatchQueue(label: "bridge") + + public var notificationDelegationHandler: CAPUNUserNotificationCenterDelegate + + init(_ bridgeDelegate: CAPBridgeDelegate, _ messageHandlerWrapper: CAPMessageHandlerWrapper, _ config: CAPConfig, _ scheme: String) { + self.bridgeDelegate = bridgeDelegate + self.messageHandlerWrapper = messageHandlerWrapper + self.notificationDelegationHandler = CAPUNUserNotificationCenterDelegate() + self.config = config + self.scheme = scheme + + super.init() + + self.messageHandlerWrapper.bridge = self + self.notificationDelegationHandler.bridge = self + localUrl = "\(self.scheme)://\(config.getString("server.hostname") ?? "localhost")" + exportCoreJS(localUrl: localUrl!) + registerPlugins() + setupCordovaCompatibility() + bindObservers() + NotificationCenter.default.addObserver(forName: type(of: self).tmpVCAppeared.name, object: .none, queue: .none) { [weak self] _ in + self?.tmpWindow = nil + } + } + + deinit { + // the message handler needs to removed to avoid any retain cycles + messageHandlerWrapper.cleanUp() + } + + // MARK: - Deprecated + + public func getWebView() -> WKWebView? { + return webView + } + + public func isSimulator() -> Bool { + return isSimEnvironment + } + + public func isDevMode() -> Bool { + return isDevEnvironment + } + + public func getStatusBarVisible() -> Bool { + return statusBarVisible + } + + @nonobjc public func setStatusBarVisible(_ visible:Bool) { + statusBarVisible = visible + } + + public func getStatusBarStyle() -> UIStatusBarStyle { + return statusBarStyle + } + @nonobjc public func setStatusBarStyle(_ style:UIStatusBarStyle) { + statusBarStyle = style + } + + @available(iOS 12.0, *) + public func getUserInterfaceStyle() -> UIUserInterfaceStyle { + return userInterfaceStyle + } + + @nonobjc public func setStatusBarAnimation(_ animation:UIStatusBarAnimation) { + statusBarAnimation = animation + } + + public func getLastUrl() -> URL? { + return ApplicationDelegateProxy.shared.lastURL + } + + /** + * Print a hopefully informative error message to the log when something + * particularly dreadful happens. + */ + static func fatalError(_ error: Error, _ originalError: Error) { + CAPLog.print("⚡️ ❌ Capacitor: FATAL ERROR") + CAPLog.print("⚡️ ❌ Error was: ", originalError.localizedDescription) + switch error { + case CapacitorBridgeError.errorExportingCoreJS: + CAPLog.print("⚡️ ❌ Unable to export required Bridge JavaScript. Bridge will not function.") + CAPLog.print("⚡️ ❌ You should run \"npx capacitor copy\" to ensure the Bridge JS is added to your project.") + if let wke = originalError as? WKError { + CAPLog.print("⚡️ ❌ ", wke.userInfo) + } + default: + CAPLog.print("⚡️ ❌ Unknown error") + } + + CAPLog.print("⚡️ ❌ Please verify your installation or file an issue") + } + + /** + * Bind notification center observers to watch for app active/inactive status + */ + func bindObservers() { + let appStatePlugin = getOrLoadPlugin(pluginName: "App") as? CAPAppPlugin + + NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification, object: nil, queue: OperationQueue.main) { [weak self, weak appStatePlugin] (_) in + CAPLog.print("APP ACTIVE") + self?.isActive = true + if let strongSelf = self { + appStatePlugin?.fireChange(isActive: strongSelf.isActive) + } + } + NotificationCenter.default.addObserver(forName: UIApplication.willResignActiveNotification, object: nil, queue: OperationQueue.main) { [weak self, weak appStatePlugin] (_) in + CAPLog.print("APP INACTIVE") + self?.isActive = false + if let strongSelf = self { + appStatePlugin?.fireChange(isActive: strongSelf.isActive) + } + } + } + + /** + * - Returns: whether the app is currently active + */ + func isAppActive() -> Bool { + return isActive + } + + /** + * Export core JavaScript to the webview + */ + func exportCoreJS(localUrl: String) { + do { + try JSExport.exportCapacitorGlobalJS(userContentController: self.messageHandlerWrapper.contentController, isDebug: isDevMode(), localUrl: localUrl) + try JSExport.exportCapacitorJS(userContentController: self.messageHandlerWrapper.contentController) + } catch { + type(of: self).fatalError(error, error) + } + } + + /** + * Set up our Cordova compat by loading all known Cordova plugins and injecting + * their JS. + */ + func setupCordovaCompatibility() { + if injectCordovaFiles { + exportCordovaJS() + registerCordovaPlugins() + } + } + + /** + * Export the core Cordova JS runtime + */ + func exportCordovaJS() { + do { + try JSExport.exportCordovaJS(userContentController: self.messageHandlerWrapper.contentController) + } catch { + type(of: self).fatalError(error, error) + } + } + + /** + * Reset the state of the bridge between navigations to avoid + * sending data back to the page from a previous page. + */ + func reset() { + storedCalls = [String: CAPPluginCall]() + } + + /** + * Register all plugins that have been declared + */ + func registerPlugins() { + let classCount = objc_getClassList(nil, 0) + let classes = UnsafeMutablePointer.allocate(capacity: Int(classCount)) + + let releasingClasses = AutoreleasingUnsafeMutablePointer(classes) + let numClasses: Int32 = objc_getClassList(releasingClasses, classCount) + + for classIndex in 0.. CAPPlugin? { + guard let plugin = self.getPlugin(pluginName: pluginName) ?? self.loadPlugin(pluginName: pluginName) else { + return nil + } + return plugin + } + + public func getPlugin(pluginName: String) -> CAPPlugin? { + return self.plugins[pluginName] + } + + public func loadPlugin(pluginName: String) -> CAPPlugin? { + guard let pluginType = knownPlugins[pluginName], let bridgeType = pluginType as? CAPBridgedPlugin.Type else { + CAPLog.print("⚡️ Unable to load plugin \(pluginName). No such module found.") + return nil + } + + let plugin = pluginType.init(bridge: self, pluginId: bridgeType.pluginId(), pluginName: bridgeType.jsName()) + plugin.load() + self.plugins[bridgeType.jsName()] = plugin + return plugin + } + + func savePluginCall(_ call: CAPPluginCall) { + storedCalls[call.callbackId] = call + } + + @objc public func getSavedCall(_ callbackId: String) -> CAPPluginCall? { + return storedCalls[callbackId] + } + + @objc public func releaseCall(_ call: CAPPluginCall) { + storedCalls.removeValue(forKey: call.callbackId) + } + + @objc public func releaseCall(callbackId: String) { + storedCalls.removeValue(forKey: callbackId) + } + + public func getDispatchQueue() -> DispatchQueue { + return self.dispatchQueue + } + + func registerCordovaPlugins() { + guard let bridgeVC = self.viewController as? CAPBridgeViewController else { + return + } + cordovaPluginManager = CDVPluginManager.init(parser: bridgeVC.cordovaParser, viewController: self.viewController, webView: self.getWebView()) + if bridgeVC.cordovaParser.startupPluginNames.count > 0 { + for pluginName in bridgeVC.cordovaParser.startupPluginNames { + _ = cordovaPluginManager?.getCommandInstance(pluginName as? String) + } + } + do { + try JSExport.exportCordovaPluginsJS(userContentController: self.messageHandlerWrapper.contentController) + } catch { + type(of: self).fatalError(error, error) + } + } + + public func reload() { + self.getWebView()?.reload() + } + + public func print(message: String, for plugin: CAPPlugin) { + CAPLog.print("⚡️ ", plugin.pluginId, "-", message) + } + + public func showAlertWith(title: String, message: String, buttonTitle: String) { + let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: buttonTitle, style: UIAlertAction.Style.default, handler: nil)) + self.viewController?.present(alert, animated: true, completion: nil) + } + + func docLink(_ url: String) -> String { + return "\(type(of: self).capacitorSite)docs/\(url)" + } + + /** + * Handle a call from JavaScript. First, find the corresponding plugin, + * construct a selector, and perform that selector on the plugin instance. + */ + public func handleJSCall(call: JSCall) { + guard let plugin = self.getPlugin(pluginName: call.pluginId) ?? self.loadPlugin(pluginName: call.pluginId) else { + CAPLog.print("⚡️ Error loading plugin \(call.pluginId) for call. Check that the pluginId is correct") + return + } + guard let pluginType = knownPlugins[plugin.getId()] else { + return + } + + var selector: Selector? + if call.method == "addListener" || call.method == "removeListener" { + selector = NSSelectorFromString(call.method + ":") + } else { + guard let bridgeType = pluginType as? CAPBridgedPlugin.Type, let method = bridgeType.getMethod(call.method) else { + CAPLog.print("⚡️ Error calling method \(call.method) on plugin \(call.pluginId): No method found.") + CAPLog.print("⚡️ Ensure plugin method exists and uses @objc in its declaration, and has been defined") + return + } + + //CAPLog.print("\n⚡️ Calling method \"\(call.method)\" on plugin \"\(plugin.getId()!)\"") + + selector = method.selector + } + + if !plugin.responds(to: selector) { + CAPLog.print("⚡️ Error: Plugin \(plugin.getId()) does not respond to method call \"\(call.method)\" using selector \"\(selector!)\".") + CAPLog.print("⚡️ Ensure plugin method exists, uses @objc in its declaration, and arguments match selector without callbacks in CAP_PLUGIN_METHOD.") + CAPLog.print("⚡️ Learn more: \(docLink(DocLinks.CAPPluginMethodSelector.rawValue))") + return + } + + // Create a plugin call object and handle the success/error callbacks + dispatchQueue.async { [weak self] in + //let startTime = CFAbsoluteTimeGetCurrent() + + let pluginCall = CAPPluginCall(callbackId: call.callbackId, options: call.options, success: {(result: CAPPluginCallResult?, pluginCall: CAPPluginCall?) -> Void in + if result != nil { + self?.toJs(result: JSResult(call: call, result: result!.data), save: pluginCall?.isSaved ?? false) + } else { + self?.toJs(result: JSResult(call: call, result: [:]), save: pluginCall?.isSaved ?? false) + } + }, error: {(error: CAPPluginCallError?) -> Void in + let description = error?.error?.localizedDescription ?? "" + self?.toJsError(error: JSResultError(call: call, message: error!.message, errorMessage: description, error: error!.data, code: error!.code)) + })! + + plugin.perform(selector, with: pluginCall) + + if pluginCall.isSaved { + self?.savePluginCall(pluginCall) + } + + //let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime + //CAPLog.print("Native call took", timeElapsed) + } + } + + /** + * Handle a Cordova call from JavaScript. First, find the corresponding plugin, + * construct a selector, and perform that selector on the plugin instance. + */ + public func handleCordovaJSCall(call: JSCall) { + // Create a selector to send to the plugin + + if let plugin = self.cordovaPluginManager?.getCommandInstance(call.pluginId.lowercased()) { + let selector = NSSelectorFromString("\(call.method):") + if !plugin.responds(to: selector) { + CAPLog.print("Error: Plugin \(plugin.className!) does not respond to method call \(selector).") + CAPLog.print("Ensure plugin method exists and uses @objc in its declaration") + return + } + + let arguments: [Any] = call.options["options"] as? [Any] ?? [] + let pluginCall = CDVInvokedUrlCommand(arguments: arguments, callbackId: call.callbackId, className: plugin.className, methodName: call.method) + plugin.perform(selector, with: pluginCall) + + } else { + CAPLog.print("Error: Cordova Plugin mapping not found") + return + } + } + + /** + * Send a successful result to the JavaScript layer. + */ + public func toJs(result: JSResult, save: Bool) { + do { + let resultJson = try result.toJson() + CAPLog.print("⚡️ TO JS", resultJson.prefix(256)) + + DispatchQueue.main.async { + self.getWebView()?.evaluateJavaScript(""" + window.Capacitor.fromNative({ + callbackId: '\(result.call.callbackId)', + pluginId: '\(result.call.pluginId)', + methodName: '\(result.call.method)', + save: \(save), + success: true, + data: \(resultJson) + }) + """) { (result, error) in + if error != nil && result != nil { + CAPLog.print(result!) + } + } + } + } catch { + if let jsError = error as? JSProcessingError, let appState = getOrLoadPlugin(pluginName: "App") as? CAPAppPlugin { + appState.firePluginError(jsError) + } + } + + } + + /** + * Send an error result to the JavaScript layer. + */ + public func toJsError(error: JSResultError) { + DispatchQueue.main.async { + self.getWebView()?.evaluateJavaScript("window.Capacitor.fromNative({ callbackId: '\(error.call.callbackId)', pluginId: '\(error.call.pluginId)', methodName: '\(error.call.method)', success: false, error: \(error.toJson())})") { (result, error) in + if error != nil && result != nil { + CAPLog.print(result!) + } + } + } + } + + /** + * Eval JS for a specific plugin. + */ + @objc public func evalWithPlugin(_ plugin: CAPPlugin, js: String) { + let wrappedJs = """ + window.Capacitor.withPlugin('\(plugin.getId())', function(plugin) { + if(!plugin) { console.error('Unable to execute JS in plugin, no such plugin found for id \(plugin.getId())'); } + \(js) + }); + """ + + DispatchQueue.main.async { + self.getWebView()?.evaluateJavaScript(wrappedJs, completionHandler: { (_, error) in + if error != nil { + CAPLog.print("⚡️ JS Eval error", error!.localizedDescription) + } + }) + } + } + + /** + * Eval JS in the web view + */ + @objc public func eval(js: String) { + DispatchQueue.main.async { + self.getWebView()?.evaluateJavaScript(js, completionHandler: { (_, error) in + if error != nil { + CAPLog.print("⚡️ JS Eval error", error!.localizedDescription) + } + }) + } + } + + @objc public func triggerJSEvent(eventName: String, target: String) { + self.eval(js: "window.Capacitor.triggerEvent('\(eventName)', '\(target)')") + } + + @objc public func triggerJSEvent(eventName: String, target: String, data: String) { + self.eval(js: "window.Capacitor.triggerEvent('\(eventName)', '\(target)', \(data))") + } + + @objc public func triggerWindowJSEvent(eventName: String) { + self.triggerJSEvent(eventName: eventName, target: "window") + } + + @objc public func triggerWindowJSEvent(eventName: String, data: String) { + self.triggerJSEvent(eventName: eventName, target: "window", data: data) + } + + @objc public func triggerDocumentJSEvent(eventName: String) { + self.triggerJSEvent(eventName: eventName, target: "document") + } + + @objc public func triggerDocumentJSEvent(eventName: String, data: String) { + self.triggerJSEvent(eventName: eventName, target: "document", data: data) + } + + public func logToJs(_ message: String, _ level: String = "log") { + DispatchQueue.main.async { + self.getWebView()?.evaluateJavaScript("window.Capacitor.logJs('\(message)', '\(level)')") { (result, error) in + if error != nil && result != nil { + CAPLog.print(result!) + } + } + } + } + + public func getLocalUrl() -> String { + return localUrl! + } + + @objc public func presentVC(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) { + if viewControllerToPresent.modalPresentationStyle == .popover { + self.viewController?.present(viewControllerToPresent, animated: flag, completion: completion) + } else { + self.tmpWindow = UIWindow.init(frame: UIScreen.main.bounds) + self.tmpWindow!.rootViewController = TmpViewController.init() + self.tmpWindow!.makeKeyAndVisible() + self.tmpWindow!.rootViewController!.present(viewControllerToPresent, animated: flag, completion: completion) + } + } + + @objc public func dismissVC(animated flag: Bool, completion: (() -> Void)? = nil) { + if self.tmpWindow == nil { + self.viewController?.dismiss(animated: flag, completion: completion) + } else { + self.tmpWindow!.rootViewController!.dismiss(animated: flag, completion: completion) + self.tmpWindow = nil + } + } + +} diff --git a/ios/Capacitor/Capacitor/JSExport.swift b/ios/Capacitor/Capacitor/JSExport.swift index 2203f3b952..5f4781330a 100644 --- a/ios/Capacitor/Capacitor/JSExport.swift +++ b/ios/Capacitor/Capacitor/JSExport.swift @@ -15,32 +15,32 @@ internal class JSExport { public static func exportCapacitorJS(userContentController: WKUserContentController) throws { guard let jsUrl = Bundle.main.url(forResource: "public/native-bridge", withExtension: "js") else { CAPLog.print("ERROR: Required native-bridge.js file in Capacitor not found. Bridge will not function!") - throw BridgeError.errorExportingCoreJS + throw CapacitorBridgeError.errorExportingCoreJS } do { try self.injectFile(fileURL: jsUrl, userContentController: userContentController) } catch { CAPLog.print("ERROR: Unable to read required native-bridge.js file from the Capacitor framework. Bridge will not function!") - throw BridgeError.errorExportingCoreJS + throw CapacitorBridgeError.errorExportingCoreJS } } public static func exportCordovaJS(userContentController: WKUserContentController) throws { guard let cordovaUrl = Bundle.main.url(forResource: "public/cordova", withExtension: "js") else { CAPLog.print("ERROR: Required cordova.js file not found. Cordova plugins will not function!") - throw BridgeError.errorExportingCoreJS + throw CapacitorBridgeError.errorExportingCoreJS } guard let cordovaPluginsUrl = Bundle.main.url(forResource: "public/cordova_plugins", withExtension: "js") else { CAPLog.print("ERROR: Required cordova_plugins.js file not found. Cordova plugins will not function!") - throw BridgeError.errorExportingCoreJS + throw CapacitorBridgeError.errorExportingCoreJS } do { try self.injectFile(fileURL: cordovaUrl, userContentController: userContentController) try self.injectFile(fileURL: cordovaPluginsUrl, userContentController: userContentController) } catch { CAPLog.print("ERROR: Unable to read required cordova files. Cordova plugins will not function!") - throw BridgeError.errorExportingCoreJS + throw CapacitorBridgeError.errorExportingCoreJS } } From 9f85b8c9ec8eca702066a329e36390060af0b194 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Wed, 14 Oct 2020 17:56:59 -0400 Subject: [PATCH 17/40] `npm run fmt` cleanup. --- .../CAPApplicationDelegateProxy.swift | 9 ++-- ios/Capacitor/Capacitor/CAPBridge.swift | 4 +- .../Capacitor/CAPBridgeProtocol.swift | 46 ++++++++--------- .../Capacitor/CAPNotifications.swift | 2 +- .../CAPUNUserNotificationCenterDelegate.swift | 2 +- ios/Capacitor/Capacitor/CapacitorBridge.swift | 50 +++++++++---------- .../Plugins/LocalNotifications.swift | 2 +- .../CapacitorTests/CapacitorTests.swift | 2 +- 8 files changed, 58 insertions(+), 59 deletions(-) diff --git a/ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift b/ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift index 80cf5d8371..29f90686e5 100644 --- a/ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift +++ b/ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift @@ -1,13 +1,12 @@ - import Foundation @objc(CAPApplicationDelegateProxy) public class ApplicationDelegateProxy: NSObject, UIApplicationDelegate { static let shared = ApplicationDelegateProxy() - + private(set) var lastURL: URL? - - public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { + + public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { NotificationCenter.default.post(name: .capacitorOpenURL, object: [ "url": url, "options": options @@ -16,7 +15,7 @@ public class ApplicationDelegateProxy: NSObject, UIApplicationDelegate { lastURL = url return true } - + public func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { // TODO: Support other types, emit to rest of plugins if userActivity.activityType != NSUserActivityTypeBrowsingWeb || userActivity.webpageURL == nil { diff --git a/ios/Capacitor/Capacitor/CAPBridge.swift b/ios/Capacitor/Capacitor/CAPBridge.swift index 5095ecef15..02665f4c77 100644 --- a/ios/Capacitor/Capacitor/CAPBridge.swift +++ b/ios/Capacitor/Capacitor/CAPBridge.swift @@ -3,11 +3,11 @@ import Foundation @available(*, deprecated, message: "CAPBridge is deprecated. statusBarTappedNotification has been moved to Notification.Name.capacitorStatusBarTapped. Application delegate methods have been moved to ApplicationDelegateProxy.") @objc public class CAPBridge: NSObject { @objc public static let statusBarTappedNotification = Notification(name: .capacitorStatusBarTapped) - + public static func handleOpenUrl(_ url: URL, _ options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool { return ApplicationDelegateProxy.shared.application(UIApplication.shared, open: url, options: options) } - + public static func handleContinueActivity(_ userActivity: NSUserActivity, _ restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { return ApplicationDelegateProxy.shared.application(UIApplication.shared, continue: userActivity, restorationHandler: restorationHandler) } diff --git a/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift b/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift index abafa5b5d1..2b7f863d93 100644 --- a/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift +++ b/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift @@ -14,51 +14,51 @@ import WebKit var statusBarVisible: Bool { get set } var statusBarStyle: UIStatusBarStyle { get set } var statusBarAnimation: UIStatusBarAnimation { get set } - + // MARK: - Deprecated @available(*, deprecated, renamed: "webView") func getWebView() -> WKWebView? - + @available(*, deprecated, renamed: "isSimEnvironment") func isSimulator() -> Bool - + @available(*, deprecated, renamed: "isDevEnvironment") func isDevMode() -> Bool - + @available(*, deprecated, renamed: "statusBarVisible") func getStatusBarVisible() -> Bool - + @available(*, deprecated, renamed: "statusBarStyle") func getStatusBarStyle() -> UIStatusBarStyle - + @available(iOS 12.0, *) @available(*, deprecated, renamed: "userInterfaceStyle") func getUserInterfaceStyle() -> UIUserInterfaceStyle - + @available(*, deprecated, message: "Moved to ApplicationDelegateProxy") func getLastUrl() -> URL? - + // MARK: Call Management func getSavedCall(_ callbackId: String) -> CAPPluginCall? func releaseCall(_ call: CAPPluginCall) func releaseCall(callbackId: String) - + // MARK: JavaScript Handling func evalWithPlugin(_ plugin: CAPPlugin, js: String) func eval(js: String) - + func triggerJSEvent(eventName: String, target: String) func triggerJSEvent(eventName: String, target: String, data: String) - + func triggerWindowJSEvent(eventName: String) func triggerWindowJSEvent(eventName: String, data: String) - + func triggerDocumentJSEvent(eventName: String) func triggerDocumentJSEvent(eventName: String, data: String) - + // MARK: - Logging func print(message: String, for plugin: CAPPlugin) - + // MARK: View Presentation func showAlertWith(title: String, message: String, buttonTitle: String) func presentVC(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)?) @@ -68,7 +68,7 @@ import WebKit /* Extensions to Obj-C protocols are not exposed to Obj-C code because of limitations in the runtime. Therefore these methods are implicitly Swift-only. - + The methods marked as deprecated are here because they can be declared without interfering with the synthesized Obj-C setters for the respective properties (e.g. `setStatusBarVisible:` for 'statusBarVisible`). */ @@ -78,24 +78,24 @@ extension CAPBridgeProtocol { let output = items.map { String(describing: $0) }.joined(separator: " ") print(message: output, for: plugin) } - + // default arguments are not permitted in protocol declarations func alert(_ title: String, _ message: String, _ buttonTitle: String = "OK") { showAlertWith(title: title, message: message, buttonTitle: buttonTitle) } - + @available(*, deprecated, renamed: "statusBarVisible") - public func setStatusBarVisible(_ visible:Bool) { + public func setStatusBarVisible(_ visible: Bool) { statusBarVisible = visible } - + @available(*, deprecated, renamed: "statusBarStyle") - public func setStatusBarStyle(_ style:UIStatusBarStyle) { + public func setStatusBarStyle(_ style: UIStatusBarStyle) { statusBarStyle = style } - + @available(*, deprecated, renamed: "statusBarAnimation") - public func setStatusBarAnimation(_ animation:UIStatusBarAnimation) { + public func setStatusBarAnimation(_ animation: UIStatusBarAnimation) { statusBarAnimation = animation } } @@ -109,7 +109,7 @@ public enum CapacitorBridgeError: Error { } extension CapacitorBridgeError: CustomNSError { - static public var errorDomain: String { "CapacitorBridge" } + public static var errorDomain: String { "CapacitorBridge" } public var errorCode: Int { switch self { case .errorExportingCoreJS: diff --git a/ios/Capacitor/Capacitor/CAPNotifications.swift b/ios/Capacitor/Capacitor/CAPNotifications.swift index c61f06b6e1..b76f262bda 100644 --- a/ios/Capacitor/Capacitor/CAPNotifications.swift +++ b/ios/Capacitor/Capacitor/CAPNotifications.swift @@ -40,7 +40,7 @@ extension Notification.Name { @available(*, deprecated, renamed: "Notification.Name.capacitorDecidePolicyForNavigationAction") case DecidePolicyForNavigationAction // swiftlint:enable identifier_name - + public func name() -> String { switch self { case .URLOpen: diff --git a/ios/Capacitor/Capacitor/CAPUNUserNotificationCenterDelegate.swift b/ios/Capacitor/Capacitor/CAPUNUserNotificationCenterDelegate.swift index 7c2b228d48..cf6a0d62a7 100644 --- a/ios/Capacitor/Capacitor/CAPUNUserNotificationCenterDelegate.swift +++ b/ios/Capacitor/Capacitor/CAPUNUserNotificationCenterDelegate.swift @@ -14,7 +14,7 @@ public class CAPUNUserNotificationCenterDelegate: NSObject, UNUserNotificationCe center.delegate = self } } - + /** * Request permissions to send notifications */ diff --git a/ios/Capacitor/Capacitor/CapacitorBridge.swift b/ios/Capacitor/Capacitor/CapacitorBridge.swift index f99b0b1967..aa961f185e 100644 --- a/ios/Capacitor/Capacitor/CapacitorBridge.swift +++ b/ios/Capacitor/Capacitor/CapacitorBridge.swift @@ -13,13 +13,13 @@ import Cordova //} internal class CapacitorBridge: NSObject, CAPBridgeProtocol { - + // MARK: - CAPBridgeProtocol Properties - + public var webView: WKWebView? { return bridgeDelegate?.bridgedWebView } - + public var isSimEnvironment: Bool { #if targetEnvironment(simulator) return true @@ -27,7 +27,7 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { return false #endif } - + public var isDevEnvironment: Bool { #if DEBUG return true @@ -35,12 +35,12 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { return false #endif } - + @available(iOS 12.0, *) public var userInterfaceStyle: UIUserInterfaceStyle { return viewController?.traitCollection.userInterfaceStyle ?? .unspecified } - + public var statusBarVisible: Bool { get { return !(viewController?.prefersStatusBarHidden ?? true) @@ -51,7 +51,7 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { } } } - + public var statusBarStyle: UIStatusBarStyle { get { return viewController?.preferredStatusBarStyle ?? .default @@ -62,7 +62,7 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { } } } - + public var statusBarAnimation: UIStatusBarAnimation { get { return (viewController as? CAPBridgeViewController)?.statusBarAnimation ?? .slide @@ -73,13 +73,13 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { } } } - + var tmpWindow: UIWindow? static let tmpVCAppeared = Notification(name: Notification.Name(rawValue: "tmpViewControllerAppeared")) public static let capacitorSite = "https://capacitorjs.com/" public static let fileStartIdentifier = "/_capacitor_file_" public static let defaultScheme = "capacitor" - + var messageHandlerWrapper: CAPMessageHandlerWrapper weak var bridgeDelegate: CAPBridgeDelegate? @objc public var viewController: UIViewController? { @@ -136,49 +136,49 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { // the message handler needs to removed to avoid any retain cycles messageHandlerWrapper.cleanUp() } - + // MARK: - Deprecated - + public func getWebView() -> WKWebView? { return webView } - + public func isSimulator() -> Bool { return isSimEnvironment } - + public func isDevMode() -> Bool { return isDevEnvironment } - + public func getStatusBarVisible() -> Bool { return statusBarVisible } - - @nonobjc public func setStatusBarVisible(_ visible:Bool) { + + @nonobjc public func setStatusBarVisible(_ visible: Bool) { statusBarVisible = visible } - + public func getStatusBarStyle() -> UIStatusBarStyle { return statusBarStyle } - @nonobjc public func setStatusBarStyle(_ style:UIStatusBarStyle) { + @nonobjc public func setStatusBarStyle(_ style: UIStatusBarStyle) { statusBarStyle = style } - + @available(iOS 12.0, *) public func getUserInterfaceStyle() -> UIUserInterfaceStyle { return userInterfaceStyle } - - @nonobjc public func setStatusBarAnimation(_ animation:UIStatusBarAnimation) { + + @nonobjc public func setStatusBarAnimation(_ animation: UIStatusBarAnimation) { statusBarAnimation = animation } - + public func getLastUrl() -> URL? { return ApplicationDelegateProxy.shared.lastURL } - + /** * Print a hopefully informative error message to the log when something * particularly dreadful happens. @@ -376,7 +376,7 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { public func print(message: String, for plugin: CAPPlugin) { CAPLog.print("⚡️ ", plugin.pluginId, "-", message) } - + public func showAlertWith(title: String, message: String, buttonTitle: String) { let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert) alert.addAction(UIAlertAction(title: buttonTitle, style: UIAlertAction.Style.default, handler: nil)) diff --git a/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift b/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift index 0579e65338..3aff8eebc2 100644 --- a/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift +++ b/ios/Capacitor/Capacitor/Plugins/LocalNotifications.swift @@ -339,7 +339,7 @@ public class CAPLocalNotificationsPlugin: CAPPlugin { createdCategories.append(generalCategory) for type in actionTypes { guard let type = type as? JSObject else { - continue + continue } guard let id = type["id"] as? String else { bridge?.modulePrint(self, "Action type must have an id field") diff --git a/ios/Capacitor/CapacitorTests/CapacitorTests.swift b/ios/Capacitor/CapacitorTests/CapacitorTests.swift index 8be9150556..01b846835f 100644 --- a/ios/Capacitor/CapacitorTests/CapacitorTests.swift +++ b/ios/Capacitor/CapacitorTests/CapacitorTests.swift @@ -17,7 +17,7 @@ class MockBridge: CAPBridge { } class CapacitorTests: XCTestCase { var bridge: MockBridge? - + override func setUp() { super.setUp() // Put setup code here. This method is called before the invocation of each test method in the class. From 8347c17bdd352b57aa6e46950871d6849cadcdd6 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Wed, 14 Oct 2020 17:57:25 -0400 Subject: [PATCH 18/40] Updating disabled code. --- ios/Capacitor/Capacitor/Plugins/App.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ios/Capacitor/Capacitor/Plugins/App.swift b/ios/Capacitor/Capacitor/Plugins/App.swift index 5875bf1f35..786c972518 100644 --- a/ios/Capacitor/Capacitor/Plugins/App.swift +++ b/ios/Capacitor/Capacitor/Plugins/App.swift @@ -55,12 +55,12 @@ public class CAPAppPlugin: CAPPlugin { } @objc func getLaunchUrl(_ call: CAPPluginCall) { -// if let lastUrl = CAPBridge.getLastUrl() { -// let urlValue = lastUrl.absoluteString -// call.resolve([ -// "url": urlValue -// ]) -// } + if let lastUrl = ApplicationDelegateProxy.shared.lastURL { + let urlValue = lastUrl.absoluteString + call.resolve([ + "url": urlValue + ]) + } call.resolve() } From a194dc77cdbeb8599af9ffa7636a169dc165b717 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Wed, 14 Oct 2020 18:01:08 -0400 Subject: [PATCH 19/40] Enabling mac builds for the verify script. --- ios/Capacitor/Capacitor.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj index 12bfbebe8b..d765553cc8 100644 --- a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj +++ b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj @@ -598,7 +598,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.Capacitor; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = NO; + SUPPORTS_MACCATALYST = YES; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -627,7 +627,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.Capacitor; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = NO; + SUPPORTS_MACCATALYST = YES; SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; From 56ed5c2008fad2d6aebda5be0c3e9a749875f6e0 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Thu, 15 Oct 2020 13:29:30 -0400 Subject: [PATCH 20/40] Project reorganization, addressing lint error. --- .../Capacitor.xcodeproj/project.pbxproj | 38 +++++++++---------- ios/Capacitor/Capacitor/CAPBridge.swift | 3 ++ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj index d765553cc8..ee28d2e5fd 100644 --- a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj +++ b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj @@ -210,36 +210,36 @@ 62959B012524DA7700A3D7F1 /* CAPPlugin.m */, 62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */, 62959B062524DA7700A3D7F1 /* CAPPluginCall.m */, - 620943092527C87D0072A562 /* CAPBridgeProtocol.swift */, - 62C0A97825377AED004384F8 /* CapacitorBridge.swift */, - 62959B142524DA7700A3D7F1 /* CAPBridge.swift */, - 626B289625364A6500FFF7CB /* CAPApplicationDelegateProxy.swift */, + 62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */, 62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */, 62959B092524DA7700A3D7F1 /* CAPPluginMethod.h */, - 62959AE32524DA7700A3D7F1 /* JSExport.swift */, + 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */, 62959B032524DA7700A3D7F1 /* CAPBridgedJSTypes.h */, 62959AE42524DA7700A3D7F1 /* CAPBridgedJSTypes.m */, - 62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */, - 62959AE72524DA7700A3D7F1 /* CAPFile.swift */, - 62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */, - 62959AE92524DA7700A3D7F1 /* UIColor.swift */, - 62959AEA2524DA7700A3D7F1 /* Plugins */, - 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */, + 62959B0C2524DA7700A3D7F1 /* JSTypes.swift */, 62959AFF2524DA7700A3D7F1 /* JS.swift */, - 62959B022524DA7700A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift */, - 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */, + 62959AEA2524DA7700A3D7F1 /* Plugins */, + 62959B142524DA7700A3D7F1 /* CAPBridge.swift */, + 620943092527C87D0072A562 /* CAPBridgeProtocol.swift */, + 62C0A97825377AED004384F8 /* CapacitorBridge.swift */, 62959B052524DA7700A3D7F1 /* CAPConfig.swift */, - 62959B072524DA7700A3D7F1 /* CapacitorExtension.swift */, - 62959B082524DA7700A3D7F1 /* CAPLog.swift */, + 626B289625364A6500FFF7CB /* CAPApplicationDelegateProxy.swift */, + 62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */, 62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */, + 62959AE32524DA7700A3D7F1 /* JSExport.swift */, + 62959AE72524DA7700A3D7F1 /* CAPFile.swift */, + 62959B022524DA7700A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift */, + 62959B082524DA7700A3D7F1 /* CAPLog.swift */, 62959B0B2524DA7700A3D7F1 /* CAPMessageHandlerWrapper.swift */, - 62959B0C2524DA7700A3D7F1 /* JSTypes.swift */, 62959B0D2524DA7700A3D7F1 /* CAPAssetHandler.swift */, + 62959B152524DA7700A3D7F1 /* CAPNotifications.swift */, 62959B0E2524DA7700A3D7F1 /* TmpViewController.swift */, 62959B102524DA7700A3D7F1 /* DocLinks.swift */, + 62959B072524DA7700A3D7F1 /* CapacitorExtension.swift */, + 62959AE92524DA7700A3D7F1 /* UIColor.swift */, 62959B112524DA7700A3D7F1 /* Data+Capacitor.swift */, + 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */, 62959B122524DA7700A3D7F1 /* Info.plist */, - 62959B152524DA7700A3D7F1 /* CAPNotifications.swift */, 62959B8225253A9500A3D7F1 /* Capacitor.modulemap */, ); path = Capacitor; @@ -248,11 +248,11 @@ 62959AEA2524DA7700A3D7F1 /* Plugins */ = { isa = PBXGroup; children = ( + 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */, + 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */, 62959AFB2524DA7700A3D7F1 /* App.swift */, 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */, 62959AEF2524DA7700A3D7F1 /* Console.swift */, - 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */, - 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */, 62959AF12524DA7700A3D7F1 /* Geolocation.swift */, 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */, 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */, diff --git a/ios/Capacitor/Capacitor/CAPBridge.swift b/ios/Capacitor/Capacitor/CAPBridge.swift index 02665f4c77..ff64675cf3 100644 --- a/ios/Capacitor/Capacitor/CAPBridge.swift +++ b/ios/Capacitor/Capacitor/CAPBridge.swift @@ -1,6 +1,9 @@ import Foundation +// the @available compiler directive does not provide an easy way to split apart string literals, so ignore the line length +// swiftlint:disable line_length @available(*, deprecated, message: "CAPBridge is deprecated. statusBarTappedNotification has been moved to Notification.Name.capacitorStatusBarTapped. Application delegate methods have been moved to ApplicationDelegateProxy.") +// swiftlint:enable line_length @objc public class CAPBridge: NSObject { @objc public static let statusBarTappedNotification = Notification(name: .capacitorStatusBarTapped) From 56fe1eacdc69c00c2e088166e81a31913cb02947 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Thu, 15 Oct 2020 17:20:50 -0400 Subject: [PATCH 21/40] Removing redundant name in deprecation message. --- ios/Capacitor/Capacitor/CAPBridge.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Capacitor/Capacitor/CAPBridge.swift b/ios/Capacitor/Capacitor/CAPBridge.swift index ff64675cf3..f339db93ca 100644 --- a/ios/Capacitor/Capacitor/CAPBridge.swift +++ b/ios/Capacitor/Capacitor/CAPBridge.swift @@ -2,7 +2,7 @@ import Foundation // the @available compiler directive does not provide an easy way to split apart string literals, so ignore the line length // swiftlint:disable line_length -@available(*, deprecated, message: "CAPBridge is deprecated. statusBarTappedNotification has been moved to Notification.Name.capacitorStatusBarTapped. Application delegate methods have been moved to ApplicationDelegateProxy.") +@available(*, deprecated, message: "statusBarTappedNotification has been moved to Notification.Name.capacitorStatusBarTapped. Application delegate methods have been moved to ApplicationDelegateProxy.") // swiftlint:enable line_length @objc public class CAPBridge: NSObject { @objc public static let statusBarTappedNotification = Notification(name: .capacitorStatusBarTapped) From 2d69c8e3d488bb6ec35469e5150b007f929c6924 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Thu, 15 Oct 2020 17:22:22 -0400 Subject: [PATCH 22/40] Adding explicit type coercion to ensure conformance to expected protocol. --- ios/Capacitor/Capacitor/JS.swift | 4 +-- ios/Capacitor/Capacitor/JSTypes.swift | 47 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/ios/Capacitor/Capacitor/JS.swift b/ios/Capacitor/Capacitor/JS.swift index 0f33b95c86..9d929fc46b 100644 --- a/ios/Capacitor/Capacitor/JS.swift +++ b/ios/Capacitor/Capacitor/JS.swift @@ -21,13 +21,13 @@ public class JSDate { * A call originating from JavaScript land */ public class JSCall { - public var options: [String: Any] = [:] + public var options: JSObject = [:] public var pluginId: String = "" public var method: String = "" public var callbackId: String = "" public init(options: [String: Any], pluginId: String, method: String, callbackId: String) { - self.options = options + self.options = JSTypes.coerceDictionaryToJSObject(options) ?? [:] self.pluginId = pluginId self.method = method self.callbackId = callbackId diff --git a/ios/Capacitor/Capacitor/JSTypes.swift b/ios/Capacitor/Capacitor/JSTypes.swift index d77e2353b0..25aba4ac4c 100644 --- a/ios/Capacitor/Capacitor/JSTypes.swift +++ b/ios/Capacitor/Capacitor/JSTypes.swift @@ -167,3 +167,50 @@ extension JSValueContainer { static var jsDateFormatter: ISO8601DateFormatter { get } var dictionaryRepresentation: NSDictionary { get } } + +/* + Simply casting objects from foundation class clusters (such as __NSArrayM) + doesn't work with the JSValue protocol and will always fail. So we need to + recursively and explicitly convert each value in the dictionary. + */ +public enum JSTypes {} +extension JSTypes { + public static func coerceDictionaryToJSObject(_ dictionary: NSDictionary?) -> JSObject? { + return coerceToJSValue(dictionary) as? JSObject + } + + public static func coerceDictionaryToJSObject(_ dictionary: [AnyHashable: Any]?) -> JSObject? { + return coerceToJSValue(dictionary) as? JSObject + } +} + +fileprivate func coerceToJSValue(_ value: Any?) -> JSValue? { + guard let value = value else { + return nil + } + switch value { + case let stringValue as String: + return stringValue + case let numberValue as NSNumber: + return numberValue + case let boolValue as Bool: + return boolValue + case let intValue as Int: + return intValue + case let floatValue as Float: + return floatValue + case let doubleValue as Double: + return doubleValue + case let arrayValue as NSArray: + return arrayValue.compactMap { coerceToJSValue($0) } + case let dictionaryValue as NSDictionary: + let keys = dictionaryValue.allKeys.compactMap { $0 as? String } + var result: JSObject = [:] + for key in keys { + result[key] = coerceToJSValue(dictionaryValue[key]) + } + return result + default: + return nil + } +} From 293d17cee88c8fd56fd9732df8c106d5dc093e23 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Thu, 15 Oct 2020 17:24:07 -0400 Subject: [PATCH 23/40] Swiftlint format --- ios/Capacitor/Capacitor/JSTypes.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Capacitor/Capacitor/JSTypes.swift b/ios/Capacitor/Capacitor/JSTypes.swift index 25aba4ac4c..75b9dc1fef 100644 --- a/ios/Capacitor/Capacitor/JSTypes.swift +++ b/ios/Capacitor/Capacitor/JSTypes.swift @@ -184,7 +184,7 @@ extension JSTypes { } } -fileprivate func coerceToJSValue(_ value: Any?) -> JSValue? { +private func coerceToJSValue(_ value: Any?) -> JSValue? { guard let value = value else { return nil } From 28f1eed110f3795cd47e00efea7bf2e02074615e Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Fri, 16 Oct 2020 15:34:26 -0400 Subject: [PATCH 24/40] Reworked CAPLog to prevent race condition between it and CAPConfig. --- ios/Capacitor/Capacitor/CAPLog.swift | 29 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/ios/Capacitor/Capacitor/CAPLog.swift b/ios/Capacitor/Capacitor/CAPLog.swift index 2a91302a3e..4a725d6f83 100644 --- a/ios/Capacitor/Capacitor/CAPLog.swift +++ b/ios/Capacitor/Capacitor/CAPLog.swift @@ -1,19 +1,26 @@ public class CAPLog { - - public static let config = CAPConfig() - + public static var enableLogging: Bool = true + + private static var oneTimeConfigCheck: () -> () = { + // `dispatch_once` is not available since Swift 3. but, since static properties are implicitly lazy, + // this code will only execute once which is sufficient for our needs here. but since we need to do an + // async dispatch, there is a window of time where the default value will be valid before the config + // value(s) can be loaded. + DispatchQueue.main.async { + let config = CAPConfig() + if let configFlag = (config.getValue("ios.hideLogs") as? Bool) ?? (config.getValue("hideLogs") as? Bool) { + enableLogging = !configFlag + } + } + return {} + }() + public static func print(_ items: Any..., separator: String = " ", terminator: String = "\n") { - if !self.hideLogs() { + oneTimeConfigCheck() + if enableLogging { for (itemIndex, item) in items.enumerated() { Swift.print(item, terminator: itemIndex == items.count - 1 ? terminator : separator) } } } - - public static func hideLogs() -> Bool { - if let hideLogs = (config.getValue("ios.hideLogs") as? Bool) ?? (config.getValue("hideLogs") as? Bool) { - return hideLogs - } - return false - } } From 3d92dd0fc2825ec92638d1b481f832856d5a9f24 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Fri, 16 Oct 2020 15:42:11 -0400 Subject: [PATCH 25/40] Adding empty application shell to host framework for unit tests. --- .../Capacitor.xcodeproj/project.pbxproj | 167 +++++++++++++++++- ios/Capacitor/TestsHostApp/AppDelegate.swift | 9 + .../AccentColor.colorset/Contents.json | 11 ++ .../AppIcon.appiconset/Contents.json | 98 ++++++++++ .../Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 +++ .../TestsHostApp/Base.lproj/Main.storyboard | 24 +++ ios/Capacitor/TestsHostApp/Info.plist | 66 +++++++ .../TestsHostApp/ViewController.swift | 9 + 9 files changed, 414 insertions(+), 1 deletion(-) create mode 100644 ios/Capacitor/TestsHostApp/AppDelegate.swift create mode 100644 ios/Capacitor/TestsHostApp/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 ios/Capacitor/TestsHostApp/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 ios/Capacitor/TestsHostApp/Assets.xcassets/Contents.json create mode 100644 ios/Capacitor/TestsHostApp/Base.lproj/LaunchScreen.storyboard create mode 100644 ios/Capacitor/TestsHostApp/Base.lproj/Main.storyboard create mode 100644 ios/Capacitor/TestsHostApp/Info.plist create mode 100644 ios/Capacitor/TestsHostApp/ViewController.swift diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj index 190d5dbcaf..767167af55 100644 --- a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj +++ b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj @@ -49,6 +49,11 @@ 62959B472524DA7800A3D7F1 /* CAPNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959B152524DA7700A3D7F1 /* CAPNotifications.swift */; }; 62959BA52526475A00A3D7F1 /* Cordova.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62959BA02526474300A3D7F1 /* Cordova.framework */; }; 62959BA62526475A00A3D7F1 /* Cordova.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 62959BA02526474300A3D7F1 /* Cordova.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 6296A77E253A2E49005A202A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6296A77D253A2E49005A202A /* AppDelegate.swift */; }; + 6296A782253A2E49005A202A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6296A781253A2E49005A202A /* ViewController.swift */; }; + 6296A785253A2E49005A202A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6296A783253A2E49005A202A /* Main.storyboard */; }; + 6296A787253A2E49005A202A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6296A786253A2E49005A202A /* Assets.xcassets */; }; + 6296A78A253A2E49005A202A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6296A788253A2E49005A202A /* LaunchScreen.storyboard */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -66,6 +71,13 @@ remoteGlobalIDString = 2F5C86DC1FE94845004B09C7; remoteInfo = Cordova; }; + 6296A796253A2EAE005A202A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 50503ED61FC08594003606DC /* Project object */; + proxyType = 1; + remoteGlobalIDString = 6296A77A253A2E49005A202A; + remoteInfo = TestsHostApp; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -129,6 +141,13 @@ 62959B8225253A9500A3D7F1 /* Capacitor.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = Capacitor.modulemap; sourceTree = ""; }; 62959B9B2526474300A3D7F1 /* CapacitorCordova.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CapacitorCordova.xcodeproj; path = ../CapacitorCordova/CapacitorCordova.xcodeproj; sourceTree = ""; }; 62959BBD2526510200A3D7F1 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 6296A77B253A2E49005A202A /* TestsHostApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestsHostApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 6296A77D253A2E49005A202A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 6296A781253A2E49005A202A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 6296A784253A2E49005A202A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 6296A786253A2E49005A202A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 6296A789253A2E49005A202A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 6296A78B253A2E49005A202A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -149,6 +168,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6296A778253A2E49005A202A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -167,6 +193,7 @@ children = ( 62959AE12524DA7700A3D7F1 /* Capacitor */, 50503EEC1FC08595003606DC /* CapacitorTests */, + 6296A77C253A2E49005A202A /* TestsHostApp */, 50503EE01FC08594003606DC /* Products */, 501CBAA51FC0A723009B0D4D /* Frameworks */, ); @@ -177,6 +204,7 @@ children = ( 50503EDF1FC08594003606DC /* Capacitor.framework */, 50503EE81FC08595003606DC /* CapacitorTests.xctest */, + 6296A77B253A2E49005A202A /* TestsHostApp.app */, ); name = Products; sourceTree = ""; @@ -252,6 +280,19 @@ name = Products; sourceTree = ""; }; + 6296A77C253A2E49005A202A /* TestsHostApp */ = { + isa = PBXGroup; + children = ( + 6296A77D253A2E49005A202A /* AppDelegate.swift */, + 6296A781253A2E49005A202A /* ViewController.swift */, + 6296A783253A2E49005A202A /* Main.storyboard */, + 6296A786253A2E49005A202A /* Assets.xcassets */, + 6296A788253A2E49005A202A /* LaunchScreen.storyboard */, + 6296A78B253A2E49005A202A /* Info.plist */, + ); + path = TestsHostApp; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -302,19 +343,37 @@ ); dependencies = ( 50503EEB1FC08595003606DC /* PBXTargetDependency */, + 6296A797253A2EAE005A202A /* PBXTargetDependency */, ); name = CapacitorTests; productName = AvocadoTests; productReference = 50503EE81FC08595003606DC /* CapacitorTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + 6296A77A253A2E49005A202A /* TestsHostApp */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6296A78F253A2E49005A202A /* Build configuration list for PBXNativeTarget "TestsHostApp" */; + buildPhases = ( + 6296A777253A2E49005A202A /* Sources */, + 6296A778253A2E49005A202A /* Frameworks */, + 6296A779253A2E49005A202A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TestsHostApp; + productName = TestsHostApp; + productReference = 6296A77B253A2E49005A202A /* TestsHostApp.app */; + productType = "com.apple.product-type.application"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 50503ED61FC08594003606DC /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 0900; + LastSwiftUpdateCheck = 1200; LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Drifty Co."; TargetAttributes = { @@ -326,6 +385,11 @@ 50503EE71FC08595003606DC = { CreatedOnToolsVersion = 9.0; ProvisioningStyle = Automatic; + TestTargetID = 6296A77A253A2E49005A202A; + }; + 6296A77A253A2E49005A202A = { + CreatedOnToolsVersion = 12.0; + ProvisioningStyle = Automatic; }; }; }; @@ -335,6 +399,7 @@ hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = 50503ED51FC08594003606DC; productRefGroup = 50503EE01FC08594003606DC /* Products */; @@ -349,6 +414,7 @@ targets = ( 50503EDE1FC08594003606DC /* Capacitor */, 50503EE71FC08595003606DC /* CapacitorTests */, + 6296A77A253A2E49005A202A /* TestsHostApp */, ); }; /* End PBXProject section */ @@ -378,6 +444,16 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6296A779253A2E49005A202A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6296A78A253A2E49005A202A /* LaunchScreen.storyboard in Resources */, + 6296A787253A2E49005A202A /* Assets.xcassets in Resources */, + 6296A785253A2E49005A202A /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -427,6 +503,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 6296A777253A2E49005A202A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6296A782253A2E49005A202A /* ViewController.swift in Sources */, + 6296A77E253A2E49005A202A /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -435,8 +520,32 @@ target = 50503EDE1FC08594003606DC /* Capacitor */; targetProxy = 50503EEA1FC08595003606DC /* PBXContainerItemProxy */; }; + 6296A797253A2EAE005A202A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 6296A77A253A2E49005A202A /* TestsHostApp */; + targetProxy = 6296A796253A2EAE005A202A /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ +/* Begin PBXVariantGroup section */ + 6296A783253A2E49005A202A /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 6296A784253A2E49005A202A /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 6296A788253A2E49005A202A /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 6296A789253A2E49005A202A /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ 50503EF11FC08595003606DC /* Debug */ = { isa = XCBuildConfiguration; @@ -620,6 +729,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestsHostApp.app/TestsHostApp"; }; name = Debug; }; @@ -635,6 +745,52 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestsHostApp.app/TestsHostApp"; + }; + name = Release; + }; + 6296A78C253A2E49005A202A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 9YN2HU59K8; + INFOPLIST_FILE = TestsHostApp/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.TestsHostApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 6296A78D253A2E49005A202A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 9YN2HU59K8; + INFOPLIST_FILE = TestsHostApp/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.TestsHostApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; @@ -668,6 +824,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 6296A78F253A2E49005A202A /* Build configuration list for PBXNativeTarget "TestsHostApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6296A78C253A2E49005A202A /* Debug */, + 6296A78D253A2E49005A202A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 50503ED61FC08594003606DC /* Project object */; diff --git a/ios/Capacitor/TestsHostApp/AppDelegate.swift b/ios/Capacitor/TestsHostApp/AppDelegate.swift new file mode 100644 index 0000000000..f8b87fe2d1 --- /dev/null +++ b/ios/Capacitor/TestsHostApp/AppDelegate.swift @@ -0,0 +1,9 @@ +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } +} diff --git a/ios/Capacitor/TestsHostApp/Assets.xcassets/AccentColor.colorset/Contents.json b/ios/Capacitor/TestsHostApp/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000000..eb87897008 --- /dev/null +++ b/ios/Capacitor/TestsHostApp/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ios/Capacitor/TestsHostApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/Capacitor/TestsHostApp/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..9221b9bb1a --- /dev/null +++ b/ios/Capacitor/TestsHostApp/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ios/Capacitor/TestsHostApp/Assets.xcassets/Contents.json b/ios/Capacitor/TestsHostApp/Assets.xcassets/Contents.json new file mode 100644 index 0000000000..73c00596a7 --- /dev/null +++ b/ios/Capacitor/TestsHostApp/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ios/Capacitor/TestsHostApp/Base.lproj/LaunchScreen.storyboard b/ios/Capacitor/TestsHostApp/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000..865e9329f3 --- /dev/null +++ b/ios/Capacitor/TestsHostApp/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Capacitor/TestsHostApp/Base.lproj/Main.storyboard b/ios/Capacitor/TestsHostApp/Base.lproj/Main.storyboard new file mode 100644 index 0000000000..25a763858e --- /dev/null +++ b/ios/Capacitor/TestsHostApp/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Capacitor/TestsHostApp/Info.plist b/ios/Capacitor/TestsHostApp/Info.plist new file mode 100644 index 0000000000..5b531f7b27 --- /dev/null +++ b/ios/Capacitor/TestsHostApp/Info.plist @@ -0,0 +1,66 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/ios/Capacitor/TestsHostApp/ViewController.swift b/ios/Capacitor/TestsHostApp/ViewController.swift new file mode 100644 index 0000000000..ae980e1ea3 --- /dev/null +++ b/ios/Capacitor/TestsHostApp/ViewController.swift @@ -0,0 +1,9 @@ +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + } +} From 2bbcb563ecae83f6c256f4a7df69626d34e21074 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Mon, 19 Oct 2020 14:44:04 -0400 Subject: [PATCH 26/40] Adding unit tests for the type bridging. --- .../Capacitor.xcodeproj/project.pbxproj | 18 ++++ .../CapacitorTests/BridgedTypesTests.swift | 86 +++++++++++++++++++ .../CapacitorTests-Bridging-Header.h | 5 ++ .../CapacitorTests/CapacitorTests.swift | 13 --- .../CapacitorTests/JSONSerializationWrapper.h | 9 ++ .../CapacitorTests/JSONSerializationWrapper.m | 29 +++++++ 6 files changed, 147 insertions(+), 13 deletions(-) create mode 100644 ios/Capacitor/CapacitorTests/BridgedTypesTests.swift create mode 100644 ios/Capacitor/CapacitorTests/CapacitorTests-Bridging-Header.h create mode 100644 ios/Capacitor/CapacitorTests/JSONSerializationWrapper.h create mode 100644 ios/Capacitor/CapacitorTests/JSONSerializationWrapper.m diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj index eab962c0f4..a6871fc2f4 100644 --- a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj +++ b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj @@ -57,6 +57,8 @@ 6296A785253A2E49005A202A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6296A783253A2E49005A202A /* Main.storyboard */; }; 6296A787253A2E49005A202A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6296A786253A2E49005A202A /* Assets.xcassets */; }; 6296A78A253A2E49005A202A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6296A788253A2E49005A202A /* LaunchScreen.storyboard */; }; + 62A02168253A342D00A93582 /* BridgedTypesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62A02167253A342D00A93582 /* BridgedTypesTests.swift */; }; + 62A0216F253A3F8000A93582 /* JSONSerializationWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 62A0216E253A3F8000A93582 /* JSONSerializationWrapper.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -154,6 +156,10 @@ 6296A786253A2E49005A202A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 6296A789253A2E49005A202A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 6296A78B253A2E49005A202A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 62A02167253A342D00A93582 /* BridgedTypesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BridgedTypesTests.swift; sourceTree = ""; }; + 62A0216C253A3F8000A93582 /* CapacitorTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CapacitorTests-Bridging-Header.h"; sourceTree = ""; }; + 62A0216D253A3F8000A93582 /* JSONSerializationWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSONSerializationWrapper.h; sourceTree = ""; }; + 62A0216E253A3F8000A93582 /* JSONSerializationWrapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JSONSerializationWrapper.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -219,7 +225,11 @@ isa = PBXGroup; children = ( 50503EED1FC08595003606DC /* CapacitorTests.swift */, + 62A02167253A342D00A93582 /* BridgedTypesTests.swift */, 62959BBD2526510200A3D7F1 /* Info.plist */, + 62A0216D253A3F8000A93582 /* JSONSerializationWrapper.h */, + 62A0216E253A3F8000A93582 /* JSONSerializationWrapper.m */, + 62A0216C253A3F8000A93582 /* CapacitorTests-Bridging-Header.h */, ); path = CapacitorTests; sourceTree = ""; @@ -394,6 +404,7 @@ }; 50503EE71FC08595003606DC = { CreatedOnToolsVersion = 9.0; + LastSwiftMigration = 1200; ProvisioningStyle = Automatic; TestTargetID = 6296A77A253A2E49005A202A; }; @@ -512,6 +523,8 @@ buildActionMask = 2147483647; files = ( 50503EEE1FC08595003606DC /* CapacitorTests.swift in Sources */, + 62A0216F253A3F8000A93582 /* JSONSerializationWrapper.m in Sources */, + 62A02168253A342D00A93582 /* BridgedTypesTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -733,12 +746,15 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = CapacitorTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.CapacitorTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "CapacitorTests/CapacitorTests-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestsHostApp.app/TestsHostApp"; @@ -749,12 +765,14 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = CapacitorTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.CapacitorTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "CapacitorTests/CapacitorTests-Bridging-Header.h"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestsHostApp.app/TestsHostApp"; diff --git a/ios/Capacitor/CapacitorTests/BridgedTypesTests.swift b/ios/Capacitor/CapacitorTests/BridgedTypesTests.swift new file mode 100644 index 0000000000..873a52f499 --- /dev/null +++ b/ios/Capacitor/CapacitorTests/BridgedTypesTests.swift @@ -0,0 +1,86 @@ +import XCTest + +@testable import Capacitor + +class BridgedTypesTests: XCTestCase { + static var sourceDictionary: [AnyHashable: Any] = [:] + static var resultDictionary: [AnyHashable: Any] = [:] + + var sourceDictionary: [AnyHashable: Any] = [:] + var resultDictionary: [AnyHashable: Any] = [:] + + override class func setUp() { + let subDictionary: [AnyHashable: Any] = ["testIntArray": [0, 1, 2], "testStringArray": ["1", "2", "3"], "testDictionary":["foo":"bar"]] + let dictionary: [AnyHashable: Any] = ["testInt": 1 as Int, "testFloat": Float.pi, "testBool": true as Bool, "testString": "Some string value", "testChild": subDictionary] + sourceDictionary = dictionary + let serializer = JSONSerializationWrapper(dictionary: sourceDictionary)! + resultDictionary = serializer.unwrappedResult()! + } + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + sourceDictionary = BridgedTypesTests.sourceDictionary + resultDictionary = BridgedTypesTests.resultDictionary + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testTranslation() throws { + XCTAssertNotNil(sourceDictionary) + XCTAssertNotNil(resultDictionary) + } + + func testCastingFailure() throws { + var castResult = resultDictionary as? JSObject + XCTAssertNil(castResult) + + castResult = sourceDictionary as? JSObject + XCTAssertNil(castResult) + } + + func testCoercionSuccess() throws { + let coercedResult = JSTypes.coerceDictionaryToJSObject(resultDictionary) + XCTAssertNotNil(coercedResult) + } + + func testRoundtripEquality() throws { + let coercedResult = JSTypes.coerceDictionaryToJSObject(resultDictionary)! + let foo: NSDictionary = coercedResult as NSDictionary + let bar: NSDictionary = sourceDictionary as NSDictionary + + XCTAssertEqual(foo, bar) + } + + func testTypeEquavalency() throws { + let coercedResult = JSTypes.coerceDictionaryToJSObject(resultDictionary)! + let coercedFloat = coercedResult["testFloat"] as? Float + let sourceFloat = sourceDictionary["testFloat"] as? Float + let resultFloat = resultDictionary["testFloat"] as? Float + + XCTAssertNotNil(coercedFloat) + XCTAssertNotNil(sourceFloat) + XCTAssertNotNil(resultFloat) + + XCTAssertEqual(coercedFloat, sourceFloat) + XCTAssertEqual(sourceFloat, resultFloat) + XCTAssertEqual(coercedFloat, Float.pi) + } + + func testNumberWrapping() throws { + // the original number is a swift primitive float + let sourceFloat = sourceDictionary["testFloat"]! + XCTAssertTrue(type(of: sourceFloat) == Float.self) + + // but after serialization/deserilization, it will be wrapped as an NSNumber + let wrappedFloat = resultDictionary["testFloat"]! + let underlyingType: AnyObject.Type = NSClassFromString("__NSCFNumber")! + XCTAssertTrue(type(of: wrappedFloat) == underlyingType.self) + + // coercision will keep the NSNumber type since there's no way to recover it + let coercedResult = JSTypes.coerceDictionaryToJSObject(resultDictionary)! + let coercedFloat = coercedResult["testFloat"]! + XCTAssertTrue(type(of: coercedFloat) == underlyingType.self) + } +} diff --git a/ios/Capacitor/CapacitorTests/CapacitorTests-Bridging-Header.h b/ios/Capacitor/CapacitorTests/CapacitorTests-Bridging-Header.h new file mode 100644 index 0000000000..b0f308df84 --- /dev/null +++ b/ios/Capacitor/CapacitorTests/CapacitorTests-Bridging-Header.h @@ -0,0 +1,5 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +#import "JSONSerializationWrapper.h" diff --git a/ios/Capacitor/CapacitorTests/CapacitorTests.swift b/ios/Capacitor/CapacitorTests/CapacitorTests.swift index 8be9150556..79bdc26f2d 100644 --- a/ios/Capacitor/CapacitorTests/CapacitorTests.swift +++ b/ios/Capacitor/CapacitorTests/CapacitorTests.swift @@ -28,17 +28,4 @@ class CapacitorTests: XCTestCase { // 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/ios/Capacitor/CapacitorTests/JSONSerializationWrapper.h b/ios/Capacitor/CapacitorTests/JSONSerializationWrapper.h new file mode 100644 index 0000000000..860eb3b341 --- /dev/null +++ b/ios/Capacitor/CapacitorTests/JSONSerializationWrapper.h @@ -0,0 +1,9 @@ +#import + +@interface JSONSerializationWrapper : NSObject +@property (nonatomic, strong) NSDictionary* _Nonnull dictionary; + +- (instancetype _Nullable)initWithDictionary:(NSDictionary* _Nonnull)options; +- (NSDictionary * _Nullable)unwrappedResult; + +@end diff --git a/ios/Capacitor/CapacitorTests/JSONSerializationWrapper.m b/ios/Capacitor/CapacitorTests/JSONSerializationWrapper.m new file mode 100644 index 0000000000..8965ae0270 --- /dev/null +++ b/ios/Capacitor/CapacitorTests/JSONSerializationWrapper.m @@ -0,0 +1,29 @@ + +#import "JSONSerializationWrapper.h" + +@implementation JSONSerializationWrapper + +- (instancetype)initWithDictionary:(NSDictionary *)dictionary { + self = [super init]; + if (self != nil) { + _dictionary = dictionary; + } + return self; +} + +- (NSDictionary *)unwrappedResult { + NSError* error = nil; + NSData* serializedData = [NSJSONSerialization dataWithJSONObject:[self dictionary] options:NSJSONWritingPrettyPrinted error:&error]; + if (serializedData != nil) { + NSString* output = [[NSString alloc] initWithData:serializedData encoding:NSUTF8StringEncoding]; + NSLog(@"%@",output); + + + + NSDictionary* result = [NSJSONSerialization JSONObjectWithData:serializedData options:0 error:&error]; + return result; + } + return nil; +} + +@end From 84cb33aa7534bb7603fd4a5f6bcffd62b033084c Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Mon, 19 Oct 2020 14:48:26 -0400 Subject: [PATCH 27/40] Removing deleted file. --- ios/Capacitor/Capacitor.xcodeproj/project.pbxproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj index a6871fc2f4..bbd01c8318 100644 --- a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj +++ b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj @@ -28,7 +28,6 @@ 62959B282524DA7800A3D7F1 /* BackgroundTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */; }; 62959B292524DA7800A3D7F1 /* SplashScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */; }; 62959B2C2524DA7800A3D7F1 /* LocalNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */; }; - 62959B2D2524DA7800A3D7F1 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFB2524DA7700A3D7F1 /* App.swift */; }; 62959B2F2524DA7800A3D7F1 /* DefaultPlugins.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */; }; 62959B302524DA7800A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */; }; 62959B312524DA7800A3D7F1 /* JS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFF2524DA7700A3D7F1 /* JS.swift */; }; @@ -122,7 +121,6 @@ 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundTask.swift; sourceTree = ""; }; 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SplashScreen.swift; sourceTree = ""; }; 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalNotifications.swift; sourceTree = ""; }; - 62959AFB2524DA7700A3D7F1 /* App.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = ""; }; 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DefaultPlugins.m; sourceTree = ""; }; 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIStatusBarManager+CAPHandleTapAction.m"; sourceTree = ""; }; 62959AFF2524DA7700A3D7F1 /* JS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JS.swift; sourceTree = ""; }; @@ -277,7 +275,6 @@ 62959AEA2524DA7700A3D7F1 /* Plugins */ = { isa = PBXGroup; children = ( - 62959AFB2524DA7700A3D7F1 /* App.swift */, 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */, 62959AEF2524DA7700A3D7F1 /* Console.swift */, 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */, @@ -507,7 +504,6 @@ 620850362538A409003BC41B /* JSTypes.swift in Sources */, 62959B422524DA7800A3D7F1 /* DocLinks.swift in Sources */, 62959B172524DA7800A3D7F1 /* JSExport.swift in Sources */, - 62959B2D2524DA7800A3D7F1 /* App.swift in Sources */, 62959B3F2524DA7800A3D7F1 /* CAPAssetHandler.swift in Sources */, 62959B3C2524DA7800A3D7F1 /* CAPBridgeDelegate.swift in Sources */, 62959B2C2524DA7800A3D7F1 /* LocalNotifications.swift in Sources */, From 32bfa11ba4b514233861bed13b48b42e5f2ae40f Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Mon, 19 Oct 2020 15:14:06 -0400 Subject: [PATCH 28/40] Adding swift lint config file to exclude tests and host app from linting rules --- ios/Capacitor/.swiftlint.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 ios/Capacitor/.swiftlint.yml diff --git a/ios/Capacitor/.swiftlint.yml b/ios/Capacitor/.swiftlint.yml new file mode 100644 index 0000000000..fcd0fc56cc --- /dev/null +++ b/ios/Capacitor/.swiftlint.yml @@ -0,0 +1,3 @@ +excluded: +- CapacitorTests +- TestsHostApp From e5c8bc70a433eac5ae5dd3f6195a11e87a84e67e Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Mon, 19 Oct 2020 17:26:32 -0400 Subject: [PATCH 29/40] Updating tests. --- ios/Capacitor/CapacitorTests/CapacitorTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/Capacitor/CapacitorTests/CapacitorTests.swift b/ios/Capacitor/CapacitorTests/CapacitorTests.swift index 5a44b46ea8..290003af8d 100644 --- a/ios/Capacitor/CapacitorTests/CapacitorTests.swift +++ b/ios/Capacitor/CapacitorTests/CapacitorTests.swift @@ -10,9 +10,9 @@ class MockBridgeMessageHandler: CAPMessageHandlerWrapper { class MockConfig: CAPConfig { } -class MockBridge: CAPBridge { +class MockBridge: CapacitorBridge { override public func registerPlugins() { - print("REGISTER PLUGINS") + Swift.print("REGISTER PLUGINS") } } class CapacitorTests: XCTestCase { From a0e5e24c968a906fa8fff5280d696a8749419e8f Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Mon, 19 Oct 2020 17:28:37 -0400 Subject: [PATCH 30/40] Removing reference to deleted file. --- ios/Capacitor/Capacitor.xcodeproj/project.pbxproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj index 767167af55..f525aac0fd 100644 --- a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj +++ b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj @@ -25,7 +25,6 @@ 62959B282524DA7800A3D7F1 /* BackgroundTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */; }; 62959B292524DA7800A3D7F1 /* SplashScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */; }; 62959B2C2524DA7800A3D7F1 /* LocalNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */; }; - 62959B2D2524DA7800A3D7F1 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFB2524DA7700A3D7F1 /* App.swift */; }; 62959B2F2524DA7800A3D7F1 /* DefaultPlugins.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */; }; 62959B302524DA7800A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */; }; 62959B312524DA7800A3D7F1 /* JS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AFF2524DA7700A3D7F1 /* JS.swift */; }; @@ -114,7 +113,6 @@ 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundTask.swift; sourceTree = ""; }; 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SplashScreen.swift; sourceTree = ""; }; 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalNotifications.swift; sourceTree = ""; }; - 62959AFB2524DA7700A3D7F1 /* App.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = ""; }; 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DefaultPlugins.m; sourceTree = ""; }; 62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIStatusBarManager+CAPHandleTapAction.m"; sourceTree = ""; }; 62959AFF2524DA7700A3D7F1 /* JS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JS.swift; sourceTree = ""; }; @@ -258,7 +256,6 @@ 62959AEA2524DA7700A3D7F1 /* Plugins */ = { isa = PBXGroup; children = ( - 62959AFB2524DA7700A3D7F1 /* App.swift */, 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */, 62959AEF2524DA7700A3D7F1 /* Console.swift */, 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */, @@ -484,7 +481,6 @@ 62959B3D2524DA7800A3D7F1 /* CAPMessageHandlerWrapper.swift in Sources */, 62959B422524DA7800A3D7F1 /* DocLinks.swift in Sources */, 62959B172524DA7800A3D7F1 /* JSExport.swift in Sources */, - 62959B2D2524DA7800A3D7F1 /* App.swift in Sources */, 62959B3F2524DA7800A3D7F1 /* CAPAssetHandler.swift in Sources */, 62959B3C2524DA7800A3D7F1 /* CAPBridgeDelegate.swift in Sources */, 62959B2C2524DA7800A3D7F1 /* LocalNotifications.swift in Sources */, From 90166dd1d557cd4db2303b65259785aeb206c62d Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Mon, 19 Oct 2020 18:04:54 -0400 Subject: [PATCH 31/40] Updating `getLastUrl` call. --- ios/Capacitor/Capacitor/CAPBridge.swift | 8 ++++++-- ios/Capacitor/Capacitor/CAPBridgeProtocol.swift | 3 --- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ios/Capacitor/Capacitor/CAPBridge.swift b/ios/Capacitor/Capacitor/CAPBridge.swift index f339db93ca..4b6377ac3b 100644 --- a/ios/Capacitor/Capacitor/CAPBridge.swift +++ b/ios/Capacitor/Capacitor/CAPBridge.swift @@ -2,11 +2,15 @@ import Foundation // the @available compiler directive does not provide an easy way to split apart string literals, so ignore the line length // swiftlint:disable line_length -@available(*, deprecated, message: "statusBarTappedNotification has been moved to Notification.Name.capacitorStatusBarTapped. Application delegate methods have been moved to ApplicationDelegateProxy.") +@available(*, deprecated, message: "'statusBarTappedNotification' has been moved to Notification.Name.capacitorStatusBarTapped. 'getLastUrl' and application delegate methods have been moved to ApplicationDelegateProxy.") // swiftlint:enable line_length @objc public class CAPBridge: NSObject { @objc public static let statusBarTappedNotification = Notification(name: .capacitorStatusBarTapped) - + + public static func getLastUrl() -> URL? { + return ApplicationDelegateProxy.shared.lastURL + } + public static func handleOpenUrl(_ url: URL, _ options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool { return ApplicationDelegateProxy.shared.application(UIApplication.shared, open: url, options: options) } diff --git a/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift b/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift index 2b7f863d93..7948d0c28f 100644 --- a/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift +++ b/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift @@ -35,9 +35,6 @@ import WebKit @available(*, deprecated, renamed: "userInterfaceStyle") func getUserInterfaceStyle() -> UIUserInterfaceStyle - @available(*, deprecated, message: "Moved to ApplicationDelegateProxy") - func getLastUrl() -> URL? - // MARK: Call Management func getSavedCall(_ callbackId: String) -> CAPPluginCall? func releaseCall(_ call: CAPPluginCall) From 14f63211b40933488f15391e2a391349cfbb590e Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Mon, 19 Oct 2020 18:07:21 -0400 Subject: [PATCH 32/40] Restoring missed file from merge. --- .../src/main/java/com/getcapacitor/App.java | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 android/capacitor/src/main/java/com/getcapacitor/App.java diff --git a/android/capacitor/src/main/java/com/getcapacitor/App.java b/android/capacitor/src/main/java/com/getcapacitor/App.java new file mode 100644 index 0000000000..9b12dfa523 --- /dev/null +++ b/android/capacitor/src/main/java/com/getcapacitor/App.java @@ -0,0 +1,89 @@ +package com.getcapacitor; + +import androidx.annotation.Nullable; + +public class App { + + /** + * Interface for callbacks when app status changes. + */ + public interface AppStatusChangeListener { + void onAppStatusChanged(Boolean isActive); + } + + /** + * Interface for callbacks when back button is pressed. + */ + public interface BackButtonListener { + void onBackButton(); + } + + /** + * Interface for callbacks when app is restored with pending plugin call. + */ + public interface AppRestoredListener { + void onAppRestored(PluginResult result); + } + + @Nullable + private AppStatusChangeListener statusChangeListener; + + @Nullable + private BackButtonListener backButtonListener; + + @Nullable + private AppRestoredListener appRestoredListener; + + private boolean isActive = false; + + public boolean isActive() { + return isActive; + } + + /** + * Set the object to receive callbacks. + * @param listener + */ + public void setStatusChangeListener(@Nullable AppStatusChangeListener listener) { + this.statusChangeListener = listener; + } + + /** + * Set the object to receive callbacks. + * @param listener + */ + public void setBackButtonListener(@Nullable BackButtonListener listener) { + this.backButtonListener = listener; + } + + /** + * Set the object to receive callbacks. + * @param listener + */ + public void setAppRestoredListener(@Nullable AppRestoredListener listener) { + this.appRestoredListener = listener; + } + + protected void fireRestoredResult(PluginResult result) { + if (appRestoredListener != null) { + appRestoredListener.onAppRestored(result); + } + } + + public void fireStatusChange(boolean isActive) { + this.isActive = isActive; + if (statusChangeListener != null) { + statusChangeListener.onAppStatusChanged(isActive); + } + } + + public void fireBackButton() { + if (backButtonListener != null) { + backButtonListener.onBackButton(); + } + } + + public boolean hasBackButtonListeners() { + return backButtonListener != null; + } +} From e4c4dc4ae9d0b7961c7e31a349d58fee97d52d33 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Mon, 19 Oct 2020 18:13:51 -0400 Subject: [PATCH 33/40] Cleanup and organization. --- ios/Capacitor/Capacitor/CapacitorBridge.swift | 124 +++++++++--------- 1 file changed, 65 insertions(+), 59 deletions(-) diff --git a/ios/Capacitor/Capacitor/CapacitorBridge.swift b/ios/Capacitor/Capacitor/CapacitorBridge.swift index d47e6d2147..71f3811b87 100644 --- a/ios/Capacitor/Capacitor/CapacitorBridge.swift +++ b/ios/Capacitor/Capacitor/CapacitorBridge.swift @@ -8,13 +8,9 @@ import Dispatch import WebKit import Cordova -//enum BridgeError: Error { -// case errorExportingCoreJS -//} - internal class CapacitorBridge: NSObject, CAPBridgeProtocol { - // MARK: - CAPBridgeProtocol Properties + // MARK: - CAPBridgeProtocol: Properties public var webView: WKWebView? { return bridgeDelegate?.bridgedWebView @@ -108,33 +104,8 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { var dispatchQueue = DispatchQueue(label: "bridge") public var notificationDelegationHandler: CAPUNUserNotificationCenterDelegate - - init(_ bridgeDelegate: CAPBridgeDelegate, _ messageHandlerWrapper: CAPMessageHandlerWrapper, _ config: CAPConfig, _ scheme: String) { - self.bridgeDelegate = bridgeDelegate - self.messageHandlerWrapper = messageHandlerWrapper - self.notificationDelegationHandler = CAPUNUserNotificationCenterDelegate() - self.config = config - self.scheme = scheme - - super.init() - - self.messageHandlerWrapper.bridge = self - self.notificationDelegationHandler.bridge = self - localUrl = "\(self.scheme)://\(config.getString("server.hostname") ?? "localhost")" - exportCoreJS(localUrl: localUrl!) - registerPlugins() - setupCordovaCompatibility() - NotificationCenter.default.addObserver(forName: type(of: self).tmpVCAppeared.name, object: .none, queue: .none) { [weak self] _ in - self?.tmpWindow = nil - } - } - - deinit { - // the message handler needs to removed to avoid any retain cycles - messageHandlerWrapper.cleanUp() - } - - // MARK: - Deprecated + + // MARK: - CAPBridgeProtocol: Deprecated public func getWebView() -> WKWebView? { return webView @@ -171,11 +142,9 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { @nonobjc public func setStatusBarAnimation(_ animation: UIStatusBarAnimation) { statusBarAnimation = animation } - - public func getLastUrl() -> URL? { - return ApplicationDelegateProxy.shared.lastURL - } - + + // MARK: - Static Methods + /** * Print a hopefully informative error message to the log when something * particularly dreadful happens. @@ -197,6 +166,35 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { CAPLog.print("⚡️ ❌ Please verify your installation or file an issue") } + + // MARK: - Initialization + + init(_ bridgeDelegate: CAPBridgeDelegate, _ messageHandlerWrapper: CAPMessageHandlerWrapper, _ config: CAPConfig, _ scheme: String) { + self.bridgeDelegate = bridgeDelegate + self.messageHandlerWrapper = messageHandlerWrapper + self.notificationDelegationHandler = CAPUNUserNotificationCenterDelegate() + self.config = config + self.scheme = scheme + + super.init() + + self.messageHandlerWrapper.bridge = self + self.notificationDelegationHandler.bridge = self + localUrl = "\(self.scheme)://\(config.getString("server.hostname") ?? "localhost")" + exportCoreJS(localUrl: localUrl!) + registerPlugins() + setupCordovaCompatibility() + NotificationCenter.default.addObserver(forName: type(of: self).tmpVCAppeared.name, object: .none, queue: .none) { [weak self] _ in + self?.tmpWindow = nil + } + } + + deinit { + // the message handler needs to removed to avoid any retain cycles + messageHandlerWrapper.cleanUp() + } + + // MARK: - Plugins /** * Export core JavaScript to the webview */ @@ -277,18 +275,18 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { * - parameter pluginId: the ID of the plugin * - returns: the plugin, if found */ - public func getOrLoadPlugin(pluginName: String) -> CAPPlugin? { + func getOrLoadPlugin(pluginName: String) -> CAPPlugin? { guard let plugin = self.getPlugin(pluginName: pluginName) ?? self.loadPlugin(pluginName: pluginName) else { return nil } return plugin } - public func getPlugin(pluginName: String) -> CAPPlugin? { + func getPlugin(pluginName: String) -> CAPPlugin? { return self.plugins[pluginName] } - public func loadPlugin(pluginName: String) -> CAPPlugin? { + func loadPlugin(pluginName: String) -> CAPPlugin? { guard let pluginType = knownPlugins[pluginName], let bridgeType = pluginType as? CAPBridgedPlugin.Type else { CAPLog.print("⚡️ Unable to load plugin \(pluginName). No such module found.") return nil @@ -303,7 +301,9 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { func savePluginCall(_ call: CAPPluginCall) { storedCalls[call.callbackId] = call } - + + // MARK: - CAPBridgeProtocol: Call Management + @objc public func getSavedCall(_ callbackId: String) -> CAPPluginCall? { return storedCalls[callbackId] } @@ -316,7 +316,7 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { storedCalls.removeValue(forKey: callbackId) } - public func getDispatchQueue() -> DispatchQueue { + func getDispatchQueue() -> DispatchQueue { return self.dispatchQueue } @@ -337,20 +337,10 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { } } - public func reload() { + func reload() { self.getWebView()?.reload() } - public func print(message: String, for plugin: CAPPlugin) { - CAPLog.print("⚡️ ", plugin.pluginId, "-", message) - } - - public func showAlertWith(title: String, message: String, buttonTitle: String) { - let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert) - alert.addAction(UIAlertAction(title: buttonTitle, style: UIAlertAction.Style.default, handler: nil)) - self.viewController?.present(alert, animated: true, completion: nil) - } - func docLink(_ url: String) -> String { return "\(type(of: self).capacitorSite)docs/\(url)" } @@ -359,7 +349,7 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { * Handle a call from JavaScript. First, find the corresponding plugin, * construct a selector, and perform that selector on the plugin instance. */ - public func handleJSCall(call: JSCall) { + func handleJSCall(call: JSCall) { guard let plugin = self.getPlugin(pluginName: call.pluginId) ?? self.loadPlugin(pluginName: call.pluginId) else { CAPLog.print("⚡️ Error loading plugin \(call.pluginId) for call. Check that the pluginId is correct") return @@ -420,7 +410,7 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { * Handle a Cordova call from JavaScript. First, find the corresponding plugin, * construct a selector, and perform that selector on the plugin instance. */ - public func handleCordovaJSCall(call: JSCall) { + func handleCordovaJSCall(call: JSCall) { // Create a selector to send to the plugin if let plugin = self.cordovaPluginManager?.getCommandInstance(call.pluginId.lowercased()) { @@ -444,7 +434,7 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { /** * Send a successful result to the JavaScript layer. */ - public func toJs(result: JSResult, save: Bool) { + func toJs(result: JSResult, save: Bool) { let resultJson = result.toJson() CAPLog.print("⚡️ TO JS", resultJson.prefix(256)) @@ -469,7 +459,7 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { /** * Send an error result to the JavaScript layer. */ - public func toJsError(error: JSResultError) { + func toJsError(error: JSResultError) { DispatchQueue.main.async { self.getWebView()?.evaluateJavaScript("window.Capacitor.fromNative({ callbackId: '\(error.call.callbackId)', pluginId: '\(error.call.pluginId)', methodName: '\(error.call.method)', success: false, error: \(error.toJson())})") { (result, error) in if error != nil && result != nil { @@ -478,7 +468,9 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { } } } - + + // MARK: - CAPBridgeProtocol: JavaScript Handling + /** * Eval JS for a specific plugin. */ @@ -549,7 +541,21 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { public func getLocalUrl() -> String { return localUrl! } - + + // MARK: - CAPBridgeProtocol: Logging + + public func print(message: String, for plugin: CAPPlugin) { + CAPLog.print("⚡️ ", plugin.pluginId, "-", message) + } + + // MARK: - CAPBridgeProtocol: View Presentation + + @objc public func showAlertWith(title: String, message: String, buttonTitle: String) { + let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert) + alert.addAction(UIAlertAction(title: buttonTitle, style: UIAlertAction.Style.default, handler: nil)) + self.viewController?.present(alert, animated: true, completion: nil) + } + @objc public func presentVC(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) { if viewControllerToPresent.modalPresentationStyle == .popover { self.viewController?.present(viewControllerToPresent, animated: flag, completion: completion) From b9e996985c0c692bc4e10f27b5521a78dcda333c Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Wed, 21 Oct 2020 13:16:30 -0400 Subject: [PATCH 34/40] Removing deleted file reference. --- ios/Capacitor/Capacitor.xcodeproj/project.pbxproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj index f525aac0fd..2595c9c9a4 100644 --- a/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj +++ b/ios/Capacitor/Capacitor.xcodeproj/project.pbxproj @@ -19,7 +19,6 @@ 62959B1D2524DA7800A3D7F1 /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AE92524DA7700A3D7F1 /* UIColor.swift */; }; 62959B222524DA7800A3D7F1 /* Console.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AEF2524DA7700A3D7F1 /* Console.swift */; }; 62959B232524DA7800A3D7F1 /* DefaultPlugins.h in Headers */ = {isa = PBXBuildFile; fileRef = 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */; }; - 62959B242524DA7800A3D7F1 /* Geolocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF12524DA7700A3D7F1 /* Geolocation.swift */; }; 62959B252524DA7800A3D7F1 /* PushNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */; }; 62959B262524DA7800A3D7F1 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF32524DA7700A3D7F1 /* WebView.swift */; }; 62959B282524DA7800A3D7F1 /* BackgroundTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */; }; @@ -107,7 +106,6 @@ 62959AE92524DA7700A3D7F1 /* UIColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIColor.swift; sourceTree = ""; }; 62959AEF2524DA7700A3D7F1 /* Console.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Console.swift; sourceTree = ""; }; 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultPlugins.h; sourceTree = ""; }; - 62959AF12524DA7700A3D7F1 /* Geolocation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Geolocation.swift; sourceTree = ""; }; 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PushNotifications.swift; sourceTree = ""; }; 62959AF32524DA7700A3D7F1 /* WebView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = ""; }; 62959AF52524DA7700A3D7F1 /* BackgroundTask.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BackgroundTask.swift; sourceTree = ""; }; @@ -260,7 +258,6 @@ 62959AEF2524DA7700A3D7F1 /* Console.swift */, 62959AF02524DA7700A3D7F1 /* DefaultPlugins.h */, 62959AFD2524DA7700A3D7F1 /* DefaultPlugins.m */, - 62959AF12524DA7700A3D7F1 /* Geolocation.swift */, 62959AFA2524DA7700A3D7F1 /* LocalNotifications.swift */, 62959AF22524DA7700A3D7F1 /* PushNotifications.swift */, 62959AF62524DA7700A3D7F1 /* SplashScreen.swift */, @@ -469,7 +466,6 @@ 62959B282524DA7800A3D7F1 /* BackgroundTask.swift in Sources */, 62959B332524DA7800A3D7F1 /* CAPPlugin.m in Sources */, 62959B1C2524DA7800A3D7F1 /* CAPPluginMethod.m in Sources */, - 62959B242524DA7800A3D7F1 /* Geolocation.swift in Sources */, 62959B342524DA7800A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift in Sources */, 62959B472524DA7800A3D7F1 /* CAPNotifications.swift in Sources */, 62959B312524DA7800A3D7F1 /* JS.swift in Sources */, From 91ffe8b891e6528935b78bef87aec9943e723659 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Thu, 22 Oct 2020 14:53:50 -0400 Subject: [PATCH 35/40] Revert "Reworked CAPLog to prevent race condition between it and CAPConfig." This reverts commit 28f1eed110f3795cd47e00efea7bf2e02074615e. --- ios/Capacitor/Capacitor/CAPLog.swift | 29 +++++++++++----------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/ios/Capacitor/Capacitor/CAPLog.swift b/ios/Capacitor/Capacitor/CAPLog.swift index 4a725d6f83..2a91302a3e 100644 --- a/ios/Capacitor/Capacitor/CAPLog.swift +++ b/ios/Capacitor/Capacitor/CAPLog.swift @@ -1,26 +1,19 @@ public class CAPLog { - public static var enableLogging: Bool = true - - private static var oneTimeConfigCheck: () -> () = { - // `dispatch_once` is not available since Swift 3. but, since static properties are implicitly lazy, - // this code will only execute once which is sufficient for our needs here. but since we need to do an - // async dispatch, there is a window of time where the default value will be valid before the config - // value(s) can be loaded. - DispatchQueue.main.async { - let config = CAPConfig() - if let configFlag = (config.getValue("ios.hideLogs") as? Bool) ?? (config.getValue("hideLogs") as? Bool) { - enableLogging = !configFlag - } - } - return {} - }() - + + public static let config = CAPConfig() + public static func print(_ items: Any..., separator: String = " ", terminator: String = "\n") { - oneTimeConfigCheck() - if enableLogging { + if !self.hideLogs() { for (itemIndex, item) in items.enumerated() { Swift.print(item, terminator: itemIndex == items.count - 1 ? terminator : separator) } } } + + public static func hideLogs() -> Bool { + if let hideLogs = (config.getValue("ios.hideLogs") as? Bool) ?? (config.getValue("hideLogs") as? Bool) { + return hideLogs + } + return false + } } From 60a9cb120972fa65ddba6bf6a67d7d623c6dffdd Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Thu, 22 Oct 2020 14:54:15 -0400 Subject: [PATCH 36/40] Revert "Reworked CAPLog to prevent race condition between it and CAPConfig." This reverts commit 28f1eed110f3795cd47e00efea7bf2e02074615e. --- ios/Capacitor/Capacitor/CAPLog.swift | 29 +++++++++++----------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/ios/Capacitor/Capacitor/CAPLog.swift b/ios/Capacitor/Capacitor/CAPLog.swift index 4a725d6f83..2a91302a3e 100644 --- a/ios/Capacitor/Capacitor/CAPLog.swift +++ b/ios/Capacitor/Capacitor/CAPLog.swift @@ -1,26 +1,19 @@ public class CAPLog { - public static var enableLogging: Bool = true - - private static var oneTimeConfigCheck: () -> () = { - // `dispatch_once` is not available since Swift 3. but, since static properties are implicitly lazy, - // this code will only execute once which is sufficient for our needs here. but since we need to do an - // async dispatch, there is a window of time where the default value will be valid before the config - // value(s) can be loaded. - DispatchQueue.main.async { - let config = CAPConfig() - if let configFlag = (config.getValue("ios.hideLogs") as? Bool) ?? (config.getValue("hideLogs") as? Bool) { - enableLogging = !configFlag - } - } - return {} - }() - + + public static let config = CAPConfig() + public static func print(_ items: Any..., separator: String = " ", terminator: String = "\n") { - oneTimeConfigCheck() - if enableLogging { + if !self.hideLogs() { for (itemIndex, item) in items.enumerated() { Swift.print(item, terminator: itemIndex == items.count - 1 ? terminator : separator) } } } + + public static func hideLogs() -> Bool { + if let hideLogs = (config.getValue("ios.hideLogs") as? Bool) ?? (config.getValue("hideLogs") as? Bool) { + return hideLogs + } + return false + } } From b72720a3fccfb22fd8c9d2cbd44424ff524208b9 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Thu, 22 Oct 2020 14:57:16 -0400 Subject: [PATCH 37/40] Deleting extraneous log statement in test. --- ios/Capacitor/CapacitorTests/JSONSerializationWrapper.m | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ios/Capacitor/CapacitorTests/JSONSerializationWrapper.m b/ios/Capacitor/CapacitorTests/JSONSerializationWrapper.m index 8965ae0270..6316c9c88b 100644 --- a/ios/Capacitor/CapacitorTests/JSONSerializationWrapper.m +++ b/ios/Capacitor/CapacitorTests/JSONSerializationWrapper.m @@ -15,11 +15,6 @@ - (NSDictionary *)unwrappedResult { NSError* error = nil; NSData* serializedData = [NSJSONSerialization dataWithJSONObject:[self dictionary] options:NSJSONWritingPrettyPrinted error:&error]; if (serializedData != nil) { - NSString* output = [[NSString alloc] initWithData:serializedData encoding:NSUTF8StringEncoding]; - NSLog(@"%@",output); - - - NSDictionary* result = [NSJSONSerialization JSONObjectWithData:serializedData options:0 error:&error]; return result; } From ee9a46cc496329167de9343ee10f869730c5ab3a Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Tue, 3 Nov 2020 14:52:21 -0500 Subject: [PATCH 38/40] Changing deprecation messages on notifications. --- ios/Capacitor/Capacitor/CAPNotifications.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ios/Capacitor/Capacitor/CAPNotifications.swift b/ios/Capacitor/Capacitor/CAPNotifications.swift index b76f262bda..25114c111f 100644 --- a/ios/Capacitor/Capacitor/CAPNotifications.swift +++ b/ios/Capacitor/Capacitor/CAPNotifications.swift @@ -26,18 +26,18 @@ extension Notification.Name { Deprecated, will be removed */ @objc public enum CAPNotifications: Int { - // swiftlint:disable identifier_name - @available(*, deprecated, renamed: "Notification.Name.capacitorOpenURL") + // swiftlint:disable identifier_name + @available(*, deprecated, message: "renamed to 'Notification.Name.capacitorOpenURL'") case URLOpen - @available(*, deprecated, renamed: "Notification.Name.capacitorOpenUniversalLink") + @available(*, deprecated, message: "renamed to 'Notification.Name.capacitorOpenUniversalLink'") case UniversalLinkOpen - @available(*, deprecated, renamed: "Notification.Name.capacitorContinueActivity") + @available(*, deprecated, message: "Notification.Name.capacitorContinueActivity'") case ContinueActivity - @available(*, deprecated, renamed: "Notification.Name.capacitorDidRegisterForRemoteNotifications") + @available(*, deprecated, message: "renamed to 'Notification.Name.capacitorDidRegisterForRemoteNotifications'") case DidRegisterForRemoteNotificationsWithDeviceToken - @available(*, deprecated, renamed: "Notification.Name.capacitorDidFailToRegisterForRemoteNotifications") + @available(*, deprecated, message: "renamed to 'Notification.Name.capacitorDidFailToRegisterForRemoteNotifications'") case DidFailToRegisterForRemoteNotificationsWithError - @available(*, deprecated, renamed: "Notification.Name.capacitorDecidePolicyForNavigationAction") + @available(*, deprecated, message: "renamed to 'Notification.Name.capacitorDecidePolicyForNavigationAction'") case DecidePolicyForNavigationAction // swiftlint:enable identifier_name From b0e8d730e692b1a9a1f2d7f01166dd1c2e4fc51f Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Tue, 3 Nov 2020 14:52:31 -0500 Subject: [PATCH 39/40] Comment cleanup. --- ios/Capacitor/Capacitor/CAPBridgeProtocol.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift b/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift index 5c28a6e3eb..f90409eca1 100644 --- a/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift +++ b/ios/Capacitor/Capacitor/CAPBridgeProtocol.swift @@ -65,11 +65,11 @@ import WebKit Extensions to Obj-C protocols are not exposed to Obj-C code because of limitations in the runtime. Therefore these methods are implicitly Swift-only. - The methods marked as deprecated are here because they can be declared without interfering with the synthesized Obj-C setters + The deprecated methods are declared here because they can be defined without colliding with the synthesized Obj-C setters for the respective properties (e.g. `setStatusBarVisible:` for 'statusBarVisible`). */ extension CAPBridgeProtocol { - // varidic parameters cannot be exposed to Obj-C + // variadic parameters cannot be exposed to Obj-C func modulePrint(_ plugin: CAPPlugin, _ items: Any...) { let output = items.map { String(describing: $0) }.joined(separator: " ") print(message: output, for: plugin) @@ -99,7 +99,6 @@ extension CAPBridgeProtocol { /* Error(s) potentially exported by the bridge. */ - public enum CapacitorBridgeError: Error { case errorExportingCoreJS } From c87624d5252b9cbeeb59461329a65863421878a6 Mon Sep 17 00:00:00 2001 From: Ian Keith Date: Tue, 3 Nov 2020 15:57:20 -0500 Subject: [PATCH 40/40] Swiftlint format. --- ios/Capacitor/Capacitor/CAPBridge.swift | 4 +-- .../Capacitor/CAPNotifications.swift | 2 +- ios/Capacitor/Capacitor/CapacitorBridge.swift | 29 +++++++++---------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/ios/Capacitor/Capacitor/CAPBridge.swift b/ios/Capacitor/Capacitor/CAPBridge.swift index 4b6377ac3b..a7b270fab6 100644 --- a/ios/Capacitor/Capacitor/CAPBridge.swift +++ b/ios/Capacitor/Capacitor/CAPBridge.swift @@ -6,11 +6,11 @@ import Foundation // swiftlint:enable line_length @objc public class CAPBridge: NSObject { @objc public static let statusBarTappedNotification = Notification(name: .capacitorStatusBarTapped) - + public static func getLastUrl() -> URL? { return ApplicationDelegateProxy.shared.lastURL } - + public static func handleOpenUrl(_ url: URL, _ options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool { return ApplicationDelegateProxy.shared.application(UIApplication.shared, open: url, options: options) } diff --git a/ios/Capacitor/Capacitor/CAPNotifications.swift b/ios/Capacitor/Capacitor/CAPNotifications.swift index 25114c111f..a4ef7fd5b5 100644 --- a/ios/Capacitor/Capacitor/CAPNotifications.swift +++ b/ios/Capacitor/Capacitor/CAPNotifications.swift @@ -26,7 +26,7 @@ extension Notification.Name { Deprecated, will be removed */ @objc public enum CAPNotifications: Int { - // swiftlint:disable identifier_name + // swiftlint:disable identifier_name @available(*, deprecated, message: "renamed to 'Notification.Name.capacitorOpenURL'") case URLOpen @available(*, deprecated, message: "renamed to 'Notification.Name.capacitorOpenUniversalLink'") diff --git a/ios/Capacitor/Capacitor/CapacitorBridge.swift b/ios/Capacitor/Capacitor/CapacitorBridge.swift index 0e434d440d..c19bb2bc66 100644 --- a/ios/Capacitor/Capacitor/CapacitorBridge.swift +++ b/ios/Capacitor/Capacitor/CapacitorBridge.swift @@ -102,7 +102,7 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { // Background dispatch queue for plugin calls var dispatchQueue = DispatchQueue(label: "bridge") - + // MARK: - CAPBridgeProtocol: Deprecated public func getWebView() -> WKWebView? { @@ -140,9 +140,9 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { @nonobjc public func setStatusBarAnimation(_ animation: UIStatusBarAnimation) { statusBarAnimation = animation } - + // MARK: - Static Methods - + /** * Print a hopefully informative error message to the log when something * particularly dreadful happens. @@ -164,9 +164,8 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { CAPLog.print("⚡️ ❌ Please verify your installation or file an issue") } - // MARK: - Initialization - + init(_ bridgeDelegate: CAPBridgeDelegate, _ messageHandlerWrapper: CAPMessageHandlerWrapper, _ config: CAPConfig, _ scheme: String) { self.bridgeDelegate = bridgeDelegate self.messageHandlerWrapper = messageHandlerWrapper @@ -297,9 +296,9 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { func savePluginCall(_ call: CAPPluginCall) { storedCalls[call.callbackId] = call } - + // MARK: - CAPBridgeProtocol: Call Management - + @objc public func getSavedCall(_ callbackId: String) -> CAPPluginCall? { return storedCalls[callbackId] } @@ -433,7 +432,7 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { func toJs(result: JSResult, save: Bool) { let resultJson = result.toJson() CAPLog.print("⚡️ TO JS", resultJson.prefix(256)) - + DispatchQueue.main.async { self.getWebView()?.evaluateJavaScript(""" window.Capacitor.fromNative({ @@ -464,9 +463,9 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { } } } - + // MARK: - CAPBridgeProtocol: JavaScript Handling - + /** * Eval JS for a specific plugin. */ @@ -537,21 +536,21 @@ internal class CapacitorBridge: NSObject, CAPBridgeProtocol { public func getLocalUrl() -> String { return localUrl! } - + // MARK: - CAPBridgeProtocol: Logging - + public func print(message: String, for plugin: CAPPlugin) { CAPLog.print("⚡️ ", plugin.pluginId, "-", message) } - + // MARK: - CAPBridgeProtocol: View Presentation - + @objc public func showAlertWith(title: String, message: String, buttonTitle: String) { let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert) alert.addAction(UIAlertAction(title: buttonTitle, style: UIAlertAction.Style.default, handler: nil)) self.viewController?.present(alert, animated: true, completion: nil) } - + @objc public func presentVC(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) { if viewControllerToPresent.modalPresentationStyle == .popover { self.viewController?.present(viewControllerToPresent, animated: flag, completion: completion)