To the Tip: Importing Modules Exported as Xojo Code

Importing xojo code is not a problem.
I’m exporting my library with all my framework xojo code as text.
But for importing, I do NOT use the import option from the menu, I drag the library into the project, this works perfectly !!!

A fixed import function does not mean it is possible to have modules containing classes as external project items now, or is it?

1 Like

It looks like it’s not working… i can’t get this to work. Export or Import…
Ohh well the xojo_code module file does not contain everything so nothing changed ?

Importing a module with all classes was possible, but just not in 1 file (the xojo_code file did not contain the classes, still doesn’t?)

Well this is an opportunity for me to ask about best practices for doing in Xojo the equivalent of adding a project to a solution in, say, a Visual Studio C# project.

Put another way, I have a pilot Xojo desktop project. Along the way I’ve subclassed a couple of controls and created a couple of helper classes. These are all in the project I’m working on for initial development and convenience, but could all be reusable in other code bases. In other environments I would put these classes in their own project, probably representing compilation to a separate DLL, and then either the project or the DLL could simply be added to any solution that can use it. I have not offhand found documentation of how this is done in Xojo in such a way that I’m not working on a copy of the shared code but truly sharing code between my solutions.

So how is this SUPPOSED to work: one exports one or more classes from Xojo project “A” to a new Xojo project “B” which becomes the place this code will be maintained – a “library” of sorts – then imports from that project “B” into some other project “C”? To me, importing sounds like bringing in a copy, not referencing an externally maintained unit of code. But maybe I don’t understand the semantics.

Part of the problem for me coming from other products is that I’ve become accustomed to working on a solution consisting of multiple projects. It appears each Xojo app is a self-contained “project” that doesn’t reference anything else, but into which you can import code from other projects, which will then be merged into your tree of stuff on the dev environment Contents pane. But you then have to remember to maintain your code in some other project and re-import any changes??

Maybe what I’m after really is the plug-in architecture, which I haven’t looked at, though I have the impression that at present you can’t create Xojo plugins in Xojo.

If some kind soul could bring me up to speed here or point me to the docs I’m not finding, I’d be grateful.

I will confess I didn’t really understand what “improvements” were made. But you can right click a project item and “Make External”. That makes it a separate entity that you can then import into another project as an External item. After that, any changes you make in one project will be reflected in any other project that uses that external item. I have a large library of external modules and classes that I use throughout all my projects.

1 Like

Yes Tim, this is the only way which works for me. I use a special folder to move always the latest version of my common library where I copy it from when needed.

So Tim, to be clear – if I have a project “A” and make an item in that project external, it becomes a separate project “B” which if imported into another project “C” always references “B” as the source of truth, such that maintaining “B” from either “A” or “C” will actually be editing “B” for that item?

I would hope that would be the case, otherwise, “A” and “C” would just have their own copies of “B” and you would have to remember to make changes to “B” directly and re-import into “A” and “C” (and “D” and “E”, ad infinitum) every time there’s a change – which would be asking for trouble, sooner or later.

Yes, that is correct. “B” becomes it’s own entity. Any changes to it will be reflected in all projects that refer to it as an external item. Note that you can add it to a project as a not-external item and then it just makes a copy of it in that project, separate from the shared “B” project.

There is no super build option that rebuilds everything dependant upon B. However, you are likely wanting to test and adjust other projects for changes in B rather than just recompiling everything.