나는한다개발 avatar

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

yjiq150

Published: 24 Nov 2018 › Updated: 24 Nov 2018

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

엑스코드 플레이그라운드(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

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

Written by

iOS/Web 개발자입니다.

Read more #kr posts


Best Posts From 나는한다개발

We have not curated any of yjiq150's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From 나는한다개발