How to create your own CocoaPods framework

Hello Everyone,

I hope you are well aware with CocoaPods and how to use this inside your XCode projects. If you are not well aware, follow my previous blog about how to use CocoaPods.

Now it is time to learn to build your own Pod framework.

Setup – What you need?

  • git account.
  • Make sure git is installed in your Mac machine. Because we will do all git commands from terminal only. (using source tree or any other application for git commands is not recommended)
  • Make sure your system is updated and you have latest Ruby Gems installed.
    $ sudo gem update --system
  • Install CocoaPods if you don’t have Pods installed in your Mac machine.
    $ sudo gem install cocoapods

Create your Pod framework

  1. Open terminal and redirect to desired folder where you want to put your Pod Framework.
  2. Create your framework with the command pod lib create. Here I am giving my Pod framework name ‘MZFacebookManager’.
  • $ pod lib create MZFacebookManager
This will ask you some series of questions. You can answer based on your choice. Like for my case I have given answers like this:
  1. What language do you want to use? [ ObjC / Swift ]
     - ObjC
  2. Would you like to include a demo application with your library? [ Yes / No ]
     - Yes
  3. Which testing frameworks will you use? [ Specta / Kiwi / None ]
     - None
  4. Would you like to do view based testing? [ Yes / No ]
     - No
  5. What is your class prefix?
     - MZ

Once you are done it will create the folder for MZFacebookManager. Inside this you can see structure like:

Screen Shot 2017-04-06 at 1.19.25 PM

.podspec file at the root is important file. This will contains your Pod version, dependencies, git url etc with some other Pod descriptions. You can edit the details, version and also define dependencies if your Framework is using any other third party Framework. Like in my case, my Framework is using ‘FBSDKLoginKit‘ and ‘FBSDKCoreKit‘.

Screen Shot 2017-04-06 at 1.20.49 PM

Once you are done with editing of podspec file you need to validate this file. You can do this with Pod lib lint command.

$ pod lib lint

Screen Shot 2017-04-06 at 1.36.27 PM
Now open github website and create a new repository for MZFacebookManager (give your Framework name).

Screen Shot 2017-04-06 at 1.45.58 PMOnce it is created, go back to terminal again and push your code (You can also ignore this Push if you don’t want to push a default code on your git).

But if you want to push, just make sure once again your .podspec file is defined the correct url of git repository.

s.source = { :git => 'https://github.com/muzammil-triffort/MZFacebookManager.git', :tag => s.version.to_s }

Push your code on git: 

$ git push

This will push the default code of your Framework. Now open XCode again and add your Framework files.

  • Delete ReplaceMe file
  • Add your ObjC or Swift files (based on the project type you have chosen at the start)
  • Like i have added three files inside development i.e. MZFacebookManager.h, MZFacebookLoginManager.h and .m files. These files will show when you install the Pod Framework.

Screen Shot 2017-04-06 at 2.00.39 PM

Once all files added and there is no error in your code. Update the version of your Framework by updating this inside .podspec file (0.1.1) and run lib lint command again to make sure everything is correct.

$ pod lib lint

When validation success, now first push the code on git by giving a tag.

$ git tag 0.1.1

$ git push origin 0.1.1

Push your Pods Spec

$ pod trunk push MZFacebookManager.podspec 
At first time you will get the error message to resgister your session:
[!] You need to register a session first. 
$pod trunk register muzammil@triffort.com 'Muzammil' --description='Testing'

Replace my email id and name with yours. This will send a verification link on your mail. Once you verified, you can continue with terminal.

$ pod trunk push MZFacebookManager.podspec 
If all goes well Pod spec successfully update on git and you can see it is showing the description and other Pod details on home page of your git repository.
You can also add –verbose in lib lint and trunk push command to see the detail result (in case of error).
If you open your github repository, you can see screen like this:
Screen Shot 2017-04-06 at 2.22.10 PM
 Summary
# Create Library
pod lib create LibraryName
# Verify podspec
pod lib lint
# Push the podspec
pod trunk push LibraryName.podspec

