Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Interested adding externals/plugins from LiveCode and third parties to your LiveCode projects? This is the place to talk about them.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
acarlton
Posts: 4
Joined: Sun Oct 07, 2018 9:28 pm

Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by acarlton » Mon Oct 08, 2018 12:32 am

Hello LiveCode community!

I've taken over maintenance for an old LiveCode application which uses a custom external library written in C. The application is no longer working with recent platform and I'm reasonably sure that complications with the external are to blame. I'm new to LiveCode and don't use Xcode frequently.

I decided to build a simple external using the most recent LiveCode documentation I could find (from Nov 2006):

http://newsletters.livecode .com/november/issue13/newsletter5.php

As i386 architectures are no longer supported, I've removed the PowerPC-32 and x86-32 from all Xcode project build target configurations, and i386 from the list of valid architectures. These changes allow the project to build in Xcode properly.

Xcode 10 doesn't seem to have the same interface referenced by the old article for building in release mode. To perform the initial step of building in Release configuration, I have run Product > Archive from the menu.

When I then 'Run' the project, making sure the the build configuration from the 'manage schemes' interface is 'Debug', the LiveCode test stack rnaHelloStack.rev doesn't open automatically. I am able to make that happen by defining the LiveCode Indy 9.0.1.app executable for the scheme and EITHER:

1) Defining the working directory in the scheme options AND passing the rnaHelloStack.rev as an argument. 2) Choosing the Launch option for the scheme to 'Wait for executable to be launched' and opening the rnaHelloTest.rev file directly from the Finder after running the project.

In all cases, when the rnaHelloTest.rev is opened in LiveCode and I add the button handler script, the code halts execution at the call to the external function.

I have tinkered with the LiveCode code and variables. My best guess is that the external is not properly loaded into the stack. I've scoured for more recent documentation but have found nothing except this old forum post trying a similar thing:

https://forums.livecode .com/viewtopic.php?f=17&t=11295&sid=380a6fe4b12111f767fc863262a3acf9

How can I assure a simple external like this from the documentation is available to a LiveCode stack via the updated LiveCode 9.0.1 IDE and XCode 10?

Thank you,
Aaron

P.S. I also posted this question on StackOverflow, but decided the experts here might be a better source of help.
https://stackoverflow .com/questions/52692585/building-a-c-c-external-for-livecode-9-01-with-xcode-10

sphere
Posts: 700
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth

Re: Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by sphere » Mon Oct 08, 2018 11:59 am

Xcode 10 is not yet supported.
You need to use Xcode 9.4

See the release note under help in the IDE.
:D :o :) :shock: 8) :lol:

bogs
Posts: 2282
Joined: Sat Feb 25, 2017 10:45 pm

Re: Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by bogs » Mon Oct 08, 2018 12:31 pm

I'm not sure if this was intentional or not on your part, but all of the links you posted have a space in them breaking the link on the board posting.

The 'StackOverflow' link should read :
https://stackoverflow.com/questions/526 ... h-xcode-10

The 'Livecode forum' link should read :
viewtopic.php?f=17&t=11295&sid=380a6fe4 ... 3262a3acf9

Unfortunately, I don't have an answer to your question myself, although the topic has come up a few times in the past, such as this post about following the externals tutorial, but that was all the way back to 2010.

The 'Official' lesson for desktop externals I could find was this one Desktop Externals Guide, but that appears to be (from a quick scan) little to no different than your newsletter link.

Hopefully someone else that actually uses this route may chime in, otherwise you might be able to make use of the foreign interface parts to see if that is a road to resolution.

I see sphere already did :D
Image

sphere
Posts: 700
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth

Re: Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by sphere » Mon Oct 08, 2018 6:17 pm

well i don't know about all the things he is talking about Bogs, but he should start with the stuff that's supported as a base.
And perhaps it might work :)
:D :o :) :shock: 8) :lol:

Klaus
Posts: 10388
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by Klaus » Mon Oct 08, 2018 6:22 pm

Hi all,

