티스토리 뷰

Mobile/iOS

cocoapods. Library 등록 하기

out of coding 2018. 6. 25. 14:40

cocoapod에 자신이 만든 Library를 배포하는 방법에 대해서 알아보도록 하겠습니다.


저 같은 경우에는 UITextView에 PlaceHolder가 없어서 만들어 두고 싶어서 개발하게 되었습니다.


cocoapods이란?


iOS 개발자가 기존보다는 조금 더 쉽게 연관된 Library를 사용할 수 있도록 하는 방법입니다.


공식 사이트.

https://cocoapods.org/


많은 개발자분들이 사용하실거라 생각해서 더 이상 설명은 하지 않겠습니다.


시작하기 전에 저의 pod버전은 1.4.0입니다.

버전마다 약간씩 다를수 있습니다.


일단 두가지 방법을 제공합니다.


- 라이브러리 프레임워크를 생성해서 하는 방법

  : podSpec파일부터 프레임워크 파일까지 모두 만들어주는 방법입니다.


- 기존 프로젝트를 자신의 입맛대로 만들고 podSpec파일을 생성해서 하는 법

  : 자신이 만든 프로젝트에 podSpec파일을 넣어 주는 방법입니다.


두가지의 방법이 모두 동일하게 podSpec 파일을 수정하여 주어야 합니다.


이곳에 가면 

https://guides.cocoapods.org/making/making-a-cocoapod.html


생성하는 방법에 대해서 영어로 더 자세하게 있습니다.


1. pod lib create [YOUR_PROJECT_NAME]


이것을 사용하게 되면 Example 프로젝트, Pod 프로젝트, 워크스페이스 등등 모든것을 만들어 줍니다.


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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
$ pod lib create HintTextView
Cloning `https://github.com/CocoaPods/pod-template.git` into `HintTextView`.
Configuring HintTextView template.
 
------------------------------
 
To get you started we need to ask a few questions, this should only take a minute.
 
