Playground에서 Cocoapod 라이브러리 사용하기

in #kr5 years ago

엑스코드 플레이그라운드(Xcode Playground)에서 간단하게 코드를 테스트 해보고 싶은데 해당 코드가 특정 cocoapod 라이브러리에 의존성이 있는 경우 cocoapods-playgrounds 명령어 도구를 사용하면 편리하다.

설치 및 사용 방법

설치

sudo gem install cocoapods-playgrounds

플레이그라운드 프로젝트 생성

cocoapods playgrounds podName

위 명령어를 실행하면 위 라이브러리가 연결된 워크스페이스가 자동으로 생성되고, 해당 워크스페이스 안에 우리가 사용할 수 있는 playground 파일까지 포함되어있으니 여기서 마음껏 테스트 해보면 된다.

여러 라이브러리 동시 참조

여러개 라이브러리에 의존성을 가지는 플레이그라운드 프로젝트를 만들고 싶을 경우, 라이브러리 이름을 컴마로 구분하여 붙여 써 둔다.

pod playgrounds ReactiveKit,ReactiveReSwift,Bond

트러블 슈팅

gem install cocoapods-playgrounds를 통해 설치한 후 명령어를 실행시 Xcode 10에서 아래와 같은 에러 발생한다.

Errno::ENOENT - No such file or directory @ dir_initialize - /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/Source/Playground with Platform Choice.xctemplate

이 경우 다음 명령어를 통해서 직접 소스코드로 부터 gem을 빌드한 후 직접 설치하면 문제 해결됨. 현재 최신버전은 1.2.2으로 되어있는데, 버전이 업데이트 되는경우 이에 맞게 아래 명령어를 적절히 수정해 서 실행 할 것.

git clone https://github.com/asmallteapot/cocoapods-playgrounds.git
gem build cocoapods-playgrounds.gemspec
sudo gem install cocoapods-playgrounds-1.2.2.gem
Sort:  

Congratulations @yjiq150! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 900 upvotes. Your next target is to reach 1000 upvotes.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @yjiq150! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!