From fca42a0730e75a142f7f354c6ac3f6d6a0f4711f Mon Sep 17 00:00:00 2001 From: Jason Tsai Date: Tue, 27 Dec 2022 13:52:01 +0800 Subject: [PATCH] fix(ios): navigation delegate class name conflict (#824) --- .changes/navigation-delegate-class-name-conflict.md | 5 +++++ src/webview/wkwebview/mod.rs | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changes/navigation-delegate-class-name-conflict.md diff --git a/.changes/navigation-delegate-class-name-conflict.md b/.changes/navigation-delegate-class-name-conflict.md new file mode 100644 index 000000000..1b8f1aeb2 --- /dev/null +++ b/.changes/navigation-delegate-class-name-conflict.md @@ -0,0 +1,5 @@ +--- +"wry": patch +--- + +Change class declare name from `UIViewController` to `WryNavigationDelegate` to avoid class name conflict on iOS. diff --git a/src/webview/wkwebview/mod.rs b/src/webview/wkwebview/mod.rs index 668a17a5e..c4859b763 100644 --- a/src/webview/wkwebview/mod.rs +++ b/src/webview/wkwebview/mod.rs @@ -468,7 +468,8 @@ impl InnerWebView { let pending_scripts = Arc::new(Mutex::new(Some(Vec::new()))); - let navigation_delegate_cls = match ClassDecl::new("UIViewController", class!(NSObject)) { + let navigation_delegate_cls = match ClassDecl::new("WryNavigationDelegate", class!(NSObject)) + { Some(mut cls) => { cls.add_ivar::<*mut c_void>("pending_scripts"); cls.add_ivar::<*mut c_void>("navigation_policy_function"); @@ -488,7 +489,7 @@ impl InnerWebView { add_download_methods(&mut cls); cls.register() } - None => class!(UIViewController), + None => class!(WryNavigationDelegate), }; let navigation_policy_handler: id = msg_send![navigation_delegate_cls, new];