Home > Mobile >  How to mark an imported Cocoapod framework deprecated
How to mark an imported Cocoapod framework deprecated

Time:10-16

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.

CodePudding user response:

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

CodePudding user response:

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.

  • Related