I'm afraid "externals" had their time, but they are dead as dead can vbe and the future is FFI, as bogs already mentioned. Here an overview/introduction what that is:
https://livecode.com/docs/9-0-0/extendi ... -livecode/

Unfortunately this stuff is way over my head! :D


Best

Klaus

bogs
Posts: 2282
Joined: Sat Feb 25, 2017 10:45 pm

Re: Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by bogs » Mon Oct 08, 2018 7:48 pm

sphere wrote:
Mon Oct 08, 2018 6:17 pm
well i don't know about all the things he is talking about Bogs, but he should start with the stuff that's supported as a base.
And perhaps it might work :)
I completely agree, I was glad you answered while I typed out my complete ignorance on the subject :D

@Klaus~ so they are going to kill off externals for sure? I just thought FFI was going to be an addition to, not a replacement of externals :?

I'm glad my world is much simpler to deal with :P
Image

acarlton
Posts: 4
Joined: Sun Oct 07, 2018 9:28 pm

Re: Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by acarlton » Mon Oct 08, 2018 10:18 pm

Thank you all for your replies!

@sphere -- Thank you, I will give it another try under Xcode 9.2. Thanks for pointing me to the right place in the documentation.

@bogs -- Yes indeed, the spaces in the links were intentional. The forum post submission was giving me a validation error and citing that I wasn't allowed to post URLs? I have indeed seen both of the links you reference. The Desktop Externals Guide is a re-themed replica of the newsletter link from what I can tell, and even more broken at that, since copying and pasting the code from the page won't compile properly due to formatting errors. I've also seen that post on the external tutorial, yet it hasn't been of much use since I wasn't able to debug via Xcode propertly.

Yes, it looks like FFI is the future, thanks for pointing me in that direction. Although, I'm not sure how feasible refactoring my legacy app will be. :shock:

bogs
Posts: 2282
Joined: Sat Feb 25, 2017 10:45 pm

Re: Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by bogs » Tue Oct 09, 2018 10:31 am

acarlton wrote:
Mon Oct 08, 2018 10:18 pm
@bogs -- Yes indeed, the spaces in the links were intentional. The forum post submission was giving me a validation error and citing that I wasn't allowed to post URLs?
Ah, your still under 10 posts, links and pm'ing I think are affected by your status. I didn't notice it till your last answer Image

It is too bad about the errors in the tutorial, but you might reach out to the company through the support contact email address on this page. For a company, they (usually) respond very quickly.

As to whether refactoring the app is worth it or not, that is a tough call, and depends on a lot of things. You said the application is no longer working with the recent platform, is there a reason you would need it on the 9.x series, or would you, for instance, be able to work with it on the 7.x series? Huge changes, but if you know what platform broke it, you *might* be able to work on it through the platform before that. 7.x would be the most likely bet to have continued from using externals the way they are mentioned in that tutorial and is 64bit, if it works in 8.x so much the better, thats only one stage behind current and might give you time to further study.

Or maybe you'll find it isn't an issue using Xcode 9.2.
Image

Klaus
Posts: 10388
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by Klaus » Tue Oct 09, 2018 3:44 pm

Hi all,
bogs wrote:
Mon Oct 08, 2018 7:48 pm
@Klaus~ so they are going to kill off externals for sure? I just thought FFI was going to be an addition to, not a replacement of externals :?
sorry, I don't know for sure, but it really looks like this might be the case.
No new external since a couple of years, everything is going "widget" nowadays
and the Externals lesson has been updated last in 2010!? :shock:


Best

Klaus

bogs
Posts: 2282
Joined: Sat Feb 25, 2017 10:45 pm

Re: Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by bogs » Tue Oct 09, 2018 4:34 pm

Could be. While bopping around the nether regions of the inter-webz, I found out Monte had put up "Xcode Templates for iOS, OSX and Android LiveCode Externals"

Hopefully that will help our ardent adventurer out a bit. I'm a bit surprised Brian hasn't chimed in, I keep thinking that boy must know a ton about this stuff.

