Run Objective-C framework in Apple's Script Editor

I have discover a way to execute Objective-C framework in Apple Script Editor.
The credit goes to Shane Stanley for his handlers to use Automator workflow with AppleScript.

Ps. This script should be run in Apple’s Script Editor and do not expect it to be fast.

To make this work we need to make an AppleScript Action in our Automator workflow with:

on run {input, parameters}
	run script input
end run

Save that to Desktop.

PS. You need to edit in the below script the path to the Automator workflow.

use AppleScript version "2.5" -- macOS 10.11 or later
use framework "Foundation"
use framework "Automator"
use scripting additions

property theResult : missing value
property theError : missing value

on runWorkflow:theObject
	set {theURL, theInput} to theObject as list
	set {my theResult, my theError} to current application's AMWorkflow's runWorkflowAtURL:(theURL) withInput:theInput |error|:(reference)
end runWorkflow:

set theInput to "use framework \"Foundation\"
use scripting additions
use theLib : script \"BridgePlus\"

set theString to theLib's sortListOfNumbers:{9, 2, 7, 3, 6, 4}
set theString to stringFromList(theString, \" \")
return theString

on stringFromList(_theList, theDelimiter)
	set array to current application's NSArray's arrayWithArray:_theList
	set theString to array's componentsJoinedByString:theDelimiter
	return theString as text
end stringFromList"

set thePath to "/Users/f.gustafsson.user/Desktop/runAS.workflow"
set theURL to current application's NSURL's fileURLWithPath:thePath
my performSelectorOnMainThread:"runWorkflow:" withObject:{theURL, theInput} waitUntilDone:true
if theError is not missing value then error theError's localizedDescription() as text
return theResult as list

Other Script from Shanes samples’s from MyriadTableLib

use AppleScript version "2.5" -- macOS 10.11 or later
use framework "Foundation"
use framework "Automator"
use scripting additions

property theResult : missing value
property theError : missing value

set theScript to "
use AppleScript version \"2.4\"
use scripting additions
use script \"Myriad Tables Lib\" version \"1.0.9\"

property rows selected : «class !©Zs»
property values selected : «class !©Zv»
property values returned : «class !©Zd»
property button number : «class !©Zb»
property timed out : «class !©Zt»
property final position : «class !©Fp» 

set theHeads to {\"First Name\", \"Last Name\", \"Password\", \"Index\"}
set someData to {{\"Saga\", \"Norén\", \"password\", 1}, ¬
	{\"Rasmus\", \"Larsson\", \"\", 2}, ¬
	{\"Freddie\", \"Holst\", \"\", 3}, ¬
	{\"Claes\", \"Sandberg\", \"\", 4}, ¬
	{\"John\", \"Lundqvist\", \"\", 5}, ¬
	{\"Annika\", \"Melander\", \"\", 6}}

-- typical process: make table with \"table dialog with data\", modify if required, then display
set myTable to make new table with data someData with title \"Sample table\" column headings theHeads with prompt \"You can select multiple rows. Everything is editable. Uses a row template. The Password field’s values are hidden.\" editable columns {} row template {\"\", \"\", \"hidden\", 1} with multiple selections allowed, row numbering and empty selection allowed
modify table myTable grid style grid both dashed between rows
set theResult to display table myTable

-- Property values.
-- return rows selected of theResult
return values selected of theResult
-- return values returned of theResult
-- return button number of theResult
-- return timed out of theResult
-- return final position of theResult
"

on runWorkflow:theObject
	set {theURL, theInput} to theObject as list
	set {my theResult, my theError} to current application's AMWorkflow's runWorkflowAtURL:(theURL) withInput:theInput |error|:(reference)
end runWorkflow:

set theInput to theScript

set thePath to "/Users/f.gustafsson.user/Desktop/runAS.workflow"
set theURL to current application's NSURL's fileURLWithPath:thePath
my performSelectorOnMainThread:"runWorkflow:" withObject:{theURL, theInput} waitUntilDone:true
if theError is not missing value then error theError's localizedDescription() as text
return theResult as list