playground books

I have managed to create a playground book for the previous version of Swift Playgrounds but now they support UserModules and I want that in my Xcode created content that I download to my iPad. They instruct you to down load a template and open it in Xcode. I have done that. From there things get quickly untenable. All the documentation seems incomplete. The template does not include any sort of UserModules code and when I hack it together using the documentation they have and upload it my iPad complains it does not have the

UserAutoImportedAuxiliaryModules

Key. I include that and by trial and error figure out it is an array of strings with the names of my UserModules. Have not been able to figure out how to make a usable Usermodule.playgroundmodule yet. I do search on Google and Apple for UserAutoImportedAuxiliaryModules key and find zero results. Does any body know where I can find some usable documentation or an example of a playground book that supports UserModules that I can download and examine on my Mac. You can't see anything (like what is in the Manifest.plist files) on the iPad so it is difficult to figure out what I am doing wrong.

Replies

I am doing the same thing. I think so. UserAutoImportedAuxiliaryModules will look for a directory with a suffix of playgroundmodule that exists in the Modules directory. It is an array and you can include multiple playgroundmodules.

Many of the playground books available in Swift Playgrounds use modules and can be used as examples of how to structure a book using modules. For example Sonic Workshop or Sonic Create.

If you drag one of these books onto the Xcode icon in the dock, and then open the Project Navigator (View > Navigators > Project) you will be able to examine the structure by drilling down through the folders. If you make a copy of the playgroundbook you can easily modify it and make your own.

UserAutoImportedAuxiliaryModules
This key in the book’s Manifest.plist contains an array of strings, each of which is the name of a module in the Contents/Modules folder. These modules are automatically made available to user code. For example, if one of the items in UserAutoImportedAuxiliaryModules is Foo, then any publicly-declared API in Contents/Modules/Foo.playgroundmodule will be available without the necessity for import Foo.