Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mark an imported Cocoapod framework deprecated

In one of our frameworks we're using the SwiftObserver pod. Our framework is used in several other frameworks of our app.

After raising the development target to iOS 13.0 I'd like to mark all usage of the SwiftObserver methods as deprecated to gradually change our codebase to use Combine's observers.

I was thinking of forking SwiftObserver or linking a local copy of the pod from now on. However parts of the app that still use SwiftObserver should be able to continue updating it using pod update as long as not all code has been changed to use Combine.

Is there a simpler way, maybe in the podfile, or with some sort of overwrite, to mark the usage of that pod deprecated without breaking any of its funktionality?

Please let me know if you have further questions or if there are any code samples I can provide.

like image 226
Marco Boerner Avatar asked Dec 14 '25 09:12

Marco Boerner


2 Answers

An alternative to using swiftlint proposed by @SoumyaMahunt, could be to setup your own private repo.

Here's how you might be able to achieve what you want:

  1. Create a private spec repo to be used to resolve the CocoaPod dependencies.
  2. Create a podspec for SwiftObserver and set it to deprecated -> s.deprecated = true
  3. Add the private spec repo above source 'https://github.com/CocoaPods/Specs.git', this is important to force CocoaPods to resolve against your private repo before searching in the global default repo.

Pros

  • You can use this private spec repo for other private pods
  • You can deprecate other pods without having to hack in your project.

Cons

  • Can be tideous to manually make sure the third-party pods are updated to the latest versions (you'll have to manually add new podspecs for the updated version).
Helpful links:

https://guides.cocoapods.org/making/private-cocoapods.html

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

like image 68
Laffen Avatar answered Dec 16 '25 00:12

Laffen


If you are using swiftlint, you can add custom rule to produce warning with a message indicating deprecation. You can also adjust severity of these warning to cause compilation error as well.

For producing warning with SwiftObserver pod create the following custom rule in swift lint config file (.swiftlint.yml):

custom_rules:
  pod_deprecation:
    name: "Deprecated POD use"
    regex: "(SwiftObserver)"
    match_kinds:
      - identifier
    message: "Use of deprecated pods"

This rule will cause warning with the message provided in the message parameter for all the files that import SwiftObserver:

sample warning

like image 37
Soumya Mahunt Avatar answered Dec 15 '25 22:12

Soumya Mahunt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!