Make a new Tin project from scratch


1. Start Xcode

The video on this page was made using Xcode 9 beta 6.

2. File -> New -> Project

3. Choose the project template: Mac / Cocoa App

4. Set the project attributes.

Make sure there are good entries for Product Name (this will become the app name), Organization Name, and Organization Identifier. Language should be set to Swift.

5. Choose a location to save the project folder.

6. Drag the Tin Framework into the Project Navigator.

Copy items if needed should be checked ON.

Before you add the Tin Framework into your Project, you will need a copy of the Framework. You can download the framework from the GitHub repo, and build it yourself. Or, find the latest release, and there will be a zip of the framework binary. The latest release at this time is here. Here is a direct link to the framework zip.

7. Add the Tin Framework to Project Settings, General, Embedded Binaries.

Note that doing this also adds Tin to the Linked Frameworks and Libraries section.

8. Edit ViewController.swift

9. Add "import Tin".

10. Change the ViewController class declaration to inherit from TController instead of NSViewController.

Note TController is a subclass of NSViewController.

11. Add viewWillAppear method to the ViewController class.

			
override func viewWillAppear() {
    super.viewWillAppear()

}
							

12. Add code to create a Tin view, and to present a Tin Scene in the view.

Add this code to the viewWillAppear method, after the call to super.viewWillAppear().

			
makeView(width: 800.0, height: 400.0)
let scene = Scene()
present(scene: scene)		
				

a. The makeView method will create a TView object, and assign it to the controller's view property. The arguments width and height will set the window and view size.

b. The second line creates an instance of a Scene object.

c. The third line sets the Scene object as the current scene for the TView object. The TView object will draw and update the scene inside the view.

13. Add a Tin Scene class.

			
class Scene: TScene {
    
    override func update() {
        background(gray: 0.5)
        
    }
}		
				



MakeANewTinProject from Loren Olson on Vimeo.