Example iOS plugin project, please?

Hi; I’ve successfully built my first plugin control for macOS, and now I’m trying to do the same for iOS, but not making much headway, and unfortunately, there’s no example plugin projects for iOS.

So, where to start? I found some older threads that described creating static libraries and then writing declares to access the library, but I don’t want that extra work/complexity. I can see (by unzipping the plugins) that other popular iOS plugins create a .dylib.

That’s not choosable as a target in xcode. The plugin developer I wrote to makes their iOS plugins with the command line, but that’s not an area I’m familiar with.

Can someone point me to a working xcode example iOS plugin project?

John

The fpPlugin

einhugur / fpplugin — Bitbucket

Its not “good” plugin I am still working on cleaning it up after getting the chaos on my table but for your purposes then it has iOS build script in it.

I build iOS with a script and not from XCode. (And I think Christian does that also probably)

(I see when looking into the script then it has tiny bug, that happened when I pulled out macOS 32 bit code from the script)

This here:

for i in {0..1}

should be:

for i in 0 1 3

So that it builds both iOS simulator targets and iOS non simulated target.

And the line at very bottom should be removed since Target 2 is no longer built, this one here should not be there any more:

codesign -f -s "Developer ID Application: Bjorn Eiriksson" -i EHFpPlugin.dylib "${OUTPUT[2]}"/EHFpPlugin.dylib
1 Like

Thank you very much for sharing this, it’s certainly one piece of the puzzle. Can your script’s build flags and settings be used in an Xcode target’s settings?

It still remains to be seen how to use REALmobileControl, which headers are needed, etc. I don’t have a working iOS plugin yet, so that’s still the other half of the problem. :sweat_smile:

And to remind folks, I do have a consulting request open in the other part of the forum, if anyone has the time, experience, and inclination to work with me to get something running.

I’d very much like to shift my iOS app development away from Obj-C/Swift. I will use these languages and Apple’s APIs for the critical work (in plugins), but the UI and other app boilerplate (about views, loading documents, sharing, etc.) is much easier to manage in Xojo.

John

There may only be a handful of people, who could answer.

I use scripts to build.
In Xcode you can try a target for a static library and then change it to a dynamic one by coping settings over from your Mac plugin project.

1 Like

Thank you, I will give that a try!

And why not make this a public endeavor?

I’ve uploaded my project repo; it wraps my (open-source) hybrid macOS and iOS control, TRMTKImageView, as a macOS XOJO plugin. Let’s try to make a sample Xcode project to create iOS plugins.

TRMTKImageView is a hybrid macOS and iOS Metal-based control for displaying images. It’s like NSImageView or UIImageView, but faster and handles extremely large images. It works by displaying Core Image (CIImage) images directly to a Metal CALayer on the screen without using an intermediate memory buffer. It’s ideal for live video effects and real-time image processing.

The repo contains the Xcode project for the macOS XOJO plugin and an example XOJO project:

The example project requires the MBS plugins to create the CIImage

2 Likes

I’ve made some progress with creating an iOS plugin in Xcode rather than the command line: I set up a new .framework target for iOS, used the .dylib created for the .framework bundle, then added the .dylib extension:

XOJO won’t load an iOS .dylib placed directly in the Plugins folder, so I created a zip/xojo_plugin archive. @Björn_Eiríksson’s script was helpful because I compiled his iOS plugins and placed them in the Plugins folder, too, and those didn’t load either.

Also, XOJO won’t load a plugin that only has an iOS part, complaining that it’s missing a macOS part. Once both are in place, the plugin loads.

I haven’t created a control plugin yet; I have only created a module plugin. I’m going to try a control next.

This branch/commit: Working · tinrocket/XOJO-Plugin-Examples@3a28daf · GitHub

You always need the Designer IDE platform part. Since IDE runs for example on macOS. IDE cannot see into any other platform than its current platform. So it cannot load Windows DLL or iOS dylib or anything else it can only load its own platform.

Which is why a plugin will never work unless you also put the platform of the IDE into it.

2 Likes

Things are almost falling into place. The iOS control compiles and XOJO is able to load it without error, but it doesn’t register itself in the IDE. Perhaps because a flag is missing? I don’t see an equivalent flag for “REALmobileControl” for use in the REALmobileControl struct:

Desktop control:

I’ve fixed a few bugs and cleaned up the project, but I still can’t see my TRMetalImageView plugin control in iOS projects. No errors are shown in the Loaded Plugins panel:

I assume that the iOS Simulator plugin part is required because that’s the minimum that’s produced in the Eye Control example. To confirm, I’ve even added the EyeControl example plugin (Mac arm 64, iOS Simulator) to my plugin package:

EyeControl is available in the IDE for desktop apps, but just like my TRMetalImageView, it won’t show up for iOS projects.

I have the latest branch here. Perhaps someone with more experience could quickly see what’s going on? :thinking:

Am not sure anyone has experience

At least I have not built any iOS control.

The EyeControl plugin is a XOJO example in the SDK; At a minimum, I would expect that to work, unless there’s a XOJO bug or I’m packaging the plugin incorrectly. :thinking:

Grab TypeLib from me and Unzip it and then compare to your packaging.

1 Like

That was good to check. I unzipped TypeLib, dropped my plugin parts in it, reziped and renamed it, but only the Mac part loaded, so it must be something else.

I’m not sure why XOJO’s EyeControl is still not loading; I updated the SDK and architectures, of course.

It’s showing up for me:

Did you make sure to enable support for this in your macOS build? See EyeControlPlugin.cpp

// Enable if this platform supports building for iOS
#define SUPPORTS_IOS_TARGET 1
1 Like

OK, this is great, thank you. Yes, now I see it. Something is now off in my project’s iOS target; I’ll work on creating a new target based on EyeControl

OK, still at this. I’ve duplicated the two (desktop, mobile) targets in Eye Control’s Xcode project and added my plug in code:

image

The build settings for my plugins are identical to Eye Control’s. Everything compiles nicely and is bundled into a plugin:

On desktop projects, EyeControl and my plugin appear.
On iOS projects, only EyeControl appears.

I’m not sure what’s missing at this point, but if anyone’s feeling curious or helpful, I have the branch here:

The modified Eye Control project’s in the "Eye Control - Modified” folder.

I don’t have answer to why it does not show up…

but i have other tips for you…

for properties

you need to add to the signature RBInteger param so you dont get memory clobbering issues

static void * TRMetalImageView_image_getter(REALcontrolInstance);
static void TRMetalImageView_image_setter(REALcontrolInstance, void *, void *);

You sort of have it in your setter, the void* is same size as the RBInteger, making the void* fix it there, but your getter is missing it totally.

correct would be

static void * TRMetalImageView_image_getter(REALcontrolInstance, RBInteger param);
static void TRMetalImageView_image_setter(REALcontrolInstance, RBInteger param, void *);

or since you likely wont care about the value in the param:

static void * TRMetalImageView_image_getter(REALcontrolInstance, RBInteger);
static void TRMetalImageView_image_setter(REALcontrolInstance, RBInteger, void *);

And REALpropRuntimeOnly is for properties only, so does nothing or collides with bitmask on the methods. (So either does nothing or possibly something you dont want)

1 Like

Further look then I think the problem is that your macOS plugin is not registering the Mobile control.

Remember IDE cannot run the iOS plugin, so no way IDE will know about your control unless you register it on the IDE platform.

So you would register it there and then just have #ifdef in its code so the macOS version of the mobile control does nothing but to tell “I am here ,and this is my name” and it also would tell the IDE the names of all the properties and methods. So exposes the interface basically. But you would leave it without implementation on the IDE platform except probably enough for the IDE to know how to draw it in design mode I imagine.

1 Like

@Björn_Eiríksson Thank you, that’s probably where I went wrong, and where I noticed a reference to the iOS control in the desktop control. I think I know where to narrow it down now…

@Björn_Eiríksson I got it now, thank you.

The plugin needed to register both macOS and the mobile version; once it did, everything showed up as it should. There was also a detail about C++ that I wasn’t familiar with that caused an issue.

I took a look at your fixes for the properties, thanks!

Now on to the next issue, compiling. While I can get all the controls to show up in the IDE, they will not compile for the simulator, not even the Eye Control example plugin. :sweat_smile:

John

2 Likes