Cross platform / device projects

I am currently building a desktop application for Windows and Mac which is fine. But I can see the need to write a browser based version and an iPhone and iPad and maybe Apple Watch and Apple TV version in future.

I know Xojo has ways to have external classes and stuff but i really need help on the best approach to minimize having to rewrite the different parts from scratch and want ti get the best code reuse as possible.

Thanks

Which version control software do you use?

Hi Greg, currently none as it is just me and never really seen the point as I have always found them really complicated to setup.

what you really want is this
<https://xojo.com/issue/17907>
so you can have a single “solution” that incorporates a desktop, ios, web, android, console project all in one and its dead easy to share code between them and generate multiple executables from a single xojo “project”
you’d use compatibility flags on various bits to say what can easily be shared between the items that get built
the build setting would have a way to “add target” so if you started with a desktop project you could “add” an IOS target and then that project would when compiled be able to generate a desktop & ios project
and you could “add” web, console and android

or maybe several with names

sigh … :frowning:

I cant read the feedback but what you said is exactly what I want, how do I do that?

I emailed Nathan the text from that case.

Thanks Dave, so I am guessing that the Feedback case has never actual come to a reality :frowning:

We all pretty much created bits and pieces of what is needed to address all the platforms. Basically, the trick is to move most of program logic from controls to modules.

Unfortunately you dont today
Thats why thats a feature request

It would make it so you dont have to have SVN or some other external system, version control or otherwise, to share code between related “projects”.

As it sits today you can do one of several things

  • copy code from one project to another and manually sync it (this has real drawbacks never mind being a pain in the butt)

  • save items as external and have one project as the “master” copy and the rest import that code as external items into others

  • on macOS you can use aliases from one project to another to “share” code
    it can be a little tricky to get set up initially when adding to a project but then everything just appears to be internal
    I’ve never tried it with Windows links so I dont know if it will work as well there and it may not

  • use the facilities of some external system like SVN externals, etc

Oh, well I won’t go into the sales pitch about them, but I will say that if you take the time, I think you’ll be happy that you did.

That said, if you were using Subversion, you could use the SVN External mechanism to share things between projects. We use that here for a few things. Basically you can link to directories in other projects and even to particular versions of them if you want. The advantage is that you don’t have to upgrade all of the projects that share code at the same time. it’s quite liberating.

If you’re looking for an easy installer for Subversion or Git, check out the packages from Wandisco.

XML and external items. You can add your classes/modules to your projects as you like.

Thanks everyone.

Realistically is it likely that Xojo will ever (in the next couple of years) get to a point where you can have a single codebase for cross platform / cross device development or is it time to go and look at something like LiveCode when this type of thing is needed?

I really don’t want to move away from Xojo and the way I am developing things now is that I have an API server using Xojo / Aloe which appears to work really well. I am now at the point of writing the frontend for different platforms and devices in Xojo that communicates with the API server but it does feel like I am going to end up having to use glue and sticky tape to make it work rather than having a shared codebase with different UI layouts for different platforms / devices.

Everything is held together with duct tape, spit and prayers nowadays. Code that made sense when you wrote it is unreadable or never worked. That’s quite normal.

One thing to keep in mind is that how you code for these platforms can be very different from one another too.

Take Web for example. Web apps are actually two applications which communicate with each other asynchronously over the web. That means you can’t do things quite the same way as you would on the desktop. For instance showing a dialog does not stop xojo code execution on web like it can on desktop.

iOS is the same way in many respects. iOS listbox is a good example. We made a mechanism to make it work like desktop listbox by allowing you to use AddRow, but doing it asynchronously gives you and your customers a much better scrolling experience because you’re doing what the os expects.

So in terms of sharing code, I think you’ll find that sharing the underlying stuff, that which makes your application yours, and then building individual UI to work the best that it can on each platform will give you the best overall experience, for you and your customers.

And to be clear… we do use SVN externals here and they work brilliantly for sharing code between projects.

Here’s some code sharing and source control info (with videos):

I use often Xojo Unit test, When I open the project (desktop or console) the shared resources in the project looks like this:

Folder=XojoUnit;../Shared Resources/XojoUnit;&h000000002516B04D;&h0000000000000000;false Folder=Tests;../Shared Resources/XojoUnit/Tests;&h0000000044C729E7;&h000000002516B04D;false Class=XojoUnitSuperClassTests;../Shared Resources/XojoUnit/Tests/XojoUnitSuperClassTests.xojo_code;&h000000003A8067FF;&h0000000044C729E7;false Folder=TestFramework;../Shared Resources/XojoUnit/TestFramework;&h000000003E1A9B41;&h000000002516B04D;false

when I save in other location look like this:

Folder=XojoUnit;Shared Resources/XojoUnit;&h000000002516B04D;&h0000000000000000;false Folder=Tests;Shared Resources/XojoUnit/Tests;&h0000000044C729E7;&h000000002516B04D;false Class=XojoUnitSuperClassTests;Shared Resources/XojoUnit/Tests/XojoUnitSuperClassTests.xojo_code;&h000000003A8067FF;&h0000000044C729E7;false Folder=TestFramework;Shared Resources/XojoUnit/TestFramework;&h000000003E1A9B41;&h000000002516B04D;false

As you can see is a copy of the project, but I need is a link, so I change the saved project like this:

Folder=XojoUnit;../../XojoUnit/Shared Resources/XojoUnit;&h000000002516B04D;&h0000000000000000;false Folder=Tests;../../XojoUnit/Shared Resources/XojoUnit/Tests;&h0000000044C729E7;&h000000002516B04D;false Class=XojoUnitSuperClassTests;../../XojoUnit/Shared Resources/XojoUnit/Tests/XojoUnitSuperClassTests.xojo_code;&h000000003A8067FF;&h0000000044C729E7;false Folder=TestFramework;../../XojoUnit/Shared Resources/XojoUnit/TestFramework;&h000000003E1A9B41;&h000000002516B04D;false

It works, xojo read “relative paths” but can’t saved. so I make a script for replace and save the project with a helper utility xopo, it works with others “libraries/components”. I made Last week a REST client for a project I work on, so I need add the lines to replace in the script, that is the disadvantage. Other problem is when the original shared resoruce has a file added, the others projects shows errors, so I delete and copy/paste the resource.

There is no the ideal solution, but it works for me, maybe if xojo could save the files with relative path solves the sharing problem.