Yeah! You are done with your first Pod Framework. It’s time to have some nice coffee. 

Still facing any issue with Pod? Or want to be in touch with us? Contact us:

Email:  muzammil@triffort.com Skype: muz.iphonedev

Triffort_logo

Triffort Technologies Pvt Ltd
www.triffort.com

First iPad App

10 Easy Steps to create your first iPad App:

In this tutorial I will give you a brief introduction on how to get started with your first iPad application. To begin you will need the latest version of the iPhone SDK which you can download it from Apple Site. With the SDK you get some tools like Xcode, Interface Builder, new iPad simulator, and many more.

Lets start with the Most Useless App “Hello World” 🙂

In this tutorial i will show you how to make a simple image view in iPad. After completing this tutorial your App should look like this:

Creating a new project
Launch Xcode and click on File -> New Project -> Select Application (under iPhone OS) -> select Split View Based Application. and then give the name iPadHelloWorld (or anything else) ->save it.

Here is something change. This is not look like iPhone. Here you see three classes- delegate, MasterViewController and DetailViewController. MasterViewController is for Left Side portion of iPad (show table etc) and DetailViewController is Right side portion of iPad which show your Actual data.

Now follow the Screen Shot and do the same:

1. In your MasterViewController take NSMutableArray and give the name Images.

2. In ViewDidLoad alloc the array with image name.

3. In number of Row of Table return [images count].

4. Set Cell text label.

5. Here you select the row for the Detailview.

6. Now in Detail View take one UIImageView name it myImageView then synthesize it.

7. In DetailItem open the image in the ImageView.

8. Add image files in your Resource folder.

9. Open DetailView Xib and take one ImageView in this and connect this with myImageView.

10. Build and Go.

Your App look Like this:

Please give you comments and If you have any questions mail me…

Thanx

iPad -An Introduction

The new Apple iPad is a revolutionary device for browsing the web, reading and sending email, enjoying photos, watching videos, listening to music, playing games, reading e-books and much more. iPad’s responsive high-resolution Multi-Touch™ display lets users physically interact with applications and content. iPad is just 0.5 inches thick and weighs just 1.5 pounds— thinner and lighter than any laptop or netbook. iPad includes 12 new innovative apps designed especially for the iPad, and will run almost all of the over 140,000 apps in the App Store. iPad will be available in late March starting at a price of $499.

“iPad is our most advanced technology in a magical and revolutionary device at an unbelievable price,” said Steve Jobs, Apple’s CEO. “iPad creates and defines an entirely new category of devices that will connect users with their apps and content in a much more intimate, intuitive and fun way than ever before.”

iPad features 12 next-generation Multi-Touch applications. Every app works in both portrait and landscape, automatically animating between views as the user rotates iPad in any direction. The precise Multi-Touch interface makes surfing the web on iPad an entirely new experience, dramatically more interactive and intimate than on a computer.

Reading and sending email is fun and easy on iPad’s large screen and almost full-size “soft” keyboard. Import photos from a Mac®, PC or digital camera, see them organized as albums, and enjoy and share them using iPad’s elegant slideshows. Watch movies, TV shows and YouTube, all in HD or flip through pages of an e-book you downloaded from Apple’s new iBookstore while listening to your music collection.

iPad’s 9.7-inch, LED-backlit display features IPS technology to deliver crisp, clear images and consistent color with an ultra-wide 178 degree viewing angle. The highly precise, capacitive Multi-Touch display is amazingly accurate and responsive whether scrolling web pages or playing games. The intelligent soft keyboard pioneered on iPhone takes advantage of iPad’s larger display to offer an almost full-size soft keyboard. iPad also connects to the new iPad Keyboard Dock with a full-size traditional keyboard.

Apple released a new Software Development Kit (SDK) for iPad, so developers can create amazing new applications designed to take advantage of iPad’s capabilities. The SDK includes a simulator that lets developers test and debug their iPad apps on a Mac, and also lets developers create Universal Applications that run on iPad, iPhone and iPod touch.

Let’s move for something Bigger 🙂