I found this code somewhere on this forum a few years ago. and it seems to work just fine
Public Sub Show_in_Finder(f as FolderItem)
Dim a As AppleEvent = New AppleEvent("misc", "slct", "com.apple.finder")
a.FolderItemParam("----") = f
If a.send Then
a = New AppleEvent("misc", "actv", "com.apple.finder")
If a.send Then
End If
End If
End Sub
But am I correct that this is NOT acceptable to the AppStore?
Also I need a similar routine to implement the QuickLook function (assuming it is not code inside Xcode which is where I saw it)
Just tried the command line myself, it launched a process which I kind of thought would happen, but what I didn’t expect was a new icon to appear in the dock. The /dev/null isn’t necessary at all it seems.
I can’t ever recall off the top of my head what the official stance is from Apple on using Shell in the app store, but this doesn’t seem like a very smooth solution because of the extra dock icon. QuickLook previews in other apps just open a quick look window (using Transmit 5 as an example).
According the the site where I found the QuickLook command, it said to add the Dev/Null to reduce the overhead of what is otherwise a long stream of “process data” that isn’t necessary
And it did say the Qlmanage “is not the same as the Quicklook in various Apple Programs”
So if you or anyone else has a better solution, I’m all ears :)…
And the Appstore question was aimed more at APPLEEVENT than at SHELL
You are correct.
Apple Script is permitted, but not for Finder, System Events, System Preferences or Terminal. It is also not permitted if it doesn’t use the newer “Scripting Targets”. Basically Apple Script is dead if you want to sell on the Mac App Store. And yes its the same for Apple Events also.
Sadly implementing QuickLook is not as simple as it should be, there is a cheat API for making the system generate a preview, but it’s also different than what you would actually see if you used the proper QuickLook Preview Panel.
declare function objc_getClass lib "libobjc.dylib" ( name as CString ) as ptr
Declare Function sharedWorkspace Lib "AppKit" selector "sharedWorkspace" ( obj As ptr ) As ptr
declare function selectFile lib "AppKit" selector "selectFile:inFileViewerRootedAtPath:" ( obj as ptr, fPath as CFStringRef, rootFullPath as CFStringRef ) as boolean
dim workspace as ptr = sharedWorkspace( objc_getClass( "NSWorkspace" ) )
call selectFile( workspace, f.NativePath, "")
[quote=372005:@Thomas Eckert]This does work.
A small correction though:
The assert line must removed and use “f.NativePath” instead of “f.PosixPath”.[/quote]
Thanks… I knew that “posixpath” HAD existed … but the LR says that SHELLPATH should have been the replacement
working code
Declare Function objc_getClass Lib "libobjc.dylib" ( name As CString ) As ptr
Declare Function sharedWorkspace Lib "AppKit" selector "sharedWorkspace" ( obj As ptr ) As ptr
Declare Function selectFile Lib "AppKit" selector "selectFile:inFileViewerRootedAtPath:" ( obj As ptr, fPath As CFStringRef, rootFullPath As CFStringRef ) As Boolean
Dim workspace As ptr = sharedWorkspace( objc_getClass( "NSWorkspace" ) )
// assert ( workspace <> nil, CurrentMethodName + " is Nil")
Call selectFile( workspace, f.Nativepath, "")
Update for app hardening!
If you sign your app with runtime hardening enabled, accessing libobjc.dylib directly will raise an exception! Swap out “libobjc.dylib” for “Cocoa” in the declare above to keep working with Mojave!