Open Xcode project and set active file from terminal

Viewed 1140

Opening an Xcode project from the terminal is easy:

open Foo.xcodeproj/

But that just opens the project and resumes its previous state using UserInterfaceState.xcuserstate - so it just opens to the last active file you were editing.

Is there a way to open an Xcode project and specify which file it should open to?

What I've tried:

  1. Editing .xcuserstate - nightmare, don't do it.
  2. Running open Foo/Foo.xcodeproj/ then open Foo/Sources/main.swift which works some of the time, but not always. (If you just generated the project and do this, it'll open the project, then in a separate window it'll open the file.)

Any other ideas?

1 Answers
Related