[Swift] CocoaPod vs Swift Package Manager

2023. 1. 26. 18:52ใ†Programming/Swift

1. CocoaPod vs Swift Package Manager

Podfile์„ ํ†ตํ•ด ํŒจํ‚ค์ง€ ์„ค์น˜๋ฅผ ํ•˜๋Š” ๊ฒƒ๊ณผ, XCode ๋‚ด๋ถ€์—์„œ ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ €๋ฅผ ํ†ตํ•ด ์„ค์น˜ํ•˜๋Š” ๊ฒƒ ๋‘˜์˜ ์ฐจ์ด(์žฅ๋‹จ์ )๊ฐ€ ๊ถ๊ธˆํ–ˆ๋‹ค.
๋ฌด์ž‘์ • ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ €๊ฐ€ ๋” ์ข‹์ง€! ๋ณด๋‹ค๋Š”, ์™œ ์ข‹์€์ง€ ๊ถ๊ธˆํ•ด์„œ ์ฐพ์•„๋ดค์Šต๋‹ˆ๋‹ค :)


1) CocoaPod

โœณ๏ธ Advantages

  1. You can search for a dependency on the official CocoaPods website.
  2. Supports both Dynamic Frameworks and Static Libraries (since version 1.5.0).
  3. Automatically manage a dependencyโ€™s dependencies.
    If a dependency relies on another dependency, CocoaPods will handle it for you.
  4. Anyone can easily tell what dependencies your app is using.
  5. It's easy to check if a new version of a dependency is available by using the command pod outdated.
  6. If the dependency supports it, you can try the dependency before integrating it into your project by using the command pod try Alamofire.
  7. Has an official Mac app to easily manage app dependencies.
  8. Almost every framework supports CocoaPods.

โ›”๏ธ Disadvantages

  1. You will have to wait a long time the first time you install your dependencies, even if itโ€™s just one, as CocoaPods will have to download the main Specs repository on your Mac. This will also happen on every pod update command when you want to update your dependencies.
  2. Your main project will be modified to be able to use all of your dependencies. It's also true that you can remove the CocoaPods integration by using the command pod deintegrate.
  3. Every time you build your project, all your dependencies will also be built, which leads to slower build times.



1) Swift Package Manager

โœณ๏ธ Advantages

  1. Itโ€™s the new standard build by Apple to create Swift apps.
  2. Automatically manage a dependencyโ€™s dependencies. If a dependency relies on another dependency, Swift Package Manager will handle it for you.(์ด๊ฑด ๋™์ผํ•˜๋„ค์š”)
  3. Anyone inside the project will easily know what dependencies your app is using. (์˜†์— ๋œจ๋‹ˆ๊น)
  4. Works on Linux.

โ›”๏ธ Disadvantages

  1. Currently doesn't support all the platforms like iOS, watchOS, or tvOS. (?!)
  2. You have to follow a specific folder structure.
  3. Some features on the Foundation corelib are unimplemented. You can find the current status here.
  4. Creating Unit Tests on Linux is not easy as on macOS. You also have to do additional turnaround.




Kakao Tech - Swift Package Manager ์ ์šฉ๊ธฐ

  • Swift Package Manager(SwiftPM)๋Š” ์ข…์†์„ฑ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•œ Apple์˜ ๊ณต์‹ ๋„๊ตฌ
  • Cocoapods์ด๋‚˜ Carthage์™€ ๊ฐ™์€ 3rd party tool์ด ์•„๋‹Œ 1st party๋กœ์„œ, Xcode11์— ๋‚ด์žฌ๋œ ๊ธฐ๋Šฅ์œผ๋กœ ์ถ”๊ฐ€๋จ
  • SwiftPM์€ ๋‚ด๋ถ€ ๋ชจ๋“ˆ์— ์‚ฌ์šฉ๋˜๋Š” dependency๋ฅผ ์ž๋™์œผ๋กœ ๊ด€๋ฆฌํ•ด ์ฃผ๊ณ , dependency๋ฅผ ์ถ”๊ฐ€ ๋˜๋Š” ๋ณ€๊ฒฝํ•  ๋•Œ๋งˆ๋‹ค pod install์ด๋ผ๋Š” ๋ถ€๊ฐ€ ์ž‘์—…์„ ํ•˜์ง€ ์•Š์•„๋„ ๋จ
  • 1st party ์ฆ‰, Apple ๊ณต์‹ ๋„๊ตฌ์ด๋ฏ€๋กœ ์• ํ”Œ ์ฃผ์ตœ ํ•˜์— ๋ฏธ๋ž˜์ ์œผ๋กœ ๊ณ„์† ๋ฐœ์ „์ด ๋  ์ข…์†์„ฑ ๋„๊ตฌ
  • ํ˜„์žฌ ๊ฒ€ํ†  ์ค‘์ธ Enterprise ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ช‡ ๊ฐ€์ง€๋ฅผ ์ œ์™ธํ•˜๊ณ ๋Š” ๋ชจ๋‘ SwiftPM์œผ๋กœ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜์„ ์™„๋ฃŒํ•œ ์ƒํƒœ์ด๊ณ , ์ถ”ํ›„ Cocoapods๋ฅผ ์ œ๊ฑฐํ•  ์˜ˆ์ •
  • ๋ชจ๋“ˆํ™” ์ž‘์—… ์‹œ ๋ชจ๋“ˆ์„ ์ƒ์„ฑํ•˜๊ณ  ๋ฐฐํฌํ•˜๋Š” ๋ฐฉ์‹์ด ๋‹ค๋ฅธ ์ข…์†์„ฑ ๋„๊ตฌ์™€ ๋น„๊ตํ–ˆ์„ ๋•Œ ๊ฐ„๋‹จํ•˜๋‹ค๋Š” ์žฅ์ 
  • C ๊ณ„์—ด๊ณผ Swift ํŒŒ์ผ์„ ํ•˜๋‚˜์˜ ๋ชจ๋“ˆ๋กœ ์‚ฌ์šฉํ•˜์ง€ ๋ชปํ•œ๋‹ค๋Š” ๋‹จ์ ์ด ์žˆ๋‹ค
  • Xcode์— ํŒจํ‚ค์ง€ ์ •๋ณด๊ฐ€ ๋…น์—ฌ์ ธ ์žˆ๋‹ค ๋ณด๋‹ˆ, ํ”„๋กœ์ ํŠธ ํŒŒ์ผ ๋กœ๋“œ ์‹œ Xcode๊ฐ€ package graph๋ฅผ resolveํ•˜๋Š” ์‹œ๊ฐ„์ด ์•…๊ฐ„ ์†Œ์š”๋œ๋‹ค๋Š” ๋‹จ์ 




โœณ๏ธ Summary of +

  • Apple์ด ์ง€์›ํ•˜๋Š” 1st Party๋ผ๋Š” ์žฅ์ 
  • ๊ฐ„ํŽธํ•˜๋‹ค๋Š” ์žฅ์ ! (๊นƒํ—ˆ๋ธŒ ์ฃผ์†Œ ๋ณต๋ถ™์œผ๋กœ ๋ฐ”๋กœ ์„ค์น˜ ๊ฐ€๋Šฅ) Pod install, Update๋ณด๋‹ค ๊ฐ„ํŽธํ•œ ๊ฒƒ ๊ฐ™๋‹ค.
  • ๊ฐœ์ธ์ ์œผ๋กœ XCode ๋‚ด๋ถ€์—์„œ ๋ฐ”๋กœ๋ฐ”๋กœ ํ™•์ธ๋œ๋‹ค๋Š” ์ ๋„ ์ข‹์•˜๋‹ค.
    (+ Podfile์ด ์ถ”๊ฐ€๋กœ ์ƒ๊ธฐ๊ณ , Workspace์—์„œ ์ž‘์—…ํ•ด์•ผ ํ•˜๋Š” CocoaPod์˜ ๊ณผ์ •๋ณด๋‹ค, ์ง๊ด€์ ์œผ๋กœ ํ™•์ธ ๊ฐ€๋Šฅํ•จ)

โ›”๏ธ Summary of -

  • ์ง€์›ํ•˜์ง€ ์•Š๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์žˆ๋‹ค๋Š” ์ 
  • Objective-C ์™€ Swift ํ˜ผํ•ฉ๋œ ํŒŒ์ผ์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค
    -> ์ด ๋‘˜์ด ํ˜ผํ•ฉ๋œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋„ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค





์ถœ์ฒ˜