Creating an iOS Library the Right Way (SPM and CocoaPods)

As an iOS developer, libraries make our development process, therefore our life easier. Thanks to these libraries, we shorten our development process and make it practical. I’ll try to describe the issues we’ll face when developing our own iOS library(s).

In Short

Create SPM Project for our iOS Library

Create SPM Project for our iOS Library

 

Left Icon

Empower Your iOS Projects Now!

Right Icon Learn More

Edit Library Settings

[gist id=”bdac4d1b67f7f4296be55cf402ab6723″ /]

Development Time

[gist id=”4db0f6ebf97e2c97550f81dd81a9992c” /]

Adding CocoaPods Support to our iOS Library

sudo gem install cocoapods

After the installation process is complete, create your CocoaPods project in the directory you choose with the following command line. While creating your project, you will receive certain questions about the project details and you can answer them as follows.

pod lib create ProjectName

[gist id=”cc2e137e7ab13cff507a4355776a3618″ /]

[gist id=”b4b7c4358628b9799ef7ee548df1da04″ /]

Polishing

[gist id =”a6d0a6e2e42520fe99725e57443a071a” /]

Publishing Our iOS Library

pod trunk register 'your e-mail address'

After confirming your mail, it’s time to see if our project is suitable for publishing. I recommend you to edit the warnings, either you gave a path error or an unreachable link. Using “ — allow-warnings” will cause you to encounter a possible error in the future.

pod lib lint

If you are ready to publish your validated CocoaPods library, run the command line and your library is now available to all developers.

pod trunk push

[gist id=”627f914a8f4494d35ae8059e3de1863f” /]