2018-06-24 23:52:12.759 defaults[4071:695066
The domain/default pair of (org.cocoapods.pod-template, HasRunbefore) does not exist
If this is your first time we recommend running through with the guide: 
 - https://guides.cocoapods.org/making/using-pod-lib-create.html
 ( hold cmd and double click links to open in a browser. )
 
 Press return to continue.
 
 
What platform do you want to use?? [ iOS / macOS ]
 > iOS
 
What language do you want to use?? [ Swift / ObjC ]
 > Swift
 
Would you like to include a demo application with your library? [ Yes / No ]
 > No
 
Which testing frameworks will you use? [ Quick / None ]
 > None
 
Would you like to do view based testing? [ Yes / No ]
 > No
 
Running pod install on your new library.
 
Analyzing dependencies
Fetching podspec for `HintTextView` from `../`
Downloading dependencies
Installing HintTextView (0.1.0)
Generating Pods project
Integrating client project
 
[!] Please close any current Xcode sessions and use `HintTextView.xcworkspace` for this project from now on.
Sending stats
 
 
 
 
 
 
 
git statuPod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
 
[!] Automatically assigning platform `ios` with version `9.3` on target `HintTextView_Tests` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
s
 Ace! you're ready to go!
 We will start you off by opening your project in Xcode
  open 'HintTextView/Example/HintTextView.xcworkspace'
cs


제가 해봤던 부분인데요. 간략하게 언어 언어, 베이스 선택, Demo 앱 선택 등등 선택할수 있는 부분들을 선택하게 되면 프로젝트가 생성이 되고 podSpec파일을 알아서 만들어 줍니다.


그리고 나서 생성된 프로젝트를 xcode로 열어줍니다.


후훗. 그렇지만 여기서 끝나지는 않습니다.


2. 1번이 싫고 깨끗하게 하고 싶다면 spec file 생성하기


1
pod spec create [NAME|https://github.com/USER/REPO]
cs


http://guides.cocoapods.org/terminal/commands.html#pod_spec_create


일단 뭐 특별하게 이야기 할게 없어서 스킵합니다.

저는 이 방법을 추천함...


3. lint 실행하기


1
2
3
4
5
6
7
8
9
10
$ pod lib lint
 
 -> HintTextView
 -> HintTextView (0.1.0)
    - WARN  | summary: The summary is not meaningful.
    - WARN  | url: The URL (https://github.com/developerhyuk/HintTextView) is not reachable.
    - WARN  | [iOS] swift: The validator used Swift 3.2 by default because no Swift version was specified. To specify a Swift version during validation, add the `swift_version` attribute in your podspec. Note that usage of the `--swift-version` parameter or a `.swift-version` file is now deprecated.
 
[!] HintTextView did not pass validation, due to 3 warnings (but you can use `--allow-warnings` to ignore them).
You can use the `--no-clean` option to inspect any issue.
cs


pod lib 의 lint를 체크하여야 합니다.


스펙은 여기에서 확인 바랍니다.

https://guides.cocoapods.org/syntax/podspec.html


4. github등에 소스 올리기


소스를 올리면 끝나는것은 아닙니다.


tag를 달아주고 이것을 토대로 cocoapod에서는 버저닝을 하게 됩니다.


( 추가 - 2020.06.14 ) release tab에 가서 자신이 원하는 버전을 podspec에 넣어둔것과 맞추어서 release 하여 주시기 바랍니다.


5. pod에 등록


1
$ pod trunk register your@email.com 'your name' --description='your description'
cs


( 추가 - 2020.06.14 ) pod trunk register your@email.com 까지만 넣어주면 뒤에 부분은 옵션입니다.


이렇게 하면 반응이 옵니다.


1
[!] Please verify the session by clicking the link in the verification email that has been sent to ,,,
cs


이메일을 확인하러 가봅니다.



이렇게 하라고 하는데요... 다음과 같이 해도 됩니다.


6. 메일주소 등록 확인 (등록된 나의 repo들을 확인 가능합니다.)


1
$ pod trunk me
cs


이렇게 하고 나면 다음과 같이 반응합니다.


1
2
3
4
5
6
7
$ pod trunk me
  - Name:     yourname
  - Email:    your@email.com
  - Since:    June 25th, 13:06
  - Pods:     None
  - Sessions:
    - June 25th, 13:06 - October 31st, 13:07. IP: 14.40.34.109 Description: Description
cs


7. podSpec 파일 Push


1
$ pod trunk push
cs

이렇게 하면 pod파일을 json 형식으로 변환해서 cocoapods의 specs에 등록한다고 합니다.


그런데...


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ pod trunk push
 
[!] Found podspec `HintTextView.podspec`
Updating spec repo `master`
 
CocoaPods 1.5.3 is available.
To update use: `sudo gem install cocoapods`
 
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.5.3
 
Validating podspec
 -> HintTextView (0.1.0)
    - ERROR | [iOS] unknown: Encountered an unknown error ([!/usr/bin/git clone https://github.com/outofcoding/HintTextView.git /var/folders/08/ppcgrny516scddx3vpv6lkkr0000gn/T/d20180625-1081-c4u0pu --template= --single-branch --depth 1 --branch 0.1.0
 
Cloning into '/var/folders/08/ppcgrny516scddx3vpv6lkkr0000gn/T/d20180625-1081-c4u0pu'...
warning: Could not find remote branch 0.1.0 to clone.
fatal: Remote branch 0.1.0 not found in upstream origin
) during validation.
 
[!] The spec did not pass validation, due to 1 error.
cs


저는 중간에 에러가 발생하였습니다.


이유는 위에서도 말씀 드렸던 git의 tag에 대한 부분인데요. git에서 tag의 버전으로 가져와서 사용하려고 하는데, 브랜치가 없는 상태인겁니다.


제가 오타를 냈거든요..


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
37
38
39
40
41
$ git push origin :v0.1.0
...: 
To github.com:outofcoding/HintTextView.git
 - [deleted]         v0.1.0
 
$ git tag 0.1.0
$ git push origin 0.1.0
...: 
Total 0 (delta 0), reused 0 (delta 0)
To github.com:outofcoding/HintTextView.git
 * [new tag]         0.1.0 -> 0.1.0
 
$ pod trunk push
 
[!] Found podspec `HintTextView.podspec`
Updating spec repo `master`
 
CocoaPods 1.5.3 is available.
To update use: `sudo gem install cocoapods`
 
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.5.3
 
Validating podspec
 -> HintTextView (0.1.0)
 
Updating spec repo `master`
 
CocoaPods 1.5.3 is available.
To update use: `sudo gem install cocoapods`
 
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.5.3
 
 
--------------------------------------------------------------------------------
 🎉  Congrats
 
 🚀  HintTextView (0.1.0) successfully published
 📅  June 25th, 13:14
 🌎  https://cocoapods.org/pods/HintTextView
 👍  Tell your friends!
--------------------------------------------------------------------------------
cs


태그를 정확하게 맞추어주면 아래에... 축하한다는 메세지와 함께 친구에게 이야기를 하랍니다.

저는 여기에 이야기를 하고 있지요.


8. 친구에게 이야기 합시다.






'Mobile > iOS' 카테고리의 다른 글

iOS. Core Data 간략히 설명  (0) 2018.06.30
Swift. 접근 한정자  (0) 2018.06.25
Swift. reflection.  (0) 2018.06.24
Swift. Custom ViewController Transition. Present  (0) 2018.06.24
RxSwift. Observable combine  (0) 2018.06.19
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
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
글 보관함