Notice
Recent Posts
Recent Comments
Link
관리 메뉴

김종권의 iOS 앱 개발 알아가기

[iOS - swift] 6. Tuist로 모듈화 - tuist graph 사용 방법 (의존성 확인, 의존성 관리 방법) 본문

iOS 응용 (swift)

[iOS - swift] 6. Tuist로 모듈화 - tuist graph 사용 방법 (의존성 확인, 의존성 관리 방법)

jake-kim 2023. 3. 17. 01:01

* 목차

static framework, dynamic framework

* static framework, dynamic framework 개념은 이전 포스팅 글 참고

  • tuist로 static, dynamic framework 만들기

의존성 관리 방법

* starter project: git

  • tuist graph 명령어 실행
tuist graph
  • tuist graph 했을때 아래 warning이 뜨면서 graph 파일이 생성 안되는 경우?
% tuist graph   
Installing GraphViz... 
Warning: your HOMEBREW_PREFIX is set to /usr/local but HOMEBREW_CELLAR is set
to /usr/local/Homebrew/Cellar. Your current HOMEBREW_CELLAR location will stop
you being able to use all the binary packages (bottles) Homebrew provides. We
recommend you move your HOMEBREW_CELLAR to /usr/local/Cellar which will get you
access to all bottles."

...

You must: brew install svn
Error: graphviz: Failed to download resource "netpbm"
Failure while executing; `/usr/bin/env svn checkout https://svn.code.sf.net/p/netpbm/code/stable /Users/jake/Library/Caches/Homebrew/netpbm--svn --quiet -r 4482` exited with 1. Here's the output:
You must: brew install svn

The 'brew' command exited with error code 1
Consider creating an issue using the following link: https://github.com/tuist/tuist/issues/new/choose
  • HOMEBREW_CELLAR의 위치문제이므로 아래의 명령어로 Cellar 위치를 변경하고 다시 tuist graph 입력하면 완료
% sudo mv /usr/local/Homebrew/Cellar /usr/local/Cellar
  • tuist graph 성공 시 아래처럼 graph.png 파일이 생성

tuist graph 결과
생성된 graph.png 파일

  • 그림에따라 특성이 있어서, 그림만봐도 쉽게 구분이 가능
    • 오렌지색 DB 모양은 dynamic framework
    • 빨간색 DB 모양은 static fraemwork

https://docs.tuist.io/1/commands/graph/

의존성 관리 주의사항

1). 의존성이 단방향을 이루도록 할 것

  • 의존성이 cycle을 이루는 경우, 결합도가 증가하여 단방향만 이루도록 할 것

2). dynamic framework 두 개 이상이, 하나의 static framework를 의존하는 경우

  • static framework를 의존하게되면 코드 복사가 이루어지므로 dynamic framework 하나만 의존하도록 할 것 (dynamic framework와 static framework가, static framework를 의존하는 것은 가능)

정리)

  • static1, static2 -> static (ok)
  • static1, dynamic1 -> static (ok)
  • dynamic1, dynamic2 -> static (코드중복발생)

(링커 타임 관련 내용은 이전 포스팅 글인 빌드 시스템 참고)

* static은 링커 타임에 결정되므로 여러개의 static framework가 하나의 static을 의존하더라도 링커타임에 체크하기에 때문에 하나만 만듦
* dynamic은 링커타임이 아닌 런타임에 코드를 참조하면서 이때 복사해버리기 때문에 static이 두 번 참조되면 2개의 동일한 static 프레임워크가 생성  (static1과 dynamic1 각각 static을 참조하는 경우는 이미 static1이 참조하여 링커타임에 생성되고, dynamic1이 런타임에 참조할 경우 static1이 만든 파일을 사용하기 때문에 중복x)

 

* 전체 코드: https://github.com/JK0369/ExTuist_5

* 참고

https://docs.tuist.io/1/commands/graph/

Comments