Using external framework in a plugin

waxtastic's picture

I'm working on my first plugin for QC. It's an OSC sender that sends messages that are compatible with Animata. Meaning that it can send messages that mix strings and floats. I'm using the VVOSC framework and I got it working! I'm pretty excited as I'm really a noob when it comes to this stuff.

The problem is that the plugin doesn't work unless I have the framework in my /Library/Frameworks folder. I tried following the instructions on the VVOSC comments:

Quote:
\section USE-FRAMEWORK Using the VVOSC framework -# open your project file in xcode, drag the compiled "VVOSC.framework" into it. -# from xcode's project menu, add a new "copy files" build phase to your target. -# expand your target, drag "VVOSC.framework" (from your xcode project) into the copy files build phase you just created. -# double-click on the copy files build phase you made. under the "general" tab, select "Frameworks" from the destination pop-up button (you're trying to make sure "VVOSC.framework" gets copied into your application package's "Frameworks" folder). -# use the framework in your source code with "#import <VVOSC/VVOSC.h>

I was able to get this working when I made a little test Cocoa application. But it doesn't work with the plugin. So I guess doing a plugin is different from a standalone app in this sense.

Can somebody help me with this? I can post the source code too if you want to see what's going on.

And oh yeah, I'm using the official API, if that makes a difference.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

waxtastic's picture
Re: Using external framework in a plugin

And this is the error message that I get when I don't have the VVOSC framework in the frameworks folder:

Quote:

(null) QCPlugIn: Cannot preflight plug-in at path "/Library/Graphics/Quartz Composer Plug-Ins/AnimataOSC.plugin" (Error Domain=NSCocoaErrorDomain Code=3587 UserInfo=0x1a3caee0 "The bundle “AnimataOSC” could not be loaded because it is damaged or missing necessary resources." (dlopen_preflight(/Library/Graphics/Quartz Composer Plug-Ins/AnimataOSC.plugin/Contents/MacOS/AnimataOSC): Library not loaded: @executable_path/../Frameworks/VVOSC.framework/Versions/A/VVOSC Referenced from: /Library/Graphics/Quartz Composer Plug-Ins/AnimataOSC.plugin/Contents/MacOS/AnimataOSC Reason: image not found))

So it just doesn't find it. Although when I do "Show Package Contents" on the plugin, the framework is in there. What am I doing wrong?

vade's picture
Re: Using external framework in a plugin

Recompile VVOSC with your linker path to be @loader_path or @rpath (but rpath requires your bundle or app to have runtime paths set up. loader_path is prob easier to use, but rpath is 'the future'. :)

Extra points for setting up VVOSC as a target dependency ;)

waxtastic's picture
Re: Using external framework in a plugin

Thanks a lot! After reading what you wrote maybe 14 times and with the help of Google I think I managed to do what you said.

At least it works now.

Only one issue left. When I close the viewer or hit the stop button and then open it/press run, it stops working. So I guess I need to add something to - (void) stopExecution:(id)context

Probably need to release the port somehow.

I always thought that I'm not smart enough to write plugins, but now I made one in one day. Once I get this done, I'll start working on some other plugins also.

waxtastic's picture
Re: Using external framework in a plugin

Wow. I actually managed to fix that. It's working perfectly now!

I attached the plugin on this post. I'll post the source, sample files and video tomorrow. I need to get some sleep now.

Let me know if it's not working for you.

PreviewAttachmentSize
AnimataOSC.plugin.zip108.34 KB

gtoledo3's picture
Re: Using external framework in a plugin

It's not that hard! That's why I always poo poo people when they go "ooooh, processing or ____ is more flexible than QC". Well, the idea is that you can augment QC or use it in apps with other resources.... that said, I've never done an original project and all my plugin stuff has been based on taking Apple or Open Source projects, looking at them until stuff starts making sense, changing stuff around, recompiling, and seeing what happens.

I really admire anyone that is doing plugs in QC, because if you use the standard API you are pigeonholed in a lot of ways, and then if you use the non-standard setup, it comes with a whole other set of baggage and risk.

I'm looking forward to checking this out!

echolab's picture
Re: Using external framework in a plugin

wow, it's working...cool.

(using animata r47)

waxtastic's picture
Re: Using external framework in a plugin

Excellent! And for anyone else trying this out. You will need to build Animata from the source to make all the messages work.

waxtastic's picture
Re: Using external framework in a plugin

I made a separate thread for discussing the plugin http://kineme.net/Discussion/Programming/AnimataOSCPlugin since I got the answer for my problem.

DO NOT use the plugin that's attached on this thread. It has some bugs with the Joint and Bone patches. I can't edit that post anymore. Download the finished plugin from here http://mansteri.com/software/