iOS

[iOS] - CocoaPods(코코아팟), Xcode의 Library 관리

No.401 2020. 8. 1. 13:51

● 주제 : CocoaPods가 무엇인지 알고, 사용법을 익힙니다.

  • 할 일
  1. CocoaPods 이란?
  2. Cocoapods 사용법.
  • 내용
  • CocoaPods 이란? - https://cocoapods.org/ 에 가서 보면 "WHAT IS COCOAPODS"에 간단명료하게 설명을 합니다.                     CocoaPods는 Swift와 Objective-C Cocoa Project의 dependency를  management 하는 기능을 하며, 아주 많은 앱에서 사용 중이고 project의 확장을 아름답게 도와준다고 자랑..... 하고 있습니다.     ㅡ_ㅡ;;; 뭐 덧 붙일 내용이 없네요. ㅎㅎ
  • Cocoapods 사용법 - cocoapods 설치
$ sudo gem install cocoapods
  • Cocoapods 사용법 - 사용 

순서
1) "Podfile" 을 만들기 위해 프로젝트 폴더로 이동
2) "Podfile" 생성
3) "Podfile" 편집
4) vi 상의 "Podfile" 파일 내용 및 수정
5) "Podfile" 설치

$ cd "my-prject"
$ pod init
$ vi Podfile


# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target '프로젝트 명' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  
  ###'아래 부분에 필요한 라이브러리 추가 (SnapKit,AFNetworking,RealmSwift)'
  pod 'SnapKit', '~> 5.0.0'
  pod 'AFNetworking', '~> 3.0'
  pod 'RealmSwift' 
  ###'필요한 라이브러리 추가 끝'
  
  # Pods for 프로젝트 명

  target '프로젝트 명' do
    inherit! :search_paths
    # Pods for testing
  end

  target '프로젝트 명' do
    # Pods for testing
  end

end

** Podfile 편집

###'아래 부분에 필요한 라이브러리 추가 (SnapKit,AFNetworking,RealmSwift)'
pod 'SnapKit', '~> 5.0.0'
pod 'AFNetworking', '~> 3.0'
pod 'RealmSwift'
###'필요한 라이브러리 추가 끝'

** Podfile 설치

$ pod install 

SnapKit Library를 pod install 성공 했을 때 위와 같이 확인 할 수 있습니다. 

** Podfile 적용 후 Xcode loading file : "프로젝트명. xcworkspace" 파일로 프로젝트를 열 수 있습니다.