A comprehensive Tuist template for building SwiftUI projects with modular architecture, supporting apps, frameworks, and extensions.
- Modular Architecture: Clean separation between apps, frameworks, modules, and extensions
- Multiple Target Types: Support for apps, frameworks (static/dynamic), and various app extensions
- SwiftUI Ready: Templates come with SwiftUI boilerplate code
- Configurable: Flexible configuration options for each target type
- Test Support: Automatic test target generation with configurable options
- Organized Structure: Pre-configured folder structure for easy project maintenance
Add this template as a Tuist plugin in your Project.swift
:
import ProjectDescription
let tuist = Tuist(
project: .tuist(plugins: [
.git(url: "https://github.com/tddworks/SwiftUITemplate", tag: "v1.1.0")
])
)
Template Types:
- Initial Templates: Use these for creating new projects (
app
,framework
,module
,extension
,workspace
) - Addition Templates: Use these for adding to existing projects (
addapp
,addframework
,addmodule
,addextension
)
The addition templates are safer as they never overwrite existing project configuration files.
Generate a new SwiftUI application:
tuist scaffold app --name MyApp --platform ios --bundle-id com.example --team-id ABC123XYZ --version 1.0.0
Options:
name
(required): App nameplatform
: Target platform (ios/macos)bundle-id
: Bundle identifier prefixteam-id
: Development team ID for code signingversion
: App versionhas-tests
: Include test target (default: true)has-ui-tests
: Include UI test target (default: false)
Resulting Structure:
Root/
βββ Tuist/ProjectDescriptionHelpers/Targets/Products/MyApp.swift
βββ Products/
β βββ MyApp/
β β βββ Resources/
β β β βββ Assets.xcassets
β β β βββ InfoPlist.strings
β β βββ Sources/
β β β βββ MyAppApp.swift
β β β βββ ContentView.swift
β β βββ Tests/
β β βββ MyAppTests.swift
βββ Project.swift
Generate a reusable framework:
tuist scaffold framework --name Core --is-static false --has-resources true
Options:
name
(required): Framework nameis-static
: Create static framework (default: false)has-resources
: Include resources (default: false)has-tests
: Include test target (default: true)dependencies
: Array of dependencies
Resulting Structure:
Root/
βββ Tuist/ProjectDescriptionHelpers/Targets/Frameworks/Core.swift
βββ Frameworks/
β βββ Core/
β β βββ Resources/
β β βββ Sources/
β β β βββ Core.swift
β β β βββ CoreInterface.swift
β β βββ Tests/
β β βββ CoreTests.swift
Generate a feature module:
tuist scaffold module --name FeatureAuth
Resulting Structure:
Root/
βββ Tuist/ProjectDescriptionHelpers/Targets/Modules/FeatureAuth.swift
βββ Modules/
β βββ FeatureAuth/
β βββ Resources/
β βββ Sources/
β βββ FeatureAuth.swift
Generate an app extension:
tuist scaffold extension --name MyWidget --type widget --host-app MyApp
Options:
name
(required): Extension nametype
(required): Extension type (widget, notification, share, etc.)host-app
(required): Host app namebundle-id
: Bundle identifier prefixversion
: Extension versionhas-ui
: Include UI components (default: true)
Available Extension Types:
widget
: Widget Extensionnotification
: Notification Service Extensionaction
: Action Extensionshare
: Share Extensiontoday
: Today Extensionintents
: Intents Extensionintentui
: Intents UI Extensionfileprovider
: File Provider Extensionfileproviderui
: File Provider UI Extension
Add additional app targets to an existing project:
tuist scaffold addapp --name DemoApp --platform macos --bundle-id com.mycompany.demo
Options:
name
(required): New app nameplatform
: Target platform (ios, macos, watchos, tvos) (default: ios)bundle-id
: Bundle identifier prefix (default: com.example)version
: App version (default: 1.0.0)has-tests
: Include test target (default: true)has-ui-tests
: Include UI test target (default: false)
Notes:
- Use
addapp
only after creating the initial project withapp
template - Does not overwrite existing Project.swift or Tuist configuration
- Automatically creates app target definition files
- Supports multiple platforms in same project (iOS + macOS + watchOS + tvOS)
Add additional framework targets to an existing project:
tuist scaffold addframework --name NetworkLayer --has-resources false --is-static false
Options:
name
(required): Framework nameplatform
: Target platform (ios, macos, watchos, tvos) (default: ios)has-resources
: Include resources (default: false)has-tests
: Include test target (default: true)is-static
: Create static framework (default: false)
Add additional module targets to an existing project:
tuist scaffold addmodule --name UserProfile
Options:
name
(required): Module name
Add additional extension targets to an existing project:
tuist scaffold addextension --name MyWidget --type widget --host-app MyApp
Options:
name
(required): Extension nametype
(required): Extension type (widget, notification, share, etc.)host-app
(required): Host app namebundle-id
: Bundle identifier prefix (default: com.example)version
: Extension version (default: 1.0.0)has-ui
: Include UI components (default: true)
Safe Addition Templates:
- All
add*
templates are designed for existing projects - They never overwrite Project.swift, Package.swift, or Tuist/ configuration
- Safe to use multiple times to incrementally build your project
Generate a workspace supporting multiple app targets:
tuist scaffold workspace --name MyWorkspace --apps "MainApp,CompanionApp,AdminApp"
Options:
name
(required): Workspace nameapps
(required): Comma-separated list of app namesbundleIdPrefix
: Bundle identifier prefix (default: com.example)structure
: Project structure - "single" or "multi" (default: multi)sharedFrameworks
: Array of shared frameworks (default: ["Core", "Shared"])version
: Version number (default: 1.0.0)
Structure Options:
single
: All apps in one project filemulti
: Separate project per app in workspace (recommended)
Add a new app to an existing workspace:
tuist scaffold multiapp --name NewApp --workspace MyWorkspace
Options:
name
(required): New app nameworkspace
(required): Existing workspace namebundleIdPrefix
: Bundle identifier prefixsharedDependencies
: Dependencies on shared frameworks
# 1. Create the main app and project structure
tuist scaffold app --name MyApp --platform ios --bundle-id com.mycompany --team-id ABC123XYZ
# 2. Generate initial project
tuist generate
# 3. Add components safely to existing project
tuist scaffold addframework --name Core --has-resources false
tuist scaffold addframework --name NetworkLayer --has-resources false
# 4. Add feature modules
tuist scaffold addmodule --name Authentication
tuist scaffold addmodule --name UserProfile
tuist scaffold addmodule --name Settings
# 5. Add extensions
tuist scaffold addextension --name MyWidget --type widget --host-app MyApp
tuist scaffold addextension --name MyCloudSync --type fileprovider --host-app MyApp
# 6. Add additional apps to the same project (optional)
tuist scaffold addapp --name MyApp1 --platform macos --bundle-id com.mycompany.macos
tuist scaffold addapp --name DemoApp --platform ios --bundle-id com.mycompany.demo
# 7. Generate final project with all components
tuist generate
# 1. Create workspace with multiple apps
tuist scaffold workspace --name MyWorkspace --apps "MainApp,AdminApp,CompanionApp" --bundleIdPrefix com.mycompany
# 2. Add additional frameworks to shared project
tuist scaffold framework --name NetworkLayer --hasResources false
tuist scaffold framework --name DatabaseLayer --hasResources false
# 3. Add more apps later
tuist scaffold multiapp --name DebugApp --workspace MyWorkspace --sharedDependencies "Core,Shared,NetworkLayer"
# 4. Add extensions for specific apps
tuist scaffold extension --name MainAppWidget --type widget --hostApp MainApp
tuist scaffold extension --name AdminDashboard --type today --hostApp AdminApp
# 5. Generate the workspace
tuist generate
# 1. Create single project with multiple apps
tuist scaffold workspace --name MyProject --apps "MainApp,CompanionApp" --structure single --bundleIdPrefix com.mycompany
# 2. Generate the project
tuist generate
.
βββ Products/ # App targets
βββ Modules/ # Feature modules
βββ Frameworks/ # Shared frameworks
βββ Extensions/ # App extensions
βββ Tuist/ # Tuist configuration
β βββ ProjectDescriptionHelpers/
β βββ Targets/
β β βββ Products/ # App target definitions
β β βββ Modules/ # Module target definitions
β β βββ Frameworks/ # Framework target definitions
β β βββ Extensions/ # Extension target definitions
β βββ TargetFactory.swift
β βββ TargetExtensions.swift
β βββ SourcePaths.swift
β βββ SettingsFactory.swift
βββ Project.swift
MyWorkspace/
βββ MyWorkspace.xcworkspace/
βββ MainApp/
β βββ Sources/
β βββ Resources/
β βββ Tests/
β βββ Project.swift
βββ AdminApp/
β βββ Sources/
β βββ Resources/
β βββ Tests/
β βββ Project.swift
βββ CompanionApp/
β βββ Sources/
β βββ Resources/
β βββ Tests/
β βββ Project.swift
βββ Shared/ # Shared frameworks project
β βββ Frameworks/
β β βββ Core/
β β βββ Shared/
β βββ Project.swift
βββ Tuist/
β βββ Config.swift
β βββ ProjectDescriptionHelpers/
β βββ WorkspaceFactory.swift
β βββ TargetFactory.swift
β βββ ...
βββ Workspace.swift
.
βββ Products/
β βββ MainApp/
β βββ AdminApp/
β βββ CompanionApp/
βββ Frameworks/ # Shared frameworks
βββ Modules/ # Feature modules
βββ Extensions/ # App extensions
βββ Tuist/ # Tuist configuration
βββ Project.swift # Contains all apps
File Provider extensions allow your app to provide files to the Files app and other document-based apps. Two types are supported:
- Provides file enumeration and management capabilities
- Handles file operations like create, read, update, delete
- Integrates with the Files app and document picker
tuist scaffold extension --name MyCloudProvider --type fileprovider --host-app MyApp
- Provides custom UI for file provider actions
- Handles user interactions for file operations
- Works in conjunction with File Provider Extension
tuist scaffold extension --name MyCloudProviderUI --type fileproviderui --host-app MyApp
Generated Features:
- Complete
FileProviderExtension
class with item management - File enumeration and sync anchor support
- SwiftUI-based action interface for UI extension
- Proper entitlements for file system access
- App group configuration for data sharing
The project provides a comprehensive TargetFactory
with methods for creating different target types:
createAppTarget()
: Creates an app targetcreateAppTestTarget()
: Creates app unit tests
createFramework()
: Creates a dynamic frameworkcreateStaticFramework()
: Creates a static frameworkcreateFrameworkTests()
: Creates framework tests
createExtension()
: Creates an app extension with configurable type
Edit Config.swift
to modify:
- Compatible Xcode versions
- Swift version
- Generation options
Each target type can be configured with:
- Bundle identifiers
- Destinations (iOS, macOS, etc.)
- Resources
- Dependencies
- Build settings
- Modular Development: Break your app into feature modules for better code organization
- Shared Code: Use frameworks for code shared between targets
- Multi-App Architecture: Choose the right structure for your needs:
- Workspace with separate projects: Best for complex apps with different lifecycles
- Single project: Good for related apps sharing most code
- Shared Frameworks: Create
Core
for business logic,Shared
for UI components - Extensions: Keep extension code minimal and focused
- File Provider: Use File Provider extensions for cloud storage integration
- Testing: Always include test targets for critical components
- Dependencies: Use explicit dependencies between modules
- Bundle IDs: Use consistent bundle ID prefixes across all apps in workspace
- Schemes: Create separate schemes for each app target for easier development
When to use Multiple Apps:
- Main app + Admin/Debug companion app
- Consumer app + Business/Enterprise variant
- iOS app + macOS app sharing code
- Different deployment targets (App Store vs Enterprise)
- A/B testing different app experiences
Workspace vs Single Project:
- Use Workspace: When apps have different release cycles, teams, or significant differences
- Use Single Project: When apps are closely related and developed together
Contributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.