-
Notifications
You must be signed in to change notification settings - Fork 138
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
add support for iOS #233
Comments
I've been looking into this on and off for a few months now. My main goal is to get The The forked My current progress is attempting to get the It's unclear whether or not further packages will need modifications once I am through with |
Some good news! I was able to get the counter example to render! I can’t interact with it, but I can see the window, text, and buttons. It took quite a bit to get to this point. Once I was able to get I digress. My initial guess as to why filesystem calls don’t work is that this is being built for Mac Catalyst and these apps are more strictly confined by their app bundle structures (you can’t just run a mac catalyst app from a cli, it requires an entire app bundle). So we need to use I was still getting no fonts found, but there was another instance in I'm going to look a little deeper at why I can't interact with the example. I remember something about when the window gets created with respect to the event loops that is important for iOS applications. I'll probably start here. |
This is awesome! |
Some bad news, I can't get this app bundle to run on an iOS simulator. The app fails to launch for some watchdog reason. I guess it 0x8BADF00D and got food poisoning (https://developer.apple.com/documentation/xcode/addressing-watchdog-terminations). It's hard to debug this issue with my current workflow. I'm doing most of my dev work with the remote dev feature in the CodeApp (https://github.com/thebaselab/codeapp) on my iPad in conjunction with VNCing into my 2015 MacBook Pro (I just realized how old this laptop is). I've been attempting to capture debug info with the
|
WindowEvent::Touch(_) => {} |
I will look at how touches can be implemented for floem
. It seems winit
supports touches with iOS via UITouch
, so that's a good sign.
Some mock code to add to pub(crate) fn touch_input(&mut self, touch: Touch) {
let phase: TouchPhase = touch.phase;
let num_touches : u64 = /* somehow get multiple touches if possible? */
// Handle single touch as if it were an LMB click
mut button: PointerButton = PointerButton::Primary
let count = if touch.phase == TouchPhase::Started && num_touches == 1 {
if let Some((count, last_pos, instant)) = self.last_pointer_down.as_mut() {
if *count == 4 {
*count = 1;
} else if instant.elapsed().as_millis() < 500
&& last_pos.distance(self.cursor_position) < 4.0
{
*count += 1;
} else {
*count = 1;
}
*instant = Instant::now();
*last_pos = self.cursor_position;
*count
} else {
self.last_pointer_down = Some((1, self.cursor_position, Instant::now()));
1
}
} else {
0
};
// Handle 2-touch tap as if it were a single RMB click
if (num_touches == 2) {
// Handle right click
button = PointerButton::Secondary;
}
let event = PointerInputEvent {
pos: self.cursor_position,
button,
modifiers: self.modifiers,
count,
};
match phase {
TouchPhase::Started => {
self.event(Event::PointerDown(event));
}
TouchPhase::Ended => {
self.event(Event::PointerUp(event));
}
}
}
Seems like there is an open issue in the main A potential workaround would be to add additional debouncing code to check how far in distance and how close in time a second touch is with respect to a first touch and use this as a way to get number of touches on a screen. I think this would require some modification to the There are some subtleties here that will require problem solving. On Mac Catalyst targets, we have 3 potential platforms: Mac, iPad, iPhone.
I think it's best for now to convert these touch events to pointer events and deal with the nuances at a later time. And there will be many more nuances. |
Great to see progress. Do you have your version where softbuffer compile errors are fixed available somewhere? |
I have them available in a fork of softbuffer under the ios_macabi branch: https://github.com/woodworthkyle/softbuffer/tree/ios_macabi It’s been a while since I’ve touched this, but I believe the fixes are mostly to do with some additions to the cocoa package: https://github.com/woodworthkyle/core-foundation-rs/tree/ios_macabi |
I have some updates! Originally, I was targeting Mac Catalyst. However, my interpretation of this target may have been misconstrued. I thought it was a sort of cross-platform target for the Apple ecosystem (which is somewhat true). It turns out Apple Silicon devices can actually run iOS binaries natively. When it comes to x86 Apple devices, this is where Mac Catalyst comes into play somehow. I still don't quite understand this. Mac Catalyst seems like a way to utilize AppKit with UIKit. So Mac Catalyst binaries will not run on iOS, but iOS binaries will run on Apple Silicon MacOS devices (aarch64). Anyways, I stopped at a point where I was trying to run a Mac Catalyst binary on an iOS Simulator. This led me down the path to try and run the Mac Catalyst binary on an iOS device. Along this path I discovered that iOS binaries can just run on Apple Silicon. So for now, I will be pursuing this effort (essentially just compiling iOS binaries now). I had to go down the whole rabbit-hole of learning how to properly package an app bundle for iOS (basically what needs to be in the Info.plist file). As well as learning how to code-sign (provision profiles, certificates, entitlements) and package the entire bundle (zip to .ipa file) all from command line. There was a lot of debugging that entailed reverse engineering a working example of the rust based game engine I'm at the point where debugging is a bit of a hassle, but somehow I am still making progress. Since these binaries have to be bundled inside a sandbox, we can't just run the application from a terminal and see it's
However, debugging on an iOS device is a showstopper...but not for long.
There is a So the good news is this: I am able to install and launch the app (without it crashing) on my iOS device. The same goes for my development MacOS machine. I cannot attach lldb or view the standard output of the app running on my iOS device...yet. I can, however, view the standard output as well as attach lldb to the same exact binary running on MacOS. And as far as I can tell, they behave the same (does not crash). The bad news: the UI still does not appear. I get a black screen on my iOS device and a blank window on MacOS. The lldb debugger seems to point out that we are in fact in the
I'm hoping this isn't a red herring and actually means we can run a |
Super cool!! Thanks for the update and the work! I'm definitely interested in running floem apps on iOS. |
Would be great if iOS was supported.
The text was updated successfully, but these errors were encountered: