ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

728x90
๋ฐ˜์‘ํ˜•

๐Ÿ’จ Swift Package Manager ๋ฅผ ์‚ฌ์šฉํ•ด๋ณด์ž

Xcode 11 ๋ถ€ํ„ฐ ์• ํ”Œ์—์„œ ๊ณต์‹์œผ๋กœ ์ง€์›ํ•˜๊ณ  Xcode ์— ๋‚ด์žฅ๋œ ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ €์ด๋‹ค.

์šฐ์„  Swift Package Manager(SwiftPM) ๋ฅผ ์‚ฌ์šฉํ•ด์„œ SnapKit ๋ฅผ ์„ค์น˜ํ•ด๋ณด์ž

1๏ธโƒฃ [Targets] โ†’ [General] โ†’ [Frameworks, Libraries, and Embedded Content] โ†’ [+]

2๏ธโƒฃ Add Package Dependency...

3๏ธโƒฃ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜ ์ฃผ์†Œ๋ฅผ ๊ธฐ์ž…ํ•œ๋‹ค.(๊นƒํ—ˆ๋ธŒ ์ฃผ์†Œ๋ฅผ ๊ธฐ์ž…ํ•ด์ฃผ์—ˆ๋‹ค.)

4๏ธโƒฃ ์„ค์น˜ ์‹œ ์›ํ•˜๋Š” ๋ฒ„์ „, ๋ธŒ๋žœ์น˜ ๋ฐ ์ปค๋ฐ‹์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

5๏ธโƒฃ ์›ํ•˜๋Š” package product ๋ฅผ ๊ณจ๋ผ์„œ [Finish]

SnapKit ์ด ์ œ๋Œ€๋กœ ์„ค์น˜๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

์ด๋ ‡๊ฒŒ SwiftPM ๋ฅผ ์‚ฌ์šฉํ•ด๋ณด์•˜๋‹ค. ์ƒ๊ฐ๋ณด๋‹ค ์„ค์น˜ํ•˜๋Š” ๊ณผ์ •์€ ์‰ฌ์› ๋‹ค.

๊ทธ๋ ‡๋‹ค๋ฉด ์–ด๋–ค SwiftPM ์˜ ์žฅ๋‹จ์ ๋“ค์ด ์žˆ๋Š”์ง€ ์•Œ์•„๋ณด์ž.

๐Ÿ’จ SwiftPM ์˜ ์žฅ๋‹จ์ ์€?

โ—๏ธ ์žฅ์ 

  • package ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ธฐ ์‰ฝ๋‹ค. podfile ์„ ๊ด€๋ฆฌํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค.
  • ์จ๋“œํŒŒํ‹ฐ์˜ CocoaPods ๊ณผ๋Š” ๋‹ฌ๋ฆฌ ํผ์ŠคํŠธํŒŒํ‹ฐ ํˆด์ด๋‹ค. ์ถ”๊ฐ€์ ์ธ ์„ค์น˜๊ฐ€ ํ•„์š”์—†๋‹ค.
  • Xcode ์‚ฌ์ด๋“œ๋ฐ”์— ๋ช…ํ™•ํ•˜๊ฒŒ ํ‘œ์‹œํ•˜๊ณ  ํŒจํ‚ค์ง€์˜ ํ˜„์žฌ ๋ฒ„์ „๋„ ๋ณด์—ฌ์ค€๋‹ค.

โ—๏ธ ๋‹จ์ 

  • CocoaPods ๊ฐ€ ์ƒ์„ฑํ•˜๋Š” Pods/ ๋””๋ ‰ํ† ๋ฆฌ์— ํ•ด๋‹นํ•˜๋Š” ๊ฒƒ์ด ์—†๋‹ค. SwiftPM ์„ ์‚ฌ์šฉํ•˜๋ฉด dependencies ๊ฐ€ ํ”„๋กœ์ ํŠธ์˜ ํŒŒ์ƒ ๋ฐ์ดํ„ฐ ๋””๋ ‰ํ† ๋ฆฌ(~/Library/Developer/Xcode/DerivedData/...) ๊นŠ์ˆ™์ด ์ €์žฅ๋ฉ๋‹ˆ๋‹ค.
  • ํŒจํ‚ค์ง€๋ฅผ ์—…๋ฐ์ดํŠธํ•  ๋•Œ all or nothing ์˜ ์„ ํƒ์ง€๋งŒ ์ฃผ์–ด์ง„๋‹ค. ๋‹จ์ผ ํŒจํ‚ค์ง€์— ๋Œ€ํ•œ ๋ฒ„์ „์„ ์—…๋ฐ์ดํŠธ ํ•  ์ˆ˜ ์—†๋‹ค.
  • SwiftPM ์€ CocoaPods ์™€ ๊ฐ™์€ ์ปค๋ฎค๋‹ˆํ‹ฐ ๊ธฐ๋ฐ˜ ๋„๊ตฌ๋ณด๋‹ค ๋Š๋ฆฐ ํ”„๋กœ์„ธ์Šค๋‹ค. CocoaPods๋Š” ์ˆ˜์ • ์‚ฌํ•ญ ๋ฐ ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์„ ์œ„ํ•ด ์ƒˆ ๋ฒ„์ „์„ ๋น ๋ฅด๊ฒŒ ๋ฆด๋ฆฌ์ฆˆํ•  ์ˆ˜ ์žˆ์ง€๋งŒ SwiftPM์€ Xcode ๋ฆด๋ฆฌ์ฆˆ ์ผ์ •์— ๊ตฌ์†๋ฉ๋‹ˆ๋‹ค.
  • SwiftPM ์€ ํ˜„์žฌ Objective-C ์™€ Swift ๊ฐ€ ํ˜ผํ•ฉ๋œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค.
  • SwiftPM ์€ ํ˜„์žฌ ์ด๋ฏธ์ง€, ์Šคํ† ๋ฆฌ๋ณด๋“œ, ์ž์‚ฐ ์นดํƒˆ๋กœ๊ทธ ๋“ฑ๊ณผ ๊ฐ™์€ ๋ฆฌ์†Œ์Šค ๋ฒˆ๋“ค์„ ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

๐Ÿ’จ ์ข…ํ•ฉ

  • ์ž‘๊ณ  ๊ฐ„๋‹จํ•œ ํ”„๋กœ์ ํŠธ์—์„œ ๋‚˜ ํ˜ผ์ž ๊ฐœ๋ฐœ์„ ํ•˜๊ณ  dependencies ๋ฅผ ๋‹ค ์†Œ์œ ํ•˜๊ณ  ์žˆ๋‹ค๋ฉด ์œ„์˜ ๋‹จ์ ๋“ค์ด ์˜ํ–ฅ์„ ๋ฏธ์น˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— SwiftPM ์€ ์œ ์šฉํ•˜๋‹ค.
  • ํฌ๊ณ  ๋ณต์žกํ•œ ํŒ€์ž‘์—…์˜ ๊ฒฝ์šฐ CocoaPods ์ด ์„ ํ˜ธ๋œ๋‹ค.
  • ๊ทธ๋Ÿผ์—๋„ SwiftPM ์€ ๊ฐ€๋Šฅ์„ฑ์ด ์žˆ๋‹ค. ์–ธ๊ธ‰ํ•œ ์ฃผ์ด์Šˆ๋“ค์€ ์‰ฝ๊ฒŒ ํ•ด๊ฒฐ๊ฐ€๋Šฅํ•˜๋‹ค.(ํŒจํ‚ค์ง€๋ณ„ ์—…๋ฐ์ดํŠธ ์ถ”๊ฐ€, linking ์„ ์œ„ํ•œ ํŒจํ‚ค์ง€๋ณ„ ํƒ€์ผ“ ์ถ”๊ฐ€, ํ”„๋กœ์ ํŠธ ๋ฃจํŠธ์— SwiftPM/ ๋””๋ ‰ํ† ๋ฆฌ ์œ ์ง€ํ•˜๋Š” ์˜ต์…˜ ์ถ”๊ฐ€, ๋ฒˆ๋“ค ๋ฆฌ์†Œ์Šค ํฌํ•จ ํ—ˆ์šฉ, Objective-C ์™€ Swift ํ˜ผํ•ฉ ํ—ˆ์šฉ ๋“ฑ)

์ถœ์ฒ˜ :

[Swift 5.2][SwiftPM] Swift Package Manager๋ฅผ ์ด์šฉํ•˜์—ฌ ํŒจํ‚ค์ง€๋ฅผ ํ†ตํ•ฉ ๊ด€๋ฆฌํ•˜๊ธฐ - Proxy Module

My experience replacing CocoaPods with SwiftPM

728x90
๋ฐ˜์‘ํ˜•
๋Œ“๊ธ€
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
๊ธ€ ๋ณด๊ด€ํ•จ
ยซ   2025/01   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
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
๋งํฌ
Total
Today
Yesterday