How to write extensions for all versions and how to test them?


#1

Hi there!

I was wandering what’s the best practice for writing extensions these days? I’m still on SU pro V8 and ruby 1.8.6. I’ve noticed a lot of fuzz going on about upgrading existing plugins to 2014(?) , 2015 and 2016. So what are the pitfalls I should avoid while writing scripts? Is there a fail-save strategy to do it??

Other question: How to test my extensions with different versions of SU? I tried to run 2016PRO in a virtual-machine but that doesn’t work…

I’m also planning to install 2016-make. Will I then lose my SU 8 PRO?

Many thanx!


#2

to test against ruby2 you either need a later version of SU or an independent install of ruby 2…

you can keep v8 and have other version…

install v16 the you can instal a ruby gem ‘rubocop’ to check the syntax of any old plugins in a click…

john


#3

For many authors, the current practice is to set a cutoff point and simply not support versions older than that. Alas for you, SketchUp 8 is largely considered to be obsolete. Too much hassle testing and then supporting code that spans old versions (8 is, after all, 4 versions behind!).

There are, of course, API fixes and tweaks from version to version. The release notes for each version describe these. Possibly the largest change though is that SketchUp converted from Ruby 1.8 to Ruby 2.0 in SU 2014. I won’t try to list everything you might have to deal with. If you search the web you can find discussions of converting old 1.8 scripts to 2.0 and of making 2.0 scripts backward compatible. One very important change was to full support of UNICODE characters. This required significant rework of how strings and characters behave, which broke many older plugins.

Regarding your other questions, you can install and run multiple versions of SketchUp on the same machine without first uninstalling anything. The only problem I know of is that on Windows the most recently run version may reset the “open with” to itself, potentially causing confusion about which versions can open your model files.


#4

Assuming you write pure Ruby and don’t also write binary Ruby C extensions then it shouldn’t be too hard if your base is SU8. The SketchUp API doesn’t have many breaking changes (there might be some in terms of bug fixes, but generally you shouldn’t need to worry about that.

The biggest change would be syntax change between Ruby 1.8 and 2.0. (The major changes actually happened between Ruby 1.8 and 1.9 - but SU jumped straight to 2.0). You should be able to use any general Ruby 1.8 => 1.9/2.0 migration guide.

Why do you try to run in a virtual machine? Major versions of SketchUp can run side by side without affecting each other.

These days the oldest version I support when I write new extension is SU2014. This is due to it having Ruby 2.0 with StandardLibrary support which greatly help development. The API also got a lot of improvements since then - and in some cases I support only 2015 and up because I rely on the new features.

The number of users using SU 7 or older is pretty slim these days - and SU8 and SU2013 is also decreasing a lot. Even for my commercial extensions I don’t find them significant enough to support any more.


#5

Hello,

He guys, thanx for your answers!

He Thomas, that’s a nice screenshot. Makes me feel a little nostalgic :yum:
though I started with version 6!

Nice answer too! I already got the pdf with the migration guide.
How about pro V8 along the free versions? And is there any reason
to test against pro versions?

Thank you!


#6

Same here - I acquired these older relics by digging through the old installers of my old job. :slight_smile:
Had a play around for curiosity sake: https://plus.google.com/u/0/photos/+ThomasThomassen/albums/5628506713642227441/5628506713285520770?pid=5628506713285520770&oid=103450081381233788032

As for multiple version of SketchUp. You cannot have Make and Pro side by side of the same major version. You need to choose. Unless you really need some pro features you can stick with Make - it has most features anyway.