새로운 개인 앱을 만들고 있었는데요, Tuist가 개발자들 사이에서 유명해지면서 저도 적용하기로 했습니다.
(한국어가 익숙하지 않고 영어를 읽을 수 있으면 여기서 보세요)
설치
공식 문서에서는 brew 대신 mise를 권장한다고 합니다만, 버전을 맞춰야 하지 않는다면 brew를 사용해도 될 것 같습니다
mise
mise install tuist를 실행하려고 하니, 이런 오류가 났습니다.
-bash: mise: command not found
그래서 먼저 mise를 설치해야 했죠
brew install mise
그리고 다시 mise를 실행했습니다
mise install tuist
설치할 때 이렇게 버전을 지정할 수도 있습니다 tuist@x.x.x.
자 이제 설치가 끝난걸까요? 아닙니다, 현재 디렉토리에서 Tuist를 사용할 거라고 알려줘야 해요.
mise use tuist
이렇게 실행하면 최신 버전을 사용하지만, 설치할 때처럼 버전을 지정할 수도 있습니다.
Tuist 실행하기
설치의 다음 단계는 프로젝트를 구성하는 것입니다.
더 이상의 사용법이 없네요, 다음은 뭘 하죠?
다행히도 튜토리얼이 있었습니다
튜토리얼에는 rtx라고 나와있었지만, rtx 링크를 누르면 mise repository로 가졌습니다(그래픽 카드랑 헷갈려서 이름을 바꿨다네요).
저는 Tuist를 이미 설치했기 때문에 설치는 건너뛰었지만,
여전히 tuist를 실행할 수 없었습니다
-bash: tuist: command not found
Tuist는 mise로 설치했기 때문에 실행도 그걸로 해야 합니다. 그래서 먼저 사용법을 확인했습니다
mise --help
mise x -- npm install `npm install` w/ config loaded into PATH
help에 나와있는대로 tuist를 실행했더니
mise x -- tuist version
4.6.0
성공했네요!
Migration
다음은 기존 Xcode 프로젝트를 migration하기 위한 방법이 나와있는지 찾았습니다.
다행히도 migration 라는 명령이 있었습니다.
가이드에는 Migration에 대한 항목도 있었는데, 아무 내용도 없었습니다.

그래서 저는 오래된 migration 가이드를 찾았지만, Tuist 4는 아직 준비되지 않은 것 같았습니다
어쨌든 migration 명령을 사용해봤습니다
settings-to-xcconfig
먼저 --help 옵션으로 사용법을 확인했는데요
mise x -- tuist migration --help
OVERVIEW: A set of utilities to assist in the migration of Xcode projects to Tuist.
USAGE: tuist migration <subcommand>
OPTIONS:
-h, --help Show help information.
SUBCOMMANDS:
settings-to-xcconfig It extracts the build settings from a project or a target into an xcconfig file.
check-empty-settings It checks if the build settings of a project or target are empty. Otherwise it exits unsuccessfully.
list-targets It lists the targets of a project sorted by number of dependencies.
See 'tuist help migration <subcommand>' for detailed help.
첫번째 하위 명령에 settings-to-xcconfig가 있었습니다
mise x -- tuist help migration settings-to-xcconfig
OVERVIEW: It extracts the build settings from a project or a target into an xcconfig file.
USAGE: tuist migration settings-to-xcconfig --xcodeproj-path <xcodeproj-path> --xcconfig-path <xcconfig-path> [--target <target>]
OPTIONS:
-p, --xcodeproj-path <xcodeproj-path>
The path to the Xcode project
-x, --xcconfig-path <xcconfig-path>
The path to the .xcconfig file where build settings will be extracted.
-t, --target <target> The name of the target whose build settings will be extracted. When not passed, it extracts the
build settings of the project.
-h, --help Show help information.
추가 인수 없이 실행했을 때 나타난 사용 방법을 확인해봤지만 자동으로 migration하는 방법은 없고, 보조만 할 수 있는 것 같았죠.
그래서 -x 옵션을 사용해서
mise x -- tuist migration settings-to-xcconfig -p {Project Name}.xcodeproj -x {xcconfig name}.xcconfig -t {Target Name}

아래와 같은 .xcconfig 파일을 추출했습니다.
ASSETCATALOG_COMPILER_APPICON_NAME=AppIcon
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME=AccentColor
CURRENT_PROJECT_VERSION=1
DEVELOPMENT_ASSET_PATHS="queensbladelimithelper/Preview Content"
ENABLE_PREVIEWS=YES
GENERATE_INFOPLIST_FILE=YES
INFOPLIST_KEY_UIApplicationSceneManifest_Generation=YES
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents=YES
INFOPLIST_KEY_UILaunchScreen_Generation=YES
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad=UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight
...
check-empty-settings
두번째 하위 명령은 아래와 같이 설명 되어있습니다.
It checks if the build settings of a project or target are empty. Otherwise it exits unsuccessfully.
이게 무슨 소리인지 아직 잘 모르겠지만, 아마도 설정 항목이 기본값을 사용하는지 확인하는 것 같네요.
아래와 같이 실행했을 때
mise x — tuist migration check-empty-settings -p {Project Name}.xcodeproj -t {Target Name}
이런 결과를 볼 수 있었습니다
list-targets
마지막 하위 명령은 의존성을 나열하는데요.
mise x — tuist migration list-target -p {Project Name}.xcodeproj
실행하면 아래와 같은 결과를 볼 수 있었습니다
Package.swift 만들기
다음은 어떻게 할까요? Package.swift를 수동으로 만들어야할까요? Xcode 프로젝트로부터 Package.swift를 자동으로 만드는 방법은 없었습니다.
초기 Project 만들기
한가지 방법은 초기 프로젝트에서 파일을 복사하는 겁니다. 먼저 새로운 Tuist 프로젝트를 만들기 위해 이 명령을 실행했습니다.
mise x -- tuist init --platform ios
그전에 먼저 프로젝트를 만들 디렉토리 안에서 이 명령을 실행해야 합니다.
mise use tuist
아니면 이런 오류를 보게될 거에요.

이제 만들어진 초기 Tuist 프로젝트를 원래 소스에 복사하는 겁니다.

Tutorial 복사하기
두번째 방법은 Tutorial의 내용을 복사하는 것입니다.

파일들 옮기기
Sources
초기 프로젝트처럼, Sources 디렉토릴를 만들고 모든 Swift 파일들을 거기로 옮겼습니다

Resources
Resource 파일들 또한 Resource를 위한 디렉토리로 옮겨져야 합니다

Tests
또한 테스트가 있다면 전용 디렉토리로 보내는게 좋겠죠

Package.swift 설정하기
이렇게 Package.swift를 만들거나 복사한 후, 프로젝트에 맞게 변경합니다.
import ProjectDescription
let project = Project(
name: "{Your Project Name}",
targets: [
.target(
name: "{Your Target Name}",
destinations: .iOS,
product: .app,
bundleId: "{target package name}",
infoPlist: .extendingDefault(
with: [
"UILaunchStoryboardName": "LaunchScreen.storyboard",
]
),
sources: ["{Relative Path to Directory containing Source Files}/**"],
resources: ["{Relative Path to Directory containing Resource Files}/**"],
dependencies: []
),
.target(
name: "{Test Target name}",
destinations: .iOS,
product: .unitTests,
bundleId: "{test target package name}",
infoPlist: .default,
sources: ["{Relative Path to Directory containing Test Files}/**"],
resources: [],
dependencies: [.target(name: "{Your Target Name}")]
),
]
)
프로젝트 수정하기
다음은 Sources, Resources, Package.swift를 제외한 모든 파일들을 지우는 것 입니다.
이제 더이상 xcodeproj는 없습니다. 그럼 어떻게 앱을 실행하죠? Git에 올라가지는 않는 프로젝트를 만들어야 할까요?
Tuist는 임시적인 프로젝트 파일을 만드는 것을 지원합니다. 먼저 이 명령을 실행합니다.
mise x --tuist edit

Xcode가 열리지만 Project.swift만 있고 sources, resources는 보이지 않습니다. 프로젝트 설정만을 위한 프로젝트이기 때문이죠 🤣

Project 생성하기
edit 명령은 오직 프로젝트 설정만을 보여주기 때문에.
대신에 generate 명령을 실행했습니다. 사용방법은 아래와 같은데요.
OVERVIEW: Generates an Xcode workspace to start working on the project.
USAGE: tuist generate [--path <path>] [<sources> ...] [--no-open] [--no-binary-cache] [--configuration <configuration>]
ARGUMENTS:
<sources> A list of targets to focus on. Other targets will be linked as binaries if possible. If no target
is specified, all the project targets will be generated (except external ones, such as Swift
packages).
OPTIONS:
-p, --path <path> The path to the directory or a subdirectory of the project.
-n, --no-open Don't open the project after generating it.
--no-binary-cache Ignore binary cache and use sources only.
-c, --configuration <configuration>
Configuration to generate for.
-h, --help Show help information.
mise x -- tuist generate

이 명령으로 열린 프로젝트에서는 소스 파일들도 볼 수 있습니다.

Build 환경 설정
SwiftUI 미리보기도 아주 잘 동작합니다. 그러나 signing team은 비어있었습니다. 이 프로젝트는 임시인데, 어떻게 환경설정을 유지할 있을까요?
처음에 xcconfig를 추출했던 것을 기억하실겁니다.
먼저 그 .xcconfig 파일을 Configs 디렉토리에 넣고 app.xcconfig로 이름을 바꾸고,

Target에 적용하기 위해, settings property를 Project에 추가했습니다.
let project = Project(
...,
targets: [
.target(
...,
settings: .settings(configurations: [
.debug(
name: "Debug",
xcconfig: "Configs/app.xcconfig")
])
),
이제 Team이 설정된게 보입니다.

Release에도 적용하려면, configurations에 .release를 추가해줘야하죠.
settings: .settings(configurations: [
...,
.release(
name: "Release",
xcconfig: "Configs/app.xcconfig")
])
xcconfig 파일을 나누고 싶으실지도 모르겠습니다. 그럼 xcconfig를 복제해서 app.debug.xcconfig, app.release.xcconfig와 같이 나누면 됩니다.

다시 generate를 실행하면, 설정이 나눠진 것을 확인할 수 있습니다.

configurations를 dev, qa, deploy으로만 구성해도 debug, release는 항상 생기더군요.

SwiftUI를 사용하는 프로젝트라면, Preview Asset 경로도 xcconfig에서 설정해야합니다
DEVELOPMENT_ASSET_PATHS="Resources/Preview Content"
Swift Package Manager
저는 Swift Package를 사용할겁니다.

그러나 당연히 다시 Tuist를 generate하면 프로젝트에서 사라지겠죠. 그럼 Tuist에서 어떻게 패키지를 설치할까요?
저는 이 문서의 의존성 부분을 읽고 따라 했습니다. 당연히 tutorial도 있었습니다.
Package.swift
패키지들을 설치하기위해, Package.swift를 만들었습니다. Project.swift 처럼.

그리고 tutorial을 베꼈죠.

이제 edit으로 Tuist 설정을 할 때 Package.swift를 볼 수 있었고, Swift Package를 설치하기 위해 아래와 같이 수정했습니다.

Project.swift에서는 이렇게 의존성을 설정해주고
dependencies: [.package(product: "PackageName", type: .plugin)],
settings: ...
마지막으로 패키지들의 설치를 위해 아래 명령을 실행했습니다.
mise x --tuist install

프로젝트를 generate 하려고 했지만, 이런 오류가 났습니다.

오류나는 부분을 삭제해봤지만, Package를 import 할 수 없었습니다.

뭐가 문제인지 몰랐기 때문에. 다른 방법을 사용했습니다.
그 방법은 Project에서 직접 패키지를 설치하는 것이었습니다.
packages
Package.swift를 삭제하고 Project.swift를 이렇게 수정하자.
let project = Project(
...,
packages: [.remote(
url: "https://github.com/2sem/LSExtensions",
requirement: .exact("0.1.22"))],
...
dependencies: [.package(product: "LSExtensions", type: .runtime)],
프로젝트에서 Swift Package를 import할 수 있게 되었습니다.

Git Ignore
마지막으로 .gitignore는 이렇게 설정하고
Derived/
*.xcodeproj
*.xcworkspace
Git remove
프로젝트 파일들을 Cache에서 삭제했습니다
git rm --cached -r *.xcodeproj
git rm --cached -r *.xcworkspace
Clean 후 빌드 시간 비교
이렇게 변환된 초기 프로젝트의 빌드 속도를 비교한 결 입니다.
Tuist 적용 전: 9.4초

Tuist 적용 후: 3.5초

다음 글은 TCA 설정 관련된 내용입니다.
도움이 되셨다면, 좋아요를. 더 많은 iOS 관련글을 읽어 보세요.
저와 더 얘기하고 싶다면, LinkedIn으로 오세요. 감사합니다!
문제해결방법
bash: tuist: command not found
mise x -- tuist
The target xxx has the following invalid source files globs
Package.swift에서 그 디렉토리들이 존재하는지 확인.
One of the paths in DEVELOPMENT_ASSET_PATHS does not exist: …/Preview Content
.xcconfig 파일을 수정
DEVELOPMENT_ASSET_PATHS="Resources/Preview Content"
References
GitHub - jdx/mise: dev tools, env vars, task runner
dev tools, env vars, task runner. Contribute to jdx/mise development by creating an account on GitHub.
github.com
https://docs.tuist.io/documentation/tuist/installation
What is Tuist? | Tuist
docs.tuist.dev
https://docs.old.tuist.io/commands/migration
https://green1229.tistory.com/359
Tuist의 Configuration 설정하기
안녕하세요. 그린입니다🍏 이번 포스팅에서는 Tuist의 Configuration을 알아보고 각 개발 환경을 분리하여 설정해보도록 하겠습니다🙌 들어가기 전 필요 개발 환경 체크 기본적으로 프로젝트는 DEBU
green1229.tistory.com
'Programming > iOS' 카테고리의 다른 글
프로젝트에 Tuist로 TCA 준비하기 (0) | 2025.02.26 |
---|---|
The selected Xcode version is 16.2, which is not compatible with this project’s Xcode version requirement of 14.0.0. (0) | 2025.01.12 |
Sonoma에서 Xcode 14 실행하기 #iOS #Xcode (0) | 2025.01.11 |
Ventura에서 Xcode 15 실행하는 방법 #Xcode #MacOS #강제실행 #제한해제 (0) | 2025.01.04 |