SWIFT3 프로젝트에 CocoaPods 연동하기
- 순서 -
1. 프로젝트 생성
2. CocoaPods 다운로드 및 설치 (처음 설치 시)
3. CocoaPods Podfile 생성 및 설정
4. 라이브러리 설치 및 사용
Step 1 프로젝트 생성
Xcode 를 실행하여 CocoaPods를 연동할 프로젝트를 만든다.프로젝트 이름은 "cocoapods_test" 로 하였다.
Step 2 CocoaPods 다운로드 및 설치
한번도 CocoaPods 를 설치하지 않았다면 아래와 같이 터미널을 실행하여 CocoaPods 을 설치한다
이미 설치를 했다면 건너뛰도록한다.
1) 터미널 실행하여 설치 명령어 입력 -> “sudo gem install cocoapods”
(참고로 제거는 sudo gem uninstall cocoapods)
(참고로 제거는 sudo gem uninstall cocoapods)
설치가 완료 되었다면 필요한 라이브러리들을 정리하기 위해 “pod setup --verbose” 명령어 실행
*설치 안해도 됩니다 필요하다면 설치하세요 참고로 오래 걸립니다. (5시간걸림)
너무 오래걸려 해결책을 찾아 시도 하였으나 저한테는 변화가 없었음.. 참고하세요
http://stackoverflow.com/questions/21022638/pod-install-is-staying-on-setting-up-cocoapods-master-repo
*설치 안해도 됩니다 필요하다면 설치하세요 참고로 오래 걸립니다. (5시간걸림)
너무 오래걸려 해결책을 찾아 시도 하였으나 저한테는 변화가 없었음.. 참고하세요
http://stackoverflow.com/questions/21022638/pod-install-is-staying-on-setting-up-cocoapods-master-repo
Step 3 CocoaPods Podfile 생성 및 설정
설치를 완료했다면 Step1에서 생성한 프로젝트 폴더 내 경로로 이동하여 “pod init” 명령어를 실행한다. 실행후 자동으로 PodFile이 생성된다.
![]() | ||
<"pod init"명령어 실행 후 Podfile 이 생성 됨을 확인할 수 있다.>
|
Podfile 을 여는 명령어는 두가지가 있다
"open -e podfile"
"open -a Xcode Podfile"

하나는 일반 메모장을 여는 것이고 하나는 Xcode 에서 파일을 여는 것이다.
둘중 아무거나 해도 상관없으니 일단 파일을 열어보자

"open -e podfile"
"open -a Xcode Podfile"

하나는 일반 메모장을 여는 것이고 하나는 Xcode 에서 파일을 여는 것이다.
둘중 아무거나 해도 상관없으니 일단 파일을 열어보자

Step 4 라이브러리 설치 및 사용
위에서 열었던 podfile 에 라이브러리를 추가한다.
이제 저장을 하고 터미널로 돌아와 프로젝트 폴더 경로에서 "pod install" 입력하여 라이브러리를 설치
하도록 한다
설치가 다 되었다면 프로젝트 폴더내에 프로젝트명.xcworkspace 파일을 열어본다

실행된 Xcode를 보면 라이브러리가 아래와 같이 xcode내에서 Pods 프로젝트가 import되어 있는 것을 확인할수 있다.

방금전 설치한 라이브러리가 정상적으로 설치되어 있는지 아래 ViewController 클래스내 함수에서
직접 코딩을 통해 확인가능하다.
좋은 자료 잘 보고 갑니다.
답글삭제감사합니다!!