Search code examples
iosxcodeterminalswift-playground

How to open .playground file in xcode via a terminal?


I just learned the basics of the Terminal, so I was trying to open a file named trees.playground by following command:

open trees.playground

But terminal says:

No application knows how to open trees.playground.

How to make the terminal aware that XCode can open such file?


Solution

  • Xcode should be the default opening application for .playground files. So following command should work:

    open trees.playground
    

    If it still does not, you can just force terminal to open it with Xcode like following:

    open -a Xcode trees.playground
    

    To make you understand the above mentioned command, I will break it down:

    open [Open something]
    -a [With application]
    Xcode [Name of desired application]
    trees.playground [This file]
    

    In Verbose form, it would mean "Open tree.playground with an application named Xcode".