*Edit - I came across this posting from Alex Tweedly explaining how he got this working in Dev C++ (formerly Bloodshed). I'm guessing some of it must cross translate.
Image

bwmilby
Posts: 212
Joined: Wed Jun 07, 2017 5:37 am
Location: New Orleans, LA
Contact:

Re: Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by bwmilby » Wed Oct 10, 2018 12:50 am

I haven’t messed with externals yet (other than the stuff already in the IDE that is mostly precompiled). It is an area I will look into one day.
Brian Milby

Script Tracker https://github.com/bwmilby/lc-misc/tree/master/ScriptTracker

acarlton
Posts: 4
Joined: Sun Oct 07, 2018 9:28 pm

Re: Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by acarlton » Wed Oct 10, 2018 6:12 am

UPDATE: I just downloaded Xcode 9.4 from Apple and re-tested the official instruction tutorial. The 9.4 version of Xcode has more-or-less the same interface as version 10, making the bit about "building for Release mode, and then Debug mode" similarly obscure. Again, I removed both the 32bit release build configurations and i386 as a valid architecture. Was able to "Archive" the project to simulate a Release build and then "Run" as a Debug build. Ultimately, is the same experience. LiveCode doesn't automatically launch without some additional tweaking, and even so, the call to the external function in the script gives an error, indicating to my best judgment that the external isn't loaded. No dice. :?

I suppose I can continue downgrading Xcode until I find a version that works.

@bogs --
  • I sent a support email to the LIveCode contact form indicating the issue with arcane documentation and providing a light summary of my experience.
  • I've also already seen that post and Github project by Monty about a new version of external project templates. I actually downloaded and tried to install them. They depend on a custom build of LiveCode in a specific directory. I got hung up on compiling LiveCode with its gyp dependencies before deciding not to spend too much time going in that direction.
  • That post from Alex Tweedly is interesting. There is some overlap, but his success was brittle enough that it doesn't sound like it can help much. It's making me wonder again, from some of the conversations I've seen in other discussions, if there is supposed to be some sort of External.txt file somewhere, which defines the externals available to the current stack and points them to the right location?

bogs
Posts: 2282
Joined: Sat Feb 25, 2017 10:45 pm

Re: Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by bogs » Wed Oct 10, 2018 3:20 pm

bwmilby wrote:
Wed Oct 10, 2018 12:50 am
I haven’t messed with externals yet (other than the stuff already in the IDE that is mostly precompiled). It is an area I will look into one day.
Boy I can't wait for that Image
:D

@ acarlton ~ Well, if anyone should know the answer, my bet would be on the support team. Too bad about Monte's templates, smart guy there, hopefully he'll chime in.

Really too bad Alex's post didn't sort it out for you, quite a few on the mailing list had success with it, I know Al posted in reference to it a few times as well (search "Alex Tweedly" in the nabble use-list).

My thoughts were if he could get it to run say, 4 of 5 times on a generic not-recommended setup, then that would probably be the way to go for almost anything recommended :|

I've seen the references to the text file you mention as well, unfortunately the amount of time I can devote to the search aspects of finding an answer to this are, at the moment, severely limited :evil:
Image

acarlton
Posts: 4
Joined: Sun Oct 07, 2018 9:28 pm

Re: Buliding a C/C++ external for LiveCode 9.01 and Xcode 10

Post by acarlton » Sat Oct 13, 2018 9:24 pm

UPDATE - I sent an email to support and got a response back. The overall message was that new projects going forward that need to integrate with anything outside of LiveCode should be done with LIveCode Builder, use FFI to interact without outside libraries. I was encouraged to consider the effort involved to port the existing application toward this approach. Additional help to support working on the old external API would require a support contract from LiveCode.

I'm a bit disappointed ancient and incorrect documentation sits lying about for the Externals API, even though its still referenced in the official documentation. However, it is good to know an absolute best-practices path forward.

Thanks all for your interest and support!

Post Reply

Return to “Using Externals and Plugins”