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

Class with name UIViewController could not be found #882

Closed
2 tasks
andrewkenreich opened this issue Feb 13, 2023 · 0 comments · Fixed by #883
Closed
2 tasks

Class with name UIViewController could not be found #882

andrewkenreich opened this issue Feb 13, 2023 · 0 comments · Fixed by #883

Comments

@andrewkenreich
Copy link

andrewkenreich commented Feb 13, 2023

Describe the bug

thread '' 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant