Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/target
test.yaml
test.yaml

binaries/geph5-ios/geph5/geph5.xcodeproj/xcuserdata
binaries/geph5-ios/geph5/geph5.xcodeproj/project.xcworkspace/xcuserdata
73 changes: 53 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ opt-level = 3
[profile.release-dbg]
inherits = "dev"
opt-level = 3

[patch.crates-io]
egui = { git = "https://github.com/ardocrat/egui", branch = "eframe_ios_fix" }
eframe = { git = "https://github.com/ardocrat/egui", branch = "eframe_ios_fix" }
egui-wgpu = { git = "https://github.com/ardocrat/egui", branch = "eframe_ios_fix" }
egui_extras = { git = "https://github.com/ardocrat/egui", branch = "eframe_ios_fix" }
emath = { git = "https://github.com/ardocrat/egui", branch = "eframe_ios_fix" }
winit = { git = "https://github.com/lucasmerlin/winit", branch = "geph-v0.29.x" }
13 changes: 11 additions & 2 deletions binaries/geph5-client-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ icon = ["icon.png"]
anyhow = "1.0.86"
csv = "1.3.0"
# dirs = "5.0.1"
eframe = { version = "0.28.1" }
eframe = { version = "0.28.1", default-features = false }
egui = "0.28.1"
moka = { version = "0.12.7", features = ["sync"] }
arc-writer = { path = "../../libraries/arc-writer" }
Expand Down Expand Up @@ -55,11 +55,20 @@ strip-ansi-escapes = "0.2.0"

[build-dependencies]
winresource = "0.1"
swift-rs = { version = "1", features = ["build"] }

[target.'cfg(not(target_os = "android"))'.dependencies]
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
single-instance = "0.3.3"
native-dialog = "0.7.0"

[target.'cfg(not(target_os = "ios"))'.dependencies]
eframe = { version = "0.28.1", default-features = true }

[target.'cfg(windows)'.dependencies]
winreg = "0.52.0"
winapi = { version = "0.3.9", features = ["wininet"] }

[target.'cfg(target_os = "ios")'.dependencies]
objc2 = "0.5"
objc2-foundation = { version = "0.2", features = [] }
swift-rs = "1"
12 changes: 12 additions & 0 deletions binaries/geph5-client-gui/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
extern crate winresource;

use swift_rs::SwiftLinker;

fn main() {
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows" {
let mut res = winresource::WindowsResource::new();
res.set_icon("icon.ico");
res.compile().unwrap();
}

if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "ios" {
SwiftLinker::new("10.13")
// Only if you are also targetting iOS
// Ensure the same minimum supported iOS version is specified as in your `Package.swift` file
.with_ios("11")
.with_package("SwiftLib", "../geph5-ios/SwiftLib")
.link();

}
}
57 changes: 57 additions & 0 deletions binaries/geph5-client-gui/src/ios_ui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
use egui::Ui;

use objc2::{extern_class, extern_methods, mutability, ClassType};
use objc2::rc::Id;
use objc2::runtime::NSObject;
use objc2_foundation::NSString;

extern_class!(
#[derive(Debug)]
pub struct GlobalFunctionsObjc;

unsafe impl ClassType for GlobalFunctionsObjc {
type Super = NSObject;
type Mutability = mutability::InteriorMutable;
}
);


extern_methods!(
unsafe impl GlobalFunctionsObjc {
#[method(objcDummyFnWithData:)]
pub fn objcDummyFn(data: &NSString);
}
);


extern "C" {
fn dummyFn();
}



swift_rs::swift!(fn swiftrs_dummy_fn(data: &swift_rs::SRString));

pub fn ios_ui(ui: &mut Ui) {
ui.horizontal(|ui| {
if ui.button("buy c").clicked() {
unsafe {
dummyFn();
}
}

if ui.button("buy objc").clicked() {
unsafe {
let ns_string = NSString::from_str("I was called via rust / objc2 and can have a custom message!");
GlobalFunctionsObjc::objcDummyFn(&ns_string);
}
}

if ui.button("buy swift").clicked() {
unsafe {
let swift_string = swift_rs::SRString::from("I was called via rust / swiftrs and can have a custom message!");
swiftrs_dummy_fn(&swift_string);
}
}
});
}
5 changes: 4 additions & 1 deletion binaries/geph5-client-gui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ pub mod store_cell;
pub mod tabs;
pub mod timeseries;

#[cfg(target_os = "ios")]
mod ios_ui;

pub static SHOW_KEYBOARD_CALLBACK: OnceCell<Box<dyn Fn(bool) + Send + Sync + 'static>> =
OnceCell::new();

Expand Down Expand Up @@ -142,7 +145,7 @@ impl App {
}
});

#[cfg(not(target_os = "android"))]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
if let Err(err) = result.inner {
use native_dialog::MessageType;
let _ = native_dialog::MessageDialog::new()
Expand Down
3 changes: 3 additions & 0 deletions binaries/geph5-client-gui/src/pac/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ pub use macos::*;
mod dummy;
#[cfg(target_os = "android")]
pub use dummy::*;

#[cfg(target_os = "ios")]
pub use dummy::*;
Loading