When creating a custom view, I find it very useful to make it into a framework and include an example project. This enables quickly iterating over the new component. Plus, when you're done, it's very easy to import the result into other projects. To set this up, take the following steps:
- Create new project, and choose Cocoa Touch Framework
- Type some name that reflects a library name such that "import yourlibname" looks logical and good
- Create a new Swift file, and add your code there
- Then go to menu File -> New -> Target and create a Single View Application
- Name it YourlibnameExample or something
- Select the project, then the new target, and in the Embedded Binaries section, click the plus
- Select the previously created framework, and click Add
- Then edit the new ViewController and type "import yourlibname"
- Then instantiate a class from your framework somewhere; no errors should occur