Unless otherwise stated, you should be zipping your entire template folder and turning that in. The Xcode template needs to be together in order to function, so zipping it to turn in preserves all of the relationships within the file.
The kinds of files that are in this structure that need to be present for projects to function are the SwiftProcessing library, images, permissions files, and information that Xcode needs to be able to compile your project.
Important: Do not just turn in a .swift or Playground file. Projects turned in like this will receive no credit.
Project names should be in the following format:
LastFirst_AssignmentName.zip
Note: Change the title of the zip file after it has been zipped. This preserves the original name of the project.
Headers give information to your professor and to your future self about projects. Use the format below for all of your assignments:
/*
* Course: DMA 64 - Creative Coding for Mobile Devices
* Assignment: Assignment Name
*
* by First Last
*
* Initiated: 1/1/1
* Last updated: 1/1/1
*
* DEVICE TESTED ON: iPhone 13 Simulator
*
* CITATIONS: List all sources you used for this assignment.
*
* NOTE: This is where you write any notes you would like
* to leave yourself or others using your code.
*
* */The work you do in this class is precious and depending on where you end up going after this course, it may be useful to you in the future. It's important to store and keep track of your work in a system that works for you. Here is one suggestion for a system that might be useful to you.
When starting a project, rename the external folder of the template with the following format:
YYYYMMDD_ProjectName
For example, a project called DrawingMachine that I started on October 20, 2021 would have an external folder called:
20211021_DrawingMachine
This ensures that when you navigate to a folder, all of your files are in order by the date that you started them and you don't have to spend a lot of time searching around a long list.
The textbook is a series of Xcode Playgrounds available in the SwiftProcessing package. When you download the Empty App Template, you will see the Playgrounds in the file structure. Within the Navigation sidebar open SwiftProcessing > Playgrounds and you will find 3 Playgrounds that you can expand. Each of these Playgrounds contain all of the textbook chapters.
When you expand the three Playground you'll see the 25 chapters you'll be reading.
The Empty App Template I provide for my students has two possible locations to code in. One is the SwiftProcessing.playground, which is an Xcode Playground file. The other is a Sketch.swift file. You can code in either places, but they have different purposes.
- Prototyping or testing something out.
- A good starting point for most projects.
- Any project that can be contained in a single file.
- Writing an app that works on a phone or tablet.
- Anything that requires speed or is more complex.
- Any project where you need to use more than one file. You can use multiple
.swiftfiles as your project becomes more comlex.
Xcode Playgrounds are a programming environment that allows for rapid prototyping with a live view. Rather than having to compile and run software on a hardward device or in a simulator, the results of your programming appear next to your code inside of the development environment.
Your playground has two buttons in the lower left-hand corner of the interface that will help with the execution of your code.
In the bottom left corner of the window there is a button that is either a
On the left side of the window beside the code there is a blue
Note: If your code or the editor begins running slowly, press the ⏹ button and you'll notice that the environment will become more responsive.
At the top of your template's main interface you will see a
To choose a simulator, click on the button to the right of the stop button and select your simulator. Note: You want to make sure you keep Swift-Processing-Template-w-Playground checked after you pick a simulator.
Getting the hang of an Xcode workflow can be intimidating at first, but once you know what things to check when things go wrong, you'll become accustomed to it. Here are a few tips for the two methods for coding in SwiftProcessing that you can follow if things go wrong.
- Check that all
{is accompanied with a}. - Check your tabs by choosing Edit > Select All (or command-a) and then Editor > Structure > Re-Indent (control-i). This will reformat your code with proper tabs and will show you when there is a misplaced bracket.
-
Make sure your Playground code follows this format:
// 1 import SwiftProcessing import PlaygroundSupport import UIKit // 2 class MySketch: Sketch, SketchDelegate { // 3 func setup() { } // 4 func draw() { } } // 5 PlaygroundPage.current.needsIndefiniteExecution = true PlaygroundPage.current.setLiveView(MySketch())
The commented numbers in the example refer to:
- Import statements
- The line that starts with
classwhich gives us access to all of SwiftProcessing's features. setup()which runs once when a sketch first launches.draw()which runs at 60 frames per second (by default) and loops until the sketch is stopped.- This sets up the Playground's live view. If this is missing, you will receive no error and it will simply do nothing. This is a common error in Playgrounds.
-
If the Playground is giving you console errors about missing methods, try pressing the Play button a second time. Sometimes when a project is first run, it takes a couple of plays before the Playground will see all of the available code.
-
If you're still getting errors about missing methods or an error that says SwiftProcessing was not found, then switch to the SwiftProcessing library build target, click build, and try to play the Playground again. Follow the steps in the image below:

- Select the SwiftProcessing build target in the choices to the right of the build and stop buttons.
- Select any target iOS device.
- Hit the build (
▶️ ) button to rebuild the library. - Go back to your Playground and try to play it again.
-
Make sure your code follows the following format similar to the code above. Notice that there doesn't need to be quite as much code as in the Playground code:
import SwiftProcessing import UIKit class MySketch: Sketch, SketchDelegate { func setup() { } func draw() { } }
-
Make sure that you've chosen a simulator to use that matches what you'd like to develop on.
There are times when Xcode just needs a reboot. Xcode is fairly good about saving your files, but if things won't work, a good thing to sometimes try is just save your changes with Command-s, quit, and relauch. This can sometimes fix some errors.
If this does not work, you can also clean your build folder by selecting Product > Clean Build Folder or Command-Shift-k. This erases any files that were created in previous builds and starts fresh.
In macOS you can take a screen grab with a keyboard combination.
Command-Shift-3 takes a screen grab of your entire screen.
Command-Shift-4 takes a screen grab of a selected area.
Pressing the space bar after you've entered selection mode will allow you to capture a window.
Your image files will save to your desktop.
Add a Control to either of the above methods and you will copy your screen grab to the clipboard rather than create a file.
In macOS you can create a zip file by right or control-clicking any file and choosing Compress File.







