-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
refactor(macos): migrate to objc2
#1316
base: dev
Are you sure you want to change the base?
Conversation
* refactor: migrate to `dpi` crate closes #1172 * macOS * linux * fix doctests * imports * more doctests * fix android and ios * Update examples/winit.rs Co-authored-by: Jason Tsai <[email protected]> * Update src/webview2/mod.rs --------- Co-authored-by: Jason Tsai <[email protected]>
* fix(wkwebview): menu shortcuts * Update wkwebview.md
Co-authored-by: amrbashir <[email protected]>
Package Changes Through d0f6990No changes. Add a change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
17287ab
to
fdd1534
Compare
fdd1534
to
4eec6fb
Compare
d2ff37d
to
b3f0a6a
Compare
b3f0a6a
to
1abff79
Compare
4f76fd1
to
e8d2c6e
Compare
096ba56
to
ab9804b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gave it a cursory look, great overall, really nice to see objc2
used effectively, gives me motivation to fix the places where it isn't working!
"NSBundle", | ||
"NSProcessInfo", | ||
] } | ||
objc2-app-kit = { version = "0.2.0", features = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should only be enabled under [target."cfg(target_os = \"macos\")".dependencies]
. Reversed for objc2-ui-kit
.
objc2-web-kit = { version = "0.2.0", features = [ | ||
"objc2-app-kit", | ||
"block2", | ||
"WKWebView", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
objc2-web-kit
not supportWKWebView
on iOS (madsmtm/objc2#637)
I think the easiest approach for now might be for you to copy objc2-web-kit
's definition from the source into a file in this repo, remove the #[cfg(feature = "objc2-app-kit")]
, change NSWindow
to UIWindow
, and import it from that file on iOS instead of from objc2-web-kit
.
download_started_handler: Option<Box<dyn FnMut(String, &mut PathBuf) -> bool>>, | ||
download_completed_handler: Option<Rc<dyn Fn(String, Option<PathBuf>, bool)>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change these to take dyn Fn(...) + 'static
instead, then you don't need to into_raw
and from_raw
it, and it also becomes sound. (At least I think that's how the lifetimes work here? I can never remember...)
Also, Box<dyn FnMut(...)>
really isn't possible in Objective-C classes, you'll have to wrap it in a RefCell
.
download_started_handler: Option<Box<dyn FnMut(String, &mut PathBuf) -> bool>>, | |
download_completed_handler: Option<Rc<dyn Fn(String, Option<PathBuf>, bool)>>, | |
download_started_handler: Option<RefCell<Box<dyn FnMut(String, &mut PathBuf) -> bool + 'static>>>, | |
download_completed_handler: Option<Rc<dyn Fn(String, Option<PathBuf>, bool) + 'static>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, Box<dyn FnMut(...)> really isn't possible in Objective-C classes, you'll have to wrap it in a RefCell.
Could you explain more about this? I am curious how this work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Objective-C classes require interior mutability (&self
), so while you can store Box<dyn FnMut(...)>
in them, it'd be useless, as it requires a mutable reference (&mut self
) to call the closure.
It'd be kinda like using Rc<Box<dyn FnMut(...)>>
- try it out, it won't work unless you introduce RefCell
or similar forms of interior mutability.
Just to clear up any confusion, Box<dyn Fn(...)>
is fine, it's the FnMut
that's problematic.
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
4336d96
to
7674bf3
Compare
320b26d
to
56a5616
Compare
Note: iOS can now be built and run on the iOS simulator from Tauri (it requires some modification in Tauri to use objc2). It's still WIP for testing some functionalities and organizing the code. |
Co-authored-by: Mads Marquart <[email protected]>
Issue: #1239
Roadmap
objc
dependencydev
branch{}URLSchemeHandler(We need to create it dynamically)Functionality Test:
[mac]
Reparent[ios]
setAllowsInlineMediaPlayback (not merged yet, indev
)[mac]
Synthetic mouse event[mac]
Tab focuses links[mac]
with_back_forward_navigation_gesturesdev
as well)[mac]
with_drag_drop_handler[mac]
with_accept_first_mouse[mac]
print[mac]
open_devtools[mac]
close_devtools[mac]
is_devtools_open[mac]
set_bounds (child webview)Issues
objc2-web-kit
not supportWKWebView
on iOS. We need this so we can continue the migration.objc2_web_kit::WKWebView
supportsiOS
madsmtm/objc2#637NSException
so we can recover from some situations? I'm usingcatch_unwind
now for the exception, but I think this is not ideal.tauri-runtime-wry
need to useobjc2
as well