Xcode Playgrounds Shared Directory Not Working

Xcode Playgrounds Shared Directory Not Working

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

Xcode playgrounds can't access swift files in Sources folder

You have to add public access attribute to your classes, methods and properties in source folder to make them accessible from main playground file as they treated as separate module by compiler

Unable to create folders in Xcode Playgrounds?

Although I don't know the reason why the folder disappeared or why you need the folder, I have a simple method to recover the fold sign (little arrow) back for an empty folder.

For example, if you change the name to "hello" and the little arrow disappeared. Just add a " 2" after the "hello" to from the "hello 2". Then close the playground.
When coming back, the little arrow appears.

Now you may remove the " 2" to get the real name "hello". Reopen again, and you have the folder "hello".

This is only applicable to an empty folder. If you have files in the folder, you have to use the original name to get the little triangle sign back.

Actually you may create a new empty folder and drag and drop those files to the new folder in the playground.

Xcode autocomplete does not work in Sources folder of Swift playgrounds

In order to enable autocompletion, you can embed your Playground in a regular Xcode project (e.g. an iOS application). I recommend creating a dummy project for that purpose. Simply drag and drop your playground in this dummy project and make sure to check "Add to target".

Then you can navigate to

Target -> Build Phases -> Compile Sources -> + -> Add other

and add all the files from your source folder. Please note, that you don't need to actually copy the files, a reference is enough for this purpose.

After this process all your source files are built against this dummy target and you can use autocompletion as usual. As far as I know, this is the best practice for debugging Playgrounds right now. Anyway I am curious, if there is an easier way to achieve that.



Related Topics



Leave a reply



Submit