Xcode Command Line Tool 사용법 (2)

Xcode Command Line Tool 사용법 (2)

Analyze

xcodebuild에 source code를 정적(static)으로 분석해주는 기능이 있다. 이 기능을 활용하면 내 코드에 있는 문법적 오류를 알려준다. e.g. 사용하지 않는 변수의 존재, if-else if문에서 else의 부재

xcodebuild clean analyze \
-project SampleProject.xcodeproj \
-scheme SampleProject 

Build For Testing

Xcode 8에서 추가된 기능인데, 이 기능을 활용하면 한번만 빌드하고 여러번 테스트 할 수 있다.

xcodebuild build-for-testing \
-project SampleProject.xcodeproj \
-scheme SampleProject \
-destination generic/platform=iOS

Test Without Building

build-for-testing을 이용해서 build를 했다면 build과정을 생략하고 이전에 build된 데이터로 여러 destination에 testing을 진행할 수 있다.

xcodebuild test-without-building \
-project SampleProject.xcodeproj \
-scheme SampleProject \
-destination "platform=iOS Simulator,name=iPhone 15 Pro,OS=17.2"
-destination "platform=iOS,name=Sample iPhone"

references

xcodebuild: Deploy iOS app from Command Line iOS 프로그래밍팁 - XCode Analyze 이용하기 (정적 분석)