Section 13/181 menit
13. Project Generation: Tuist
13. Project Generation: Tuist
Tuist menggantikan .xcodeproj dengan Swift code — project configuration menjadi type-safe dan mudah di-review.
swift
# Install
curl -Ls https://install.tuist.io | bash
# Init project baru
mkdir MyApp && cd MyApp
tuist init --platform ios
# Generate .xcodeproj dari Tuist config
tuist generate
# Build
tuist build
# Test
tuist test
Project.swift: Definisi Project
swift
// Project.swift — menggantikan MyApp.xcodeproj
import ProjectDescription
let project = Project(
name: "MyApp",
organizationName: "My Company",
settings: .settings(
base: [
"SWIFT_VERSION": "5.0",
"IPHONEOS_DEPLOYMENT_TARGET": "17.0",
"CODE_SIGN_STYLE": "Automatic",
"DEVELOPMENT_TEAM": "ABCDEF1234"
],
configurations: [
.debug(name: "Debug", xcconfig: "Configurations/Debug.xcconfig"),
.release(name: "Release", xcconfig: "Configurations/Release.xcconfig")
]
),
targets: [
.target(
name: "MyApp",
destinations: [.iPhone, .iPad],
product: .app,
bundleId: "com.mycompany.myapp",
deploymentTargets: .iOS("17.0"),
infoPlist: .extendingDefault(with: [
"UILaunchStoryboardName": "LaunchScreen",
"BASE_URL": .string("$(BASE_URL)")
]),
sources: ["Sources/MyApp/**"],
resources: ["Resources/**"],
dependencies: [
.target(name: "NetworkKit"),
.target(name: "DesignSystem"),
.external(name: "Alamofire"),
]
),
.target(
name: "NetworkKit",
destinations: [.iPhone, .iPad],
product: .framework,
bundleId: "com.mycompany.networkkit",
sources: ["Sources/NetworkKit/**"],
dependencies: [
.external(name: "Alamofire")
]
),
.target(
name: "DesignSystem",
destinations: [.iPhone, .iPad],
product: .framework,
bundleId: "com.mycompany.designsystem",
sources: ["Sources/DesignSystem/**"],
resources: ["Sources/DesignSystem/Resources/**"]
),
.target(
name: "MyAppTests",
destinations: [.iPhone],
product: .unitTests,
bundleId: "com.mycompany.myapp.tests",
sources: ["Tests/MyAppTests/**"],
dependencies: [
.target(name: "MyApp")
]
)
]
)
swift
// Tuist/Dependencies.swift — definisi external dependencies
import ProjectDescription
let dependencies = Dependencies(
swiftPackageManager: SwiftPackageManagerDependencies([
.remote(url: "https://github.com/Alamofire/Alamofire", requirement: .upToNextMajor(from: "5.9.0")),
.remote(url: "https://github.com/realm/SwiftLint", requirement: .upToNextMajor(from: "0.57.0")),
])
)