An Xcode Source Editor Extension that generates a type declaration based on the file name
Because typing the class name or choosing a Cocoa Touch Class template and selecting the superclass can be tedious.
- Open
DeclareType.xcodeproj
- Enable target signing for both the Application and the Source Code Extension using your own developer ID
- Select the application target and then Product > Archive
- Export the archive as a macOS App
- Run the app, then quit (Don't delete the app, put it in a convenient folder)
- Go to System Preferences -> Extensions -> Xcode Source Editor and make sure the extension is enabled
- The menu-item should now be available from Xcode's Editor menu
- Detects probable superclass (or that a protocol is created) based on the file name ending
- Imports UIKit it wasn't imported and a UIKit class is being created
- Detects: UIView, UIViewController, UIButton, UITableView, UITableViewCell, UICollectionView, UICollectionViewCell
- Creates a protocol if the file name ends with "able" or "Protocol"
- Will create a class with no parent if no candidate was found
Preferences (⌘ + ,) -> Key Bindings -> Search for "Declare"
Detects superclasses only for UIKit classes. Works only with Swift.