Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Playgrounds Shared Directory Not Working

When creating an Xcode Playground, the supported playgroundSharedDataDirectory does not properly show my the expected directory.

Expected: ~/Documents/Shared Playground Data

Actual: file:///var/folders/46/zg_mg07d5h5_9t6q_4vr9_2w0000gn/T/com.apple.dt.Xcode.pg/containers/com.apple.dt.playground.stub.iOS_Simulator.MyPlayground-BEF6F13E-994E-45C9-A18E-7DE953069D69/Documents/Shared%20Playground%20Data/

import UIKit
import PlaygroundSupport

print(playgroundSharedDataDirectory)

This also does not link to the directory. If I place a file in the correct directory, I cannot read it. If I place it in the directory, it does work, but it changes every time the playground is loaded.

Xcode 10.3, also appears in Xcode 11. This worked in 10.2

like image 904
Matthew Knippen Avatar asked Sep 17 '19 19:09

Matthew Knippen


People also ask

How do I access Xcode playground?

To open Playground on Xcode, navigate to File in the menu and click on New > Playground... To test our square function, we will choose the Blank template. Name your Playground file, then click on Create.

What is the difference between playground and Xcode?

Interactive playgrounds help you to quickly prototype and build your applications, and simply provide another great way to interact with your code. An Xcode project, however, creates a new asset folder and pre-made swift and storyboard files. Save this answer.

Does Swift Playgrounds work offline?

Swift in Sixty Seconds takes my introductory Swift tutorial and packages it up in an interactive playground you can experiment with. You get both the text and the videos, all offline on your iPad or Mac.

Is playgrounds a good way to learn Swift?

It may not help you in your job directly, but it teaches useful skills and creates a basic knowledge of the fundamental workings of the products and tools we all use every day. It's not just something kids should do at school, but an important part of an ongoing education for adults.


1 Answers

That's the path that iOS playground use. If you make a macOS playground it will have the path ~/Documents/Shared Playground Data

like image 64
Craig Siemens Avatar answered Sep 23 '22 23:09

Craig Siemens