Viktor Nilsson
Viktor Nilsson

Reputation: 1703

How to find out which file I'm currently working on in Xcode

I make iOS apps in Xcode, and I want to know how much time I spend working on specific classes/storyboards/files. So my plan is to make an application for OS X which tracks which file is currently open/active. I don't know if it is possible, but I know RescureTime can track which websites I've been on in my browser at least, so I feel it might be possible.

I have never made any application for OS X so this might be a stupid question. Is it possible to track which file is currently open/active in Xcode? If so, how?

Upvotes: 0

Views: 87

Answers (1)

Danny Daglas
Danny Daglas

Reputation: 1491

I don't know how to do this in XCode, but you can do it using some scripting language to poll XCode and have it report the front document for you on a periodic basis by calling this command:

echo 'tell application "XCode" to get name of the front document' | osascript

This will report the workspace XCode has open, or report an error if XCode is not running or does not have an open workspace.

To get more than just the front document, use this to get a manifest of all open documents in your XCode session:

echo 'tell application "XCode" to get name of documents' | osascript

Upvotes: 2

Related Questions