Home CocoaPods 꿀팁
Post
Cancel

CocoaPods 꿀팁

특정 주소의 pod을 타겟으로 바라보기

http://guides.cocoapods.org/using/the-podfile.html#from-a-podspec-in-the-root-of-a-library-repo

1
2
3
4
5
6
7
8
9
10
11
To use the master branch of the repo:
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git'

To use a different branch of the repo:
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'dev'

To use a tag of the repo:
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => '3.1.1'

Or specify a commit:
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :commit => '0f506b1c45'

pod이 업데이트 되었는지 확인하기

1
2
pod outdated

입력하면 아래와 같이 버전 정보가 비교되어 나온다. latest version을 보고 필요한 경우 업데이트 해주면 된다.

1
2
3
The following pod updates are available:
- AFNetworking 2.6.3 -> 2.6.3 (latest version 3.2.1)
- SnapKit 4.0.1 -> 4.0.1 (latest version 4.2.0)

CocoaPods warning 제거하기 ⚠️

1. inhibit_warnings 옵션 적용하기

iOS 프로젝트에 오픈소스를 간편하게 가져올 수 있도록 도와주는 cocoapods를 사용하다 보면 warning이 많이 발생하는 것을 볼 수 있다. 내가 작성한 코드도 아닌데 warning이 이렇게나 많이 뜨는것은 좀 억울하다는 생각이 들었다.

때마침 Xcode 에서 Pod 프로젝트의 경고 표시 없애기 링크가 보이길래 적용해보았다. 경고를 무시하고 싶은 pod 파일 뒤에 :inhibit_warnings => true를 명시 하면 된다는 것이다.

1
pod 'Alamofire', '~> 4.5', :inhibit_warnings => true

마침 FBSDKLoginKit에서 warning이 발생하고 있어서 바로 적용해봤다. 음… 잘된다. 하지만 새로운 pod이 추가될 때 마다 같은 문구를 반복해서 달아줘야 한다는 것은 아주 귀찮은 일이다.

2. 모든 pod에 inhibit_warnings 옵션 적용하기

다들 개발자들도 귀찮은 것을 싫어하지 않을까? 싶어서 검색해봤다. https://github.com/ClintJang/cocoapods-tips

1
inhibit_all_warnings!

앞으로 pod이 새롭게 추가되어도 pod 설치시에 위의 스크립트가 돌면서 warning을 만나지 않게 되었다. 🎉

타겟별 공통으로 사용되는 pod 파일 묶어주기

이건 조금 다른 이슈인데, FBSDKLoginKit 에서 사용하는 코드가 AppExtension 에서는 작동하지 않는다는 것을 알게되었다.

1
2
UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController.presentedViewController;
// FBLogin 'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.

타겟별로 분리하지 않았기 때문에 이런 이슈가 발생했다. 그렇다고 해서 이렇게 무식하게 하나만 빼고 전부 복붙을 할 수는 없는 노릇이다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
target 'sieum' do
  shared_pods
  # Pods for sieum
  pod 'FBSDKLoginKit' # 이것만 다르다
  pod 'SnapKit', '~> 4.0.0'
  pod 'Firebase/Core'
  pod 'Firebase/Database'
  pod 'DBImageColorPicker', '~> 1.0.0'
  pod 'Alamofire', '~> 4.3'
  pod 'SwiftyBeaver'
  pod 'PopupDialog', '~> 0.5'
  pod 'SwiftyJSON'
  pod 'Kingfisher', '~> 4.0'
  pod 'SHSideMenu', '~> 0.0.4'
  pod 'RxDataSources', '~> 3.0'
  pod 'RxTheme', '2.0'
  pod 'Then'
  pod 'ObjectMapper', '~> 3.3'
end

target 'SieumWidget' do
  pod 'SnapKit', '~> 4.0.0'
  pod 'Firebase/Core'
  pod 'Firebase/Database'
  pod 'DBImageColorPicker', '~> 1.0.0'
  pod 'Alamofire', '~> 4.3'
  pod 'SwiftyBeaver'
  pod 'PopupDialog', '~> 0.5'
  pod 'SwiftyJSON'
  pod 'Kingfisher', '~> 4.0'
  pod 'SHSideMenu', '~> 0.0.4'
  pod 'RxDataSources', '~> 3.0'
  pod 'RxTheme', '2.0'
  pod 'Then'
  pod 'ObjectMapper', '~> 3.3'
end

그래서 공통으로 쓰이는 부분은 shared_pods로 묶고, 특정 타겟에서 필요한 것만 정의해서 쓰는 방법을 사용했다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def shared_pods
  use_frameworks!
  pod 'SnapKit', '~> 4.0.0'
  pod 'Firebase/Core'
  pod 'Firebase/Database'
  pod 'DBImageColorPicker', '~> 1.0.0'
  pod 'Alamofire', '~> 4.3'
  pod 'SwiftyBeaver'
  pod 'PopupDialog', '~> 0.5'
  pod 'SwiftyJSON'
  pod 'Kingfisher', '~> 4.0'
  pod 'SHSideMenu', '~> 0.0.4'
  pod 'RxDataSources', '~> 3.0'
  pod 'RxTheme', '2.0'
  pod 'Then'
  pod 'ObjectMapper', '~> 3.3'
end

target 'sieum' do
  shared_pods
  # Pods for sieum
  pod 'FBSDKLoginKit'
end

target 'SieumWidget' do
  shared_pods
end

완벽하진 않지만 이제야 좀 정리된 것 같다.

This post is licensed under CC BY 4.0 by the author.

What's New in Testing

jekyll 테마 적용하기