Mohammed Awad-Allah
May 3, 2015 · 1 min read

Swift Playgrounds are sandboxed environments, meaning you cannot access resources outside of the playground package. So, In order to use a resource (a text file, an image … etc.) in your Swift Playground, you first need to have it inside your playground package.

In order to do so, you can follow these steps:

1. Open the file inspector

Choose: View > Utilities > Show File Inspector or alternatively press (alt+cmd+1)

2. Open Resources Folder

In the file inspector, under playground settings, you’ll find Resource Path. You can open the folder by clicking on the arrow icon beside the path.

3. Copy your files to the Resource Path

That’s it!


The following snipped opens a text file from the resource path. (P.S. Don’t hard-code absolute path in your production code)

Originally published at

Code & Data

Bite-Sized programming and Data recipes

    Mohammed Awad-Allah

    Written by

    Code & Data

    Bite-Sized programming and Data recipes

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade