Repository: tauri-apps/wry (language: rust)

Issue:
Class with name UIViewController could not be found
**Describe the bug**

thread '<unnamed>' panicked at 'Class with name UIViewController could not be found', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/wry-0.26.0/src/webview/wkwebview/mod.rs:615:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace




**Steps To Reproduce**
``` 
           // we add a download handler to save the png file
            let init_view = init_view.with_download_started_handler(move |_, suggested_path| {
                // we change the suggested_path to the export_image
                if !export_image.is_empty() {
                    let new_path = PathBuf::from(&export_image).as_path().to_path_buf();
                    *suggested_path = new_path.clone();
                    true
                } else {
                    true
                }
            });
            let init_view =
                init_view.with_download_completed_handler(move |_uri, filepath, success| {
                    if !success {
                        println!(
                            "Failed to download to {}",
                            filepath.unwrap_or_default().to_str().unwrap_or_default()
                        );
                    } else if !minimized {
                        println!(
                            "Fished downloading to {}",
                            filepath.unwrap_or_default().to_str().unwrap_or_default()
                        );
                    }
                });
```

**Expected behavior**
This would work

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Platform and Versions (please complete the following information):**
OS: Mac
Rustc:

**Would you want to assign yourself to resolve this bug?**
- [ ] Yes
- [ ] No

**Additional context**
Add any other context about the problem here.


``` 
// Download handler
        let download_delegate = if attributes.download_started_handler.is_some()
          || attributes.download_completed_handler.is_some()
        {
          let cls = match ClassDecl::new("WryDownloadDelegate", class!(NSObject)) {
            Some(mut cls) => {
              cls.add_ivar::<*mut c_void>("started");
              cls.add_ivar::<*mut c_void>("completed");
              cls.add_method(
                sel!(download:decideDestinationUsingResponse:suggestedFilename:completionHandler:),
                download_policy as extern "C" fn(&Object, Sel, id, id, id, id),
              );
              cls.add_method(
                sel!(downloadDidFinish:),
                download_did_finish as extern "C" fn(&Object, Sel, id),
              );
              cls.add_method(
                sel!(download:didFailWithError:resumeData:),
                download_did_fail as extern "C" fn(&Object, Sel, id, id, id),
              );
              cls.register()
            }
            None => class!(UIViewController),
          };`
``` 

I think this class at the bottom needs to be the same name as the "WryDownloadDelegate"  so should be -  (None => class!(WryDownloadDelegate))

it looks like #815 and #817 forgot to change this other var name? It works if we dont call it




Discussion / hints:

Fix patch:
diff --git a/.changes/patch.md b/.changes/patch.md
new file mode 100644
index 000000000..3afe24934
--- /dev/null
+++ b/.changes/patch.md
@@ -0,0 +1,6 @@
+---
+"wry": patch
+---
+
+Update the value returned on a `None` value of `ClassDecl::new("WryDownloadDelegate", class!(NSObject))`
+from `UIViewController` to `WryDownloadDelegate`.
diff --git a/src/webview/wkwebview/mod.rs b/src/webview/wkwebview/mod.rs
index 5ed1a588c..24888d7f2 100644
--- a/src/webview/wkwebview/mod.rs
+++ b/src/webview/wkwebview/mod.rs
@@ -612,7 +612,7 @@ impl InnerWebView {
               );
               cls.register()
             }
-            None => class!(UIViewController),
+            None => class!(WryDownloadDelegate),
           };
 
           let download_delegate: id = msg_send![cls, new];


Test patch: