Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(iOS): Redefining bridge API #3678

Merged
merged 67 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
dfc4306
Minor cleanup to eliminate compiler warnings in Capacitor Cordova pro…
ikeith Oct 1, 2020
1df74d6
Support direct building of the capacitor framework. Added modulemaps,…
ikeith Oct 1, 2020
413af81
Removing unneeded pod install step so build will work.
ikeith Oct 1, 2020
5338f02
Cleanup from cherry-picking commits
ikeith Oct 15, 2020
8a40a6a
Deleted exclusion of removed file.
ikeith Oct 15, 2020
6b0798e
Defining new JS types and supporting protocols.
ikeith Aug 4, 2020
005ccb8
Updating CAPPluginCall to use new types.
ikeith Aug 4, 2020
216bb70
Updating existing code to use new types and accessors.
ikeith Aug 4, 2020
5274e81
Swiftlint changes
ikeith Oct 2, 2020
1597b40
Adding excluded header, file references in project.
ikeith Oct 15, 2020
f88cbe2
WIP
ikeith Oct 14, 2020
9ea44b6
Cleanup from merge.
ikeith Oct 14, 2020
e54a284
Notifications update.
ikeith Oct 14, 2020
36e4978
Marking additional classes internal
ikeith Oct 14, 2020
66eac4b
Updating plugin implementation to match interface.
ikeith Oct 14, 2020
34b6247
Updating bridge protocol, moving CapacitorBridge, adding deprecated s…
ikeith Oct 14, 2020
9f85b8c
`npm run fmt` cleanup.
ikeith Oct 14, 2020
8347c17
Updating disabled code.
ikeith Oct 14, 2020
a194dc7
Enabling mac builds for the verify script.
ikeith Oct 14, 2020
56ed5c2
Project reorganization, addressing lint error.
ikeith Oct 15, 2020
56fe1ea
Removing redundant name in deprecation message.
ikeith Oct 15, 2020
2d69c8e
Adding explicit type coercion to ensure conformance to expected proto…
ikeith Oct 15, 2020
507c381
Merge branch 'jstypes' into plugin-api
ikeith Oct 15, 2020
293d17c
Swiftlint format
ikeith Oct 15, 2020
10c2bfb
Merge branch 'jstypes' into plugin-api
ikeith Oct 15, 2020
d15ab9f
Merge branch 'main' into ios-build
ikeith Oct 16, 2020
3ecc74f
Merge branch 'main' into jstypes
ikeith Oct 16, 2020
f4eb6ce
Merge branch 'main' into plugin-api
ikeith Oct 16, 2020
28f1eed
Reworked CAPLog to prevent race condition between it and CAPConfig.
ikeith Oct 16, 2020
3d92dd0
Adding empty application shell to host framework for unit tests.
ikeith Oct 16, 2020
f3581e0
Merge branch 'ios-build' into jstypes
ikeith Oct 16, 2020
2bbcb56
Adding unit tests for the type bridging.
ikeith Oct 19, 2020
223b683
Merge branch 'main' into jstypes
ikeith Oct 19, 2020
84cb33a
Removing deleted file.
ikeith Oct 19, 2020
32bfa11
Adding swift lint config file to exclude tests and host app from lint…
ikeith Oct 19, 2020
6598cf6
Merge branch 'main' into ios-build
ikeith Oct 19, 2020
2208598
Merge branch 'jstypes' into plugin-api
ikeith Oct 19, 2020
e5c8bc7
Updating tests.
ikeith Oct 19, 2020
a0e5e24
Removing reference to deleted file.
ikeith Oct 19, 2020
d6d1955
Merge branch 'ios-build' into jstypes
ikeith Oct 19, 2020
84aab7f
Merge branch 'jstypes' into plugin-api
ikeith Oct 19, 2020
90166dd
Updating `getLastUrl` call.
ikeith Oct 19, 2020
14f6321
Restoring missed file from merge.
ikeith Oct 19, 2020
e4c4dc4
Cleanup and organization.
ikeith Oct 19, 2020
7fb3deb
Merge branch 'main' into ios-build
imhoffd Oct 19, 2020
4495117
Merge branch 'main' into ios-build
ikeith Oct 20, 2020
36ecfce
Merge branch 'ios-build' into jstypes
ikeith Oct 20, 2020
abf2747
Merge branch 'jstypes' into plugin-api
ikeith Oct 20, 2020
d44d62b
Merge branch 'main' into ios-build
jcesarmobile Oct 21, 2020
b9e9969
Removing deleted file reference.
ikeith Oct 21, 2020
41151eb
Merge branch 'ios-build' into jstypes
ikeith Oct 21, 2020
950d290
Merge branch 'jstypes' into plugin-api
ikeith Oct 21, 2020
fbad714
Merge branch 'main' into jstypes
ikeith Oct 22, 2020
053f9e7
Merge branch 'jstypes' into plugin-api
ikeith Oct 22, 2020
91ffe8b
Revert "Reworked CAPLog to prevent race condition between it and CAPC…
ikeith Oct 22, 2020
60a9cb1
Revert "Reworked CAPLog to prevent race condition between it and CAPC…
ikeith Oct 22, 2020
b72720a
Deleting extraneous log statement in test.
ikeith Oct 22, 2020
b1a36cc
Merge branch 'jstypes' into plugin-api
ikeith Oct 22, 2020
dbcafd2
Merge branch 'main' into plugin-api
ikeith Oct 28, 2020
84c4bcc
Merge branch 'main' into plugin-api
ikeith Nov 2, 2020
80300ec
Merge branch 'main' into plugin-api
ikeith Nov 3, 2020
ee9a46c
Changing deprecation messages on notifications.
ikeith Nov 3, 2020
b0e8d73
Comment cleanup.
ikeith Nov 3, 2020
c87624d
Swiftlint format.
ikeith Nov 3, 2020
8d29253
Merge branch 'main' into plugin-api
ikeith Nov 5, 2020
5b13e78
Merge branch 'main' into plugin-api
ikeith Nov 9, 2020
69c8c80
Merge branch 'main' into plugin-api
imhoffd Nov 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 38 additions & 13 deletions ios/Capacitor/Capacitor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
621ECCBC2542046400D3D615 /* JSTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621ECCBB2542046400D3D615 /* JSTypes.swift */; };
621ECCC3254204B700D3D615 /* BridgedTypesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621ECCC2254204B700D3D615 /* BridgedTypesTests.swift */; };
621ECCC8254204BE00D3D615 /* JSONSerializationWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 621ECCC6254204BE00D3D615 /* JSONSerializationWrapper.m */; };
621ECCD6254205BD00D3D615 /* CAPBridgeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621ECCD4254205BD00D3D615 /* CAPBridgeProtocol.swift */; };
621ECCDA254205C400D3D615 /* CapacitorBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621ECCD9254205C400D3D615 /* CapacitorBridge.swift */; };
621ECCE3254206A600D3D615 /* CAPApplicationDelegateProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 621ECCE2254206A600D3D615 /* CAPApplicationDelegateProxy.swift */; };
622BB9C42541FE3000A5DBCA /* capacitor.config.json in CopyFiles */ = {isa = PBXBuildFile; fileRef = 622BB9BE2541FDFE00A5DBCA /* capacitor.config.json */; };
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 */; };
Expand Down Expand Up @@ -115,9 +118,13 @@
621ECCC6254204BE00D3D615 /* JSONSerializationWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSONSerializationWrapper.m; sourceTree = "<group>"; };
621ECCC7254204BE00D3D615 /* JSONSerializationWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONSerializationWrapper.h; sourceTree = "<group>"; };
621ECCCD254204C400D3D615 /* CapacitorTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CapacitorTests-Bridging-Header.h"; sourceTree = "<group>"; };
621ECCD4254205BD00D3D615 /* CAPBridgeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPBridgeProtocol.swift; sourceTree = "<group>"; };
621ECCD9254205C400D3D615 /* CapacitorBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CapacitorBridge.swift; sourceTree = "<group>"; };
621ECCE2254206A600D3D615 /* CAPApplicationDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPApplicationDelegateProxy.swift; sourceTree = "<group>"; };
622BB9BE2541FDFE00A5DBCA /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = "<group>"; };
62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPPluginCall.h; sourceTree = "<group>"; };
62959AE32524DA7700A3D7F1 /* JSExport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSExport.swift; sourceTree = "<group>"; };
62959AE42524DA7700A3D7F1 /* CAPBridgedJSTypes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAPBridgedJSTypes.m; sourceTree = "<group>"; };
62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAPBridgedPlugin.h; sourceTree = "<group>"; };
62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPPluginCall.swift; sourceTree = "<group>"; };
62959AE72524DA7700A3D7F1 /* CAPFile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CAPFile.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -206,6 +213,7 @@
6296A77C253A2E49005A202A /* TestsHostApp */,
50503EE01FC08594003606DC /* Products */,
501CBAA51FC0A723009B0D4D /* Frameworks */,
621ECCD12542059800D3D615 /* Recovered References */,
);
sourceTree = "<group>";
};
Expand All @@ -232,40 +240,52 @@
path = CapacitorTests;
sourceTree = "<group>";
};
621ECCD12542059800D3D615 /* Recovered References */ = {
isa = PBXGroup;
children = (
62959AE42524DA7700A3D7F1 /* CAPBridgedJSTypes.m */,
);
name = "Recovered References";
sourceTree = "<group>";
};
62959AE12524DA7700A3D7F1 /* Capacitor */ = {
isa = PBXGroup;
children = (
62959B0F2524DA7700A3D7F1 /* Capacitor.h */,
62959B132524DA7700A3D7F1 /* CAPPlugin.h */,
62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */,
62959B012524DA7700A3D7F1 /* CAPPlugin.m */,
62959AE52524DA7700A3D7F1 /* CAPBridgedPlugin.h */,
62959B092524DA7700A3D7F1 /* CAPPluginMethod.h */,
62959AE32524DA7700A3D7F1 /* JSExport.swift */,
62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */,
62959AE72524DA7700A3D7F1 /* CAPFile.swift */,
62959AE82524DA7700A3D7F1 /* CAPPluginMethod.m */,
62959AE92524DA7700A3D7F1 /* UIColor.swift */,
62959AE22524DA7700A3D7F1 /* CAPPluginCall.h */,
62959B062524DA7700A3D7F1 /* CAPPluginCall.m */,
62959AE62524DA7700A3D7F1 /* CAPPluginCall.swift */,
621ECCBB2542046400D3D615 /* JSTypes.swift */,
621ECCB62542045900D3D615 /* CAPBridgedJSTypes.h */,
621ECCB42542045900D3D615 /* CAPBridgedJSTypes.m */,
62959AEA2524DA7700A3D7F1 /* Plugins */,
62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */,
62959AFF2524DA7700A3D7F1 /* JS.swift */,
62959B012524DA7700A3D7F1 /* CAPPlugin.m */,
62959AE32524DA7700A3D7F1 /* JSExport.swift */,
621ECCD4254205BD00D3D615 /* CAPBridgeProtocol.swift */,
621ECCD9254205C400D3D615 /* CapacitorBridge.swift */,
62959B142524DA7700A3D7F1 /* CAPBridge.swift */,
62959B042524DA7700A3D7F1 /* CAPBridgeViewController.swift */,
621ECCE2254206A600D3D615 /* CAPApplicationDelegateProxy.swift */,
62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */,
62959AEA2524DA7700A3D7F1 /* Plugins */,
62959B052524DA7700A3D7F1 /* CAPConfig.swift */,
62959B062524DA7700A3D7F1 /* CAPPluginCall.m */,
62959B072524DA7700A3D7F1 /* CapacitorExtension.swift */,
62959B082524DA7700A3D7F1 /* CAPLog.swift */,
62959B0A2524DA7700A3D7F1 /* CAPBridgeDelegate.swift */,
62959AE72524DA7700A3D7F1 /* CAPFile.swift */,
62959B0B2524DA7700A3D7F1 /* CAPMessageHandlerWrapper.swift */,
62959B022524DA7700A3D7F1 /* CAPUNUserNotificationCenterDelegate.swift */,
62959B0D2524DA7700A3D7F1 /* CAPAssetHandler.swift */,
62959B0E2524DA7700A3D7F1 /* TmpViewController.swift */,
62959B102524DA7700A3D7F1 /* DocLinks.swift */,
62959B152524DA7700A3D7F1 /* CAPNotifications.swift */,
62959B072524DA7700A3D7F1 /* CapacitorExtension.swift */,
62959B112524DA7700A3D7F1 /* Data+Capacitor.swift */,
62959AE92524DA7700A3D7F1 /* UIColor.swift */,
62959AFE2524DA7700A3D7F1 /* UIStatusBarManager+CAPHandleTapAction.m */,
62959B122524DA7700A3D7F1 /* Info.plist */,
62959B142524DA7700A3D7F1 /* CAPBridge.swift */,
62959B152524DA7700A3D7F1 /* CAPNotifications.swift */,
62959B8225253A9500A3D7F1 /* Capacitor.modulemap */,
);
path = Capacitor;
Expand Down Expand Up @@ -478,8 +498,10 @@
621ECCB72542045900D3D615 /* CAPBridgedJSTypes.m in Sources */,
62959B402524DA7800A3D7F1 /* TmpViewController.swift in Sources */,
62959B372524DA7800A3D7F1 /* CAPConfig.swift in Sources */,
621ECCD6254205BD00D3D615 /* CAPBridgeProtocol.swift in Sources */,
62959B432524DA7800A3D7F1 /* Data+Capacitor.swift in Sources */,
621ECCBC2542046400D3D615 /* JSTypes.swift in Sources */,
621ECCDA254205C400D3D615 /* CapacitorBridge.swift in Sources */,
62959B382524DA7800A3D7F1 /* CAPPluginCall.m in Sources */,
62959B1B2524DA7800A3D7F1 /* CAPFile.swift in Sources */,
62959B462524DA7800A3D7F1 /* CAPBridge.swift in Sources */,
Expand All @@ -500,6 +522,7 @@
62959B2F2524DA7800A3D7F1 /* DefaultPlugins.m in Sources */,
62959B222524DA7800A3D7F1 /* Console.swift in Sources */,
62959B3A2524DA7800A3D7F1 /* CAPLog.swift in Sources */,
621ECCE3254206A600D3D615 /* CAPApplicationDelegateProxy.swift in Sources */,
62959B262524DA7800A3D7F1 /* WebView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -694,6 +717,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.Capacitor;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = YES;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -722,6 +746,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.capacitorjs.ios.Capacitor;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = YES;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
32 changes: 32 additions & 0 deletions ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 {
NotificationCenter.default.post(name: .capacitorOpenURL, 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: .capacitorOpenUniversalLink, object: [
"url": url
])
return true
}
}
6 changes: 3 additions & 3 deletions ios/Capacitor/Capacitor/CAPAssetHandler.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import MobileCoreServices

class CAPAssetHandler: NSObject, WKURLSchemeHandler {
internal class CAPAssetHandler: NSObject, WKURLSchemeHandler {

private var basePath: String = ""

Expand All @@ -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 {
Expand Down
Loading