Adding frameworks to macOS and iOS plugins

Now that my first plugin is working, I’d like to expand on it. All of my macOS and iOS Xcode projects use an Objective-C framework, TinrocketCommonLibrary, that I’ve developed over a decade. It contains code that I need to keep in framework format (mainly Metal shaders compiled by Xcode).

If I link my .framework from my plugin code, should I embed it, or does the framework need to be copied over in a build step in XOJO? Any advice on direction would be appreciated.

The framework code also refers to its bundle (e.g., [NSBundle bundleForClass:…]) when loading shaders and nibs. I’m keeping my fingers crossed that it will be able to find the runtime resources it needs.

The very latest Xojo version has something to embed a library.

I have not tried it so no idea if it actually works.

And of course it would only work with the very latest version.

1 Like

Thanks. Perhaps I found it: Copy Files build step (before the sign step) to copy my .framework folder into the Frameworks folder of my built app.

I’m currently facing a crash-at-launch when I bring everything together. Here are my build steps:

In XCode, I’m keeping it simple, to start: I’m not accessing my framework from code yet, I’m only building my plugin with it:

When I build the iOS Device and iOS Simulator plugin targets in Xcode, I get the plugin and a .framework folder:

I copy these .framework folders into the app, depending on which target I’m buliding in XOJO:

However, there’s a crash (both device & simulator) that’s happening right when my plugin is loaded:

There’s a lot of steps in between where things can go wrong. Not sure where to start.

I’ve verified that my plugin .dlyb is being linked (rpath resolves to the Frameworks folder, IIRC)

And that my frame is actually present:

Does not look like the structure they list in their documentation


They have “Libs” folder there in between.

Is also question if they support framework folder or just dylibs.

My last screenshot of the directory structure is what’s produced by XOJO; the iOS app’s package.

However, let’s give that a try and put the .framework directory in a Libs subdirectory in the plugin:

Still a crash after Xojo._InitPluginEntrypoints

Try taking just the dylib from the framework maybe ?

[quote="Björn Eiríksson, post:6, topic:80903, full:true, username:Björn_Eiríksson”]
Try taking just the dylib from the framework maybe ?

I think it’s going to need the whole framework: The folder has metal shaders, images, nibs, strings, and other required resources.

Also, the plugin .dylib has that search path reference to the framework folder.

Your framework is signed with Same identity as the app?

Does it crash as Xojo maybe tries to load your framework as plugin and aborts as the entry function isn’t there?

Check console for a message related to this.

Correct, it’s signed with the same developer identity.

There’s no bundle id or profile on the plugin, and the launch crash happens on both the simulator and device.

I’m not sure if XOJO is trying to load the framework as a plugin; this is all the console shows (same as my last console screenshot) — a crash at RuntimeLoadPlugin

You might want to quote William here to ask if its possible at all to copy whole Framework there or if it is only for dylib. Since the documentation is not clear on it. So you don’t waste your time on something that might not be possible.

1 Like

Good idea, thank you!

Hi, @William_Yu—is it possible to link an iOS or macOS .framework with a plugin, and include the .framework folder/bundle in the app? This thread is documenting a crash at launch when I try to do this.

Well, that depends on how things are setup. It’s quite likely we have not setup the correct library search path for this to work if you put the framework bundle in the Frameworks directory. Have you tried copying your framework bundle, that your plugin depends on, directly inside (top-level of) your app bundle?

1 Like

Thank you. Yes, I tried all the location options in the CopyFiles build step.

If not for frameworks, what’s the Frameworks folder destination used for then? :wink:

Folders, Versions, Symlinks, Info.plist … everything setup as in the docs?

1 Like

Yep, this is a production framework that’s been used for almost a decade.

So it seems a Xojo bug. Looks like they are assuming something about the Frameworks and your bundle is interfering with their assumptions.