How to create Xojo plugin using Xcode

The most of us have 64 bit targets and are waiting on something special :slight_smile:

Hi, I see that XoJo plugin pdf for Xcode is no longer available. Is it somewhere else?

Here’s a copy of the PDF. I couldn’t find his DemoPlugin but included the test I built from his docs
http://home.comcast.net/~trochoid/XojoPluginMatthewGardner.zip

edit: maybe I shouldn’t have included my test because i don’t remember if I left it in a functioning state. It was at one point if not :slight_smile:

Thanks very much. Much appreciated.
I’m hoping to integrate some C into XoJo via Xcode.
This will be a big help.

Will Shank, thanks for providing this. I’m going to try it with some math libraries and i’ll post the result.

There is also http://great-white-software.com/miscellaneous/Plugins%20Getting%20started.pdf

Norman and Will, Thanks for the zip and pdf files. Based on what you sent i was able to get it to work. In the hopes it will help others, here is the shortest description of what i did to make it work using the 2014 r 1.1 build of Xojo.


In Xcode i constructed a new project where i built a dynamic library (it says Cocoa in the description, but i get passed that in the next step.
In the next step choose “None” for Framework and “Dynamic” for library type.
I included code files by using the File/“Add Files” menu item to add each source file. Norman offers a different way to direct the compiler to find the headers.
Norman’s pdf makes very clear that you must make the architecture 32-bit Intel. This is very important since Xojo is still 32-bit. Please see item 5 in his PDF for a picture of what to do. If you fail to make this change, the dylib will default to 64-bit and when you run the app it will crash. The crash report will indicate that the dylib was not a match for the app but it won’t tell you it was a 32 vs. 64 bit problem.
Use Product/Build to construct the dylib.
In Xcode you must let the program know where the dylib will be located and declare the function. For my test i just called into my dylib and printed the result in a msgbox. In a window Open event i put

CONST dylibLocation = “@executable_path/…/Frameworks/libXojoDyLibTest.dylib”
Declare Function chisqr lib dylibLocation (dof as integer, cv as double) as double

msgBox "chisqr(1, 0.08) -> " + str(chisqr(1, 0.08))

You will note that the parameters i passed to chisqr() were integer (32 bit by default) and double. I did this to ensure that the parameters would pass properly. For C/++ pointer types preface your Xojo declaration of the parameter with ByRef. I haven’t tried passing Arrays or Classes yet.

I built my Xojo project for Mac OS (not My Computer) and copied the dylib into the Frameworks folder of the resulting application. Double click the app and it should work. Ultimately this is how you would deliver your application to others. Alternatively for testing purposes, you can use the menu item Project/Run Paused to build for debug and then add the dylib to your Framework folder of the resulting app - you will have to do this each time you run “Run Paused” because Xojo will overwrite your application with each build. Alternatively you are supposed to be able to place the dylib in the Xojo Frameworks folder, but i didn’t try that. Alternatively you should be able to use Run with the startup script to copy the dylib into the Frameworks folder instead of using the Run Paused.

I hope this helps, but if you find anything confusing in what i’ve said, or you think i’ve made some error, please let me know and i’ll correct this posting.

… jeff

The Insert/Copy Files for the dylib placing it into the Frameworks folder worked as expected for the OSX build, however, Xojo rejected my attempts to add it to the My Computer build. The good news is that adding the dylib copy to the OSX build apparently was added to the My Computer build. When i ran the My Computer build the application worked.

I’d like to develop my first plugin. Many thanks for help, with the tuto of Norman, I can run Complete Module.

But my project is cross-platform Mac and Windows… For the the final build in Xojo, what is the process ? You must put both compiled versions : one with Xcode and one with VS Studio ?

Read the packaging docs in Extras Plugin Packaging that is next to the IDE

It was what I had been searching for. I can build the example CompleteModule for Windows and MacOS.

Many thanks for the tutorial and your help…

This might be a stupid question,but i need to do it. So,here I go: The plugins made on Xcode only run on Mac, right? Or it works on linux and windows also?

Thanks

Theoretically you could set Xcode up to cross compile but … blech

Use Xcode for OS X
VS for Windows
gcc for Linux

Is there a good UTD documentation+examples available how to write Xojo plugins?

I’ve been using Xojo for some years and have only seen a couple of elite plugins coders
but not Xojo encouraging devs to write plugins. Seems like it isn welcomed ?

The only thing that really has changed is the version of Xcode VS etc

Hi Matthew,
I am using a lot of numerical analysis tools.
I want to know how to build an appropriate plugins for windows with C or C++.
Any doc. , example or link ?
Regards.

Please make a new topic!

1 Like