Unit Testing SDKs on iOS. Tips to make singleton and static… | by Leonardo Santos

Tricks to make singleton and static frameworks testable on iOS

Leonardo Santos
Picture by @zanilic from Unsplash

Earlier than we deep dive into our tips, bear in mind to all the time isolate the frameworks out of your venture modules and lessons, whether or not by making a wrapper, facade, adapters, or one thing else. Our venture’s structure and use instances mustn’t depend on exterior frameworks as a result of they all the time change. So bear in mind to isolate them in a separate class that may be simply modified with out affecting the lessons that implement it.

The commonest sort of unfriendly frameworks.


We normally see implementations like this:

We’re utilizing the IncogniaSDK for example.


Luckily, we will use protocols and the metatype sort from Swift. In keeping with Apple’s documentation:

More Posts