Probably I’m doing something wrong, but the Hook app doesn’t want link to a specific file in Xcode workspaces, tho it can link to workspaces in general
The Xcode version version 14.2 (14C18)
The Hook app version 4.0.1 (5010) / Scripts Version 253
I see that Hook figures out the active Xcode’s workspace, but no the opened file. The link leads to the workspace. I wonder maybe there’s something I’m missing
Could you please run the following script in /Applications/Utilities/Script Editor and post the info in the dialog boxes?
Script
tell application "Xcode"
set projectName to name of active scheme of active workspace document
set prefixName to projectName & " — "
set activeWindowName to name of window 1
display dialog "activeWindowName: " & activeWindowName
set activeDocumentName to (characters ((count of prefixName) + 1) thru -1 of (activeWindowName)) as text
display dialog "activeDocumentName: " & activeDocumentName
set current_name to activeDocumentName
if length of current_name is greater than 9 then
if text -8 through -1 of current_name is equal to "— Edited" then
set current_name to text 1 through -10 of current_name
end if
end if
display dialog "current_name: " & current_name
repeat with source_doc in documents
if current_name is equal to name of source_doc then
return "file://" & path of source_doc
end if
end repeat
get "file://" & path of active workspace document
end tell
Also , just want to be sure, if you go to Hookmark Preferences window → Script->Xcode, there is no * at the end of Xcode?
I’ve run the script and the result depends on Xcode projects type. The script works flawlessly in projects without workspaces. I’m attaching a sample project to try it out Dropbox - SampleApp.zip - Simplify your life, but I think any project with a workspace would work
Thank you for the detailed information! That’s very helpful.
Here is the revised script. Could you please run it in Script Editor and see if it works for both Xcode project and workspace?
Script
tell application "Xcode"
set activeDocumentName to (word -1 of (get name of window 1))
set current_name to activeDocumentName
if length of current_name is greater than 9 then
if text -8 through -1 of current_name is equal to "— Edited" then
set current_name to text 1 through -10 of current_name
end if
end if
repeat with source_doc in documents
if current_name is equal to name of source_doc then
return "file://" & path of source_doc
end if
end repeat
get "file://" & path of active workspace document
end tell
I just updated the script server. Please go to Hookmark Preferences window → Update->Check now to update the script. If you don’t want to update to Hookmark 5, please click on “Remind me later” button in Software update window. The script will be updated anyway, version number 255.
I have a small side question. I’m using Hook through Setapp and it seems that on Setapp Hook is on version 4, right?
I’m not against buying a separate Hook license. It’s a great tool with a premium support Just wondering whether it makes sense to install Hook as a separate program or continue using Setapp installer?