生成プロジェクトの作成
空のディレクトリ、または既存のプロジェクトのディレクトリで tuist init を実行します:
mise x tuist@latest -- tuist init
tuist init
このコマンドは、生成プロジェクトの作成、または既存の Xcode プロジェクトやワークスペースの統合の手順を案内します。セットアップをリモートサーバーに接続し、選択的テスト、プレビュー、レジストリ などの機能を利用できるようにします。
依存関係の追加#
プロジェクトが追加機能を提供するためにサードパーティ製ライブラリに依存することは一般的です。そのためには、次のコマンドを実行して、プロジェクト編集の最適な環境を整えます:
tuist edit
プロジェクトファイルを含む Xcode プロジェクトが開きます。Tuist/Package.swift を編集し、Kingfisher を追加します:
// swift-tools-version: 5.9
import PackageDescription
#if TUIST
import ProjectDescription
let packageSettings = PackageSettings(
// Customize the product types for specific package product
// Default is .staticFramework
// productTypes: ["Alamofire": .framework,]
productTypes: [:]
)
#endif
let package = Package(
name: "MyApp",
dependencies: [
// Add your own dependencies here:
// .package(url: "https://github.com/Alamofire/Alamofire", from: "5.0.0"),
// You can read more about dependencies here: https://tuist.dev/en/docs/guides/features/projects/dependencies
.package(url: "https://github.com/onevcat/Kingfisher", .upToNextMajor(from: "7.12.0"))
]
)
次に、プロジェクト内のアプリケーションターゲットを編集し、Kingfisher を依存関係として宣言します:
import ProjectDescription
let project = Project(
name: "MyApp",
targets: [
.target(
name: "MyApp",
destinations: .iOS,
product: .app,
bundleId: "dev.tuist.MyApp",
infoPlist: .extendingDefault(
with: [
"UILaunchStoryboardName": "LaunchScreen.storyboard",
]
),
buildableFolders: [
"MyApp/Sources",
"MyApp/Resources",
],
dependencies: [
.external(name: "Kingfisher")
]
),
.target(
name: "MyAppTests",
destinations: .iOS,
product: .unitTests,
bundleId: "dev.tuist.MyAppTests",
infoPlist: .default,
sources: ["MyApp/Tests/**"],
resources: [],
dependencies: [.target(name: "MyApp")]
),
]
)
その後、tuist install を実行して、Swift Package Manager を使用して依存関係を解決および取得します。
Tuist が推奨する依存関係の管理アプローチでは、Swift Package Manager (SPM) を依存関係の解決のみに使用します。その後、Tuist はそれらを最大限の設定可能性と制御性を実現するために Xcode プロジェクトとターゲットに変換します。
プロジェクトの可視化#
次のコマンドを実行することで、プロジェクト構造を可視化できます:
tuist graph
このコマンドは、プロジェクトのディレクトリに graph.png ファイルを出力して開きます:

依存関係の使用#
tuist generate を実行して Xcode でプロジェクトを開き、ContentView.swift ファイルに以下の変更を加えます:
import SwiftUI
import Kingfisher
public struct ContentView: View {
public init() {}
public var body: some View {
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Xcode からアプリを実行すると、URL から画像が読み込まれているのが確認できます。