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

Add iOS support #103

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add iOS support #103

wants to merge 3 commits into from

Conversation

lucasfernog
Copy link

No description provided.

@lucasfernog
Copy link
Author

I did not touch the image functions, but I could take a look at it if needed.

@complexspaces
Copy link
Collaborator

If its reasonable for you, I would prefer to support images on iOS out-of-the-gate as well, since it appears to be supported in the name of preventing cross-platform feature/support drift.

I've seen plenty of apps utilize it so I can see this as being something that bites someone.

let _: usize = unsafe { msg_send![self.pasteboard, clearContents] };
#[cfg(target_os = "ios")]
let _: () = unsafe {
msg_send![self.pasteboard, setItems: NSArray::from_vec(Vec::<Id<NSString>>::new())]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right array type to clear any existing content type? The docs seem to say this is essentially an array of [String; Any] but its unclear if this matches. At a glance, this needs an inner dictionary type instead of a plain NSString?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type here doesn't really matter, I just want to send an empty array to the items property.
It is indeed technically wrong, so I'll push a fix.

#[cfg(target_os = "ios")]
let success: bool = {
let string = NSString::from_str(&data);
unsafe { msg_send![self.clipboard.pasteboard, setString: string] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this (and other callsites) get mixed up? setString appears to be only a method on NSPasteboard.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setString is the objc way of setting a value for the string property, same as setItems.

@lucasfernog
Copy link
Author

If its reasonable for you, I would prefer to support images on iOS out-of-the-gate as well, since it appears to be supported in the name of preventing cross-platform feature/support drift.

I've seen plenty of apps utilize it so I can see this as being something that bites someone.

@complexspaces I just pushed the iOS image implementation. I had to use PNG instead of TIFF format though.

@rizerco
Copy link

rizerco commented Jan 3, 2024

Is there anything preventing this being merged? I’m sure lots of people would like to see it added. I’m happy to help if I can.

@complexspaces
Copy link
Collaborator

Hi @rizerco, there's still interest in merging this one in but its fallen off my priority list. Previously I was trying to see if there was a way to convert a UIImage into a raw RGBA byte array without needing the image crate.

@lucasfernog-crabnebula
Copy link

anything else i can do?

@complexspaces
Copy link
Collaborator

Thank you for your offer. I am coming up with a plan to resolve conflicts and try testing out the changes here.

I'm interested in getting iOS support landed because it would get 1Password closer to using arboard on all platforms instead of needing a custom Swift implementation. Unfortunately I have a lot of competing priorities, so things can linger for a while despite good intentions on both sides :(

@complexspaces
Copy link
Collaborator

Hi again, I have a short status/transparency update: I believe I've finished rebasing/porting to the latest master as of last week. I still need to test them inside the simulator and on my iOS device but it is moving along.

@lucasfernog
Copy link
Author

Awesome! On the Tauri side we also use a custom Swift implementation 😅

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

Successfully merging this pull request may close these issues.

4 participants