Created a simple Catalyst (Mac Idiom) template

This commit is contained in:
Steven Troughton-Smith 2021-09-13 03:10:00 +01:00
parent ed0e92308a
commit 447928c487
32 changed files with 202 additions and 155 deletions

View file

@ -9,7 +9,7 @@
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
class ___VARIABLE_classPrefix___AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}

View file

@ -0,0 +1,32 @@
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// ___COPYRIGHT___
//
import UIKit
#if targetEnvironment(macCatalyst)
import AppKit
extension ___VARIABLE_classPrefix___SceneDelegate: NSToolbarDelegate {
func toolbarItems() -> [NSToolbarItem.Identifier] {
return [.toggleSidebar]
}
func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
return toolbarItems()
}
func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
return toolbarItems()
}
func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? {
return NSToolbarItem(itemIdentifier: itemIdentifier)
}
}
#endif

View file

@ -0,0 +1,38 @@
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// ___COPYRIGHT___
//
import UIKit
class ___VARIABLE_classPrefix___SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = scene as? UIWindowScene else {
fatalError("Expected scene of type UIWindowScene but got an unexpected type")
}
window = UIWindow(windowScene: windowScene)
if let window = window {
window.rootViewController = ___VARIABLE_classPrefix___MainViewController()
#if targetEnvironment(macCatalyst)
let toolbar = NSToolbar(identifier: NSToolbar.Identifier("___VARIABLE_classPrefix___SceneDelegate.Toolbar"))
toolbar.delegate = self
toolbar.displayMode = .iconOnly
toolbar.allowsUserCustomization = false
windowScene.titlebar?.toolbar = toolbar
windowScene.titlebar?.toolbarStyle = .unified
#endif
window.makeKeyAndVisible()
}
}
}

View file

@ -8,8 +8,7 @@
import UIKit
final class MainViewController: UIViewController {
private let contentView = MainView()
final class ___VARIABLE_classPrefix___MainViewController: UIViewController {
init() {
super.init(nibName: nil, bundle: nil)
@ -19,12 +18,4 @@ final class MainViewController: UIViewController {
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func loadView() {
view = contentView
}
override func viewDidLoad() {
super.viewDidLoad()
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kind</key>
<string>Xcode.Xcode3.ProjectTemplateUnitKind</string>
<key>Identifier</key>
<string>com.highcaffeinecontent.catalyst.simple</string>
<key>Ancestors</key>
<array>
<string>com.highcaffeinecontent.catalyst.base</string>
</array>
<key>Concrete</key>
<true/>
<key>Description</key>
<string>Starting point for an app.</string>
<key>SortOrder</key>
<integer>1</integer>
<key>CFBundleIdentifier</key>
<string></string>
<key>Nodes</key>
<array>
<string>Source/Application/___VARIABLE_classPrefix___AppDelegate.swift</string>
<string>Source/Application/___VARIABLE_classPrefix___SceneDelegate.swift</string>
<string>Source/Application/___VARIABLE_classPrefix___SceneDelegate+NSToolbar.swift</string>
<string>Source/Main/___VARIABLE_classPrefix___MainViewController.swift</string>
<string>Assets.xcassets</string>
</array>
<key>Targets</key>
<array>
<dict>
<key>SharedSettings</key>
<dict>
<key>SUPPORTS_MACCATALYST</key>
<string>YES</string>
<key>TARGETED_DEVICE_FAMILY</key>
<string>1,2,6</string>
<key>IPHONEOS_DEPLOYMENT_TARGET</key>
<string>14.0</string>
<key>IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]</key>
<string>14.2</string>
<key>SWIFT_TREAT_WARNINGS_AS_ERRORS</key>
<string>YES</string>
<key>RUN_CLANG_STATIC_ANALYZER</key>
<string>YES</string>
<key>CLANG_STATIC_ANALYZER_MODE</key>
<string>deep</string>
<key>GCC_TREAT_WARNINGS_AS_ERRORS</key>
<string>deep</string>
<key>GCC_WARN_PEDANTIC</key>
<string>deep</string>
<key>INFOPLIST_FILE</key>
<string>$(PRODUCT_NAME)/Info.plist</string>
</dict>
</dict>
</array>
<key>Definitions</key>
<dict>
<key>Assets.xcassets</key>
<dict>
<key>Path</key>
<string>Assets.xcassets</string>
</dict>
<key>Source/Application/___VARIABLE_classPrefix___AppDelegate.swift</key>
<dict>
<key>Group</key>
<array>
<string>Source</string>
<string>Application</string>
</array>
<key>Path</key>
<string>Source/Application/___VARIABLE_classPrefix___AppDelegate.swift</string>
</dict>
<key>Source/Application/___VARIABLE_classPrefix___SceneDelegate.swift</key>
<dict>
<key>Group</key>
<array>
<string>Source</string>
<string>Application</string>
</array>
<key>Path</key>
<string>Source/Application/___VARIABLE_classPrefix___SceneDelegate.swift</string>
</dict>
<key>Source/Application/___VARIABLE_classPrefix___SceneDelegate+NSToolbar.swift</key>
<dict>
<key>Group</key>
<array>
<string>Source</string>
<string>Application</string>
</array>
<key>Path</key>
<string>Source/Application/___VARIABLE_classPrefix___SceneDelegate+NSToolbar.swift</string>
</dict>
<key>Source/Main/___VARIABLE_classPrefix___MainViewController.swift</key>
<dict>
<key>Group</key>
<array>
<string>Source</string>
<string>Main</string>
</array>
<key>Path</key>
<string>Source/Main/___VARIABLE_classPrefix___MainViewController.swift</string>
</dict>
</dict>
<key>Options</key>
<array/>
</dict>
</plist>

View file

@ -5,7 +5,7 @@
<key>Kind</key>
<string>Xcode.Xcode3.ProjectTemplateUnitKind</string>
<key>Identifier</key>
<string>dk.simonbs.dt.unit.iosBase</string>
<string>com.highcaffeinecontent.catalyst.base</string>
<key>Ancestors</key>
<array>
<string>com.apple.dt.unit.applicationBase</string>
@ -113,7 +113,7 @@
&lt;key&gt;UISceneConfigurationName&lt;/key&gt;
&lt;string&gt;Default Configuration&lt;/string&gt;
&lt;key&gt;UISceneDelegateClassName&lt;/key&gt;
&lt;string&gt;$(PRODUCT_MODULE_NAME).SceneDelegate&lt;/string&gt;
&lt;string&gt;$(PRODUCT_MODULE_NAME).___VARIABLE_classPrefix___SceneDelegate&lt;/string&gt;
&lt;/dict&gt;
&lt;/array&gt;
&lt;/dict&gt;
@ -142,6 +142,19 @@
</dict>
</dict>
<key>Options</key>
<array/>
<array>
<dict>
<key>Identifier</key>
<string>classPrefix</string>
<key>Name</key>
<string>Class Prefix</string>
<key>Description</key>
<string>The prefix to prepend to all created classes</string>
<key>Type</key>
<string>text</string>
<key>Placeholder</key>
<string>XYZ</string>
</dict>
</array>
</dict>
</plist>

View file

@ -1,22 +0,0 @@
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// ___COPYRIGHT___
//
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = scene as? UIWindowScene else {
fatalError("Expected scene of type UIWindowScene but got an unexpected type")
}
window = UIWindow(windowScene: windowScene)
window?.rootViewController = UINavigationController(rootViewController: MainViewController())
window?.makeKeyAndVisible()
}
}

View file

@ -1,29 +0,0 @@
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// ___COPYRIGHT___
//
import UIKit
final class MainView: UIView {
init() {
super.init(frame: .zero)
setupView()
setupLayout()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupView() {
backgroundColor = .systemBackground
}
private func setupLayout() {
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -1,80 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kind</key>
<string>Xcode.Xcode3.ProjectTemplateUnitKind</string>
<key>Identifier</key>
<string>dk.simonbs.dt.unit.iosMinimalist</string>
<key>Ancestors</key>
<array>
<string>dk.simonbs.dt.unit.iosBase</string>
</array>
<key>Concrete</key>
<true/>
<key>Description</key>
<string>Starting point for an app.</string>
<key>SortOrder</key>
<integer>1</integer>
<key>CFBundleIdentifier</key>
<string></string>
<key>Nodes</key>
<array>
<string>Source/Application/AppDelegate.swift</string>
<string>Source/Application/SceneDelegate.swift</string>
<string>Source/Main/MainView.swift</string>
<string>Source/Main/MainViewController.swift</string>
<string>Assets.xcassets</string>
</array>
<key>Definitions</key>
<dict>
<key>Assets.xcassets</key>
<dict>
<key>Path</key>
<string>Assets.xcassets</string>
</dict>
<key>Source/Application/AppDelegate.swift</key>
<dict>
<key>Group</key>
<array>
<string>Source</string>
<string>Application</string>
</array>
<key>Path</key>
<string>Source/Application/AppDelegate.swift</string>
</dict>
<key>Source/Application/SceneDelegate.swift</key>
<dict>
<key>Group</key>
<array>
<string>Source</string>
<string>Application</string>
</array>
<key>Path</key>
<string>Source/Application/SceneDelegate.swift</string>
</dict>
<key>Source/Main/MainView.swift</key>
<dict>
<key>Group</key>
<array>
<string>Source</string>
<string>Main</string>
</array>
<key>Path</key>
<string>Source/Main/MainView.swift</string>
</dict>
<key>Source/Main/MainViewController.swift</key>
<dict>
<key>Group</key>
<array>
<string>Source</string>
<string>Main</string>
</array>
<key>Path</key>
<string>Source/Main/MainViewController.swift</string>
</dict>
</dict>
<key>Options</key>
<array/>
</dict>
</plist>

View file

@ -1,8 +1,6 @@
# xctemplates
# catalyst-xctemplates
Opinionated templates for Xcode 11.
<img src="https://raw.githubusercontent.com/simonbs/xctemplates/master/imgs/header.png" width="450">
Basic Mac Catalyst templates for Xcode 11+.
## Installation
@ -12,12 +10,10 @@ The project templates should be copied into the `~/Library/Developer/Xcode/Temp
Below is a brief description of the templates in this repository.
### iOS Base
### Catalyst Base
This is not an actual project template. It contains the base configuration for an iOS project an is inherited by other project templates.
This is not an actual project template. It contains the base configuration for a Catalyst project and is inherited by other project templates.
### iOS Minimalist
### Catalyst App (Basic)
This is a minimalistic template for an iOS project. It configures the app to use scenes without storyboards.
<img src="https://raw.githubusercontent.com/simonbs/xctemplates/master/imgs/ios_minimalist.png" width="250">
This is a minimalistic template for a Mac Catalyst project using the Mac Idiom and targeting macOS 11. It configures the app to use scenes without storyboards, enables warnings-as-errors for both Swift & Objective-C, and prompts you for a class prefix.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB