본문 바로가기

Swift 공부

Tuist 3.x 라이브러리 등록 방법

Tuist 관련 자료들을 보면 모두 버전이 2.x 타겟으로 되어있어 사용할때 디플리케이트 된 함수라고 떠서 머리가 조금 아프다.

 

그래서 이번에 직접 Doc를 보면서 Tuist 의 사용법을 공부했다.

 

기존이랑 많이 변하게된 부분이 라이브러리를 사용하는 부분인데 기존의 코드와 다르게

 

Dependencies 파일을 Tuist에 만들어준 후 

 

SPM으로 사용할 라이브러리를 등록한다.

import ProjectDescription

let dependencies = Dependencies(
    
    swiftPackageManager: .init([
        .remote(url: "https://github.com/ReactiveX/RxSwift.git", requirement: .upToNextMajor(from: "6.5.0")),
        .remote(url: "https://github.com/RxSwiftCommunity/RxDataSources.git", requirement: .upToNextMajor(from: "5.0.0")),
        .remote(url: "https://github.com/RxSwiftCommunity/RxGesture.git", requirement: .upToNextMajor(from: "4.0.3")),
        .remote(url: "https://github.com/onevcat/Kingfisher.git", requirement: .upToNextMajor(from: "7.2.0")),
        .remote(url: "https://github.com/Moya/Moya.git", requirement: .upToNextMajor(from: "15.0.0")),
        .remote(url: "https://github.com/SnapKit/SnapKit.git", requirement: .upToNextMajor(from: "5.0.1")),
        .remote(url : "https://github.com/devxoul/Then", requirement: .upToNextMajor(from: "2.0.0")),
        .remote(url : "https://github.com/Swinject/Swinject.git" ,  requirement: .upToNextMajor(from: "2.8.0")),
        //        .remote(url: "https://github.com/Alamofire/Alamofire.git", requirement: .upToNextMajor(from: "5.6.0")),
        .remote(url: "https://github.com/RxSwiftCommunity/RxAlamofire.git", requirement: .upToNextMajor(from: "6.1.0")),
    ], baseSettings: .settings(
        configurations: [
            .debug(name: "Debug"),
            .release(name: "Release")
        ])
    ),
    
    platforms: [.iOS]
)

 

이런식으로 등록을 해주면되고 configuraion에 내가 사용할 configuration이 등록을 해주면된다고 나와있는데 Debug ,Release 를 사용 하지않고 실제 프로젝트에선 Mock , Prod , Dev ,Staging을 사용하는데 그걸 사용하도록 바꿔줄려고하니 Debug, Release말고는 안된다고 오류가 뜨는데 이 부분은 아직 해결방법을 찾고있다.

 

Tusit SPM 라이브러리 설정은 이렇게 등록을 진행해주면되고 해당 프로젝트로 나와

 

tuist fetch

명령어를 통해 라이브러리를 등록동기화 시켜주면된다.

 

그리고 나머지 info.plist설정 ,configuration 설정쪽은 크게 변한것이 없고 

사용하는 프로젝트에 맞춰

     Target(
            name: "TuistTestApp",
            platform: .iOS,
            product: .app,
            bundleId: "com.jyk.TuistTestApp",
            deploymentTarget : .iOS(targetVersion: "13.0.0", devices: .iphone),
            infoPlist: .extendingDefault(with: infoPlist),
            sources: ["Targets/TuistTestApp/Sources/**"],
            resources: ["Targets/TuistTestApp/Resources/**"],
            dependencies: [
                .external(name: "RxSwift"),
                .external(name: "RxDataSources"),
                .external(name: "RxGesture"),
                .external(name: "Kingfisher"),
                .external(name: "SnapKit"),
                .external(name: "Then"),
                .external(name: "Swinject"),
                .target(name: "NetworkPlatform")
            ]
        ),

라이브러리를 등록해주고 사용하면된다.

 

그리고 product를 보면 다양한 속성값들이 있는데 이 부분은 따로 정리해서 글을 쓰겠습니다.