Binding to macOS Frameworks and Discrepancy between macOS versions

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Binding to macOS Frameworks and Discrepancy between macOS versions

Post by PaulDaMacMan » Mon Aug 02, 2021 3:08 pm

Just an FYI in case anyone else hits up against this problem...

I needed to extract some text from a handful of PDF files, so of course instead of just manually copy/pasting the text, I decided to go the long and winding road and make another LiveCode Builder library (and a widget to boot).

So I created binding strings for Apple's PDFKit framework

Code: Select all

binds to "objc:PDFKit.framework>PDFDocument.+alloc"
Which was all well and good on the 10.15.x macOS machine I started development on...
Then I wanted to make some updates via my laptop which is still running macOS Mohave 10.14.6, the LCB code compiles but when any PDFKit stuff is called an error is shown (something like "can't binding to foreign library")...
I figured out the problem, it seems that in versions of macOS prior to 10.15.x PDFKit.framework was sort of a sub-framework and resided inside the bundle for Quartz.framework, in versions above 10.15.x PDFKit.framework is now seperate from the Quartz bundle, which is why my original binding string worked on 10.15.x but not 10.14.x! The binding string for macOS 10.14 should be as follows:

Code: Select all

binds to "objc:Quartz.framework>PDFDocument.+alloc"
So...just be aware you may have to have code to check macOS version number and have seperate binding strings to account for Apple (or I guess other OS vendors too) changing things (libraries) around.
Last edited by PaulDaMacMan on Tue Aug 03, 2021 1:31 pm, edited 1 time in total.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: Binding to macOS Frameworks and Discrepancy between macOS versions

Post by PaulDaMacMan » Mon Aug 02, 2021 3:45 pm

Actually it seems the "whatever.framework>" part of the binding string can be omitted entirely, so great, no need for seperate bindings!
This should work on both macOS versions:

Code: Select all

 binds to "objc:PDFDocument.+alloc"
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

Post Reply

Return to “LiveCode Builder”