Develop your own Swift Framework


Developing your own swift framework has below benefits.

  1. Reusable code
  2. Secure or Hide your code
  3. Reduce recompilation
  4. Reduce recompilation
  5. Save time

Tool Used: Xcode 8.3.2, Swift 3+

To create your own framework in swift you just have to follow below 5 steps.

Step 1: Setup Framework Project

Create new Xcode project.

Click on ‘Cocoa Touch Framework’.

Write a name of your project, we have used ‘YudizFramework’. (Make sure to choose swift language) and Click on Next button.

Add new file inside ‘YudizFramework’ folder. (Press ⌘ + N or Click on File -> New -> File…)

Click on ‘Cocoa Touch Class’.

Write File Name ‘YudizFramework’ and Subclass of ‘NSObject’.

Step 2: Write some code

Write following code inside ‘YudizFramework.swift’

Note:- Make sure your class and method are open.

Step 3: To create Universal Framework

Add new ‘Aggregate’ target to your project.

And Add below script in ‘Run Script’ to it.


Please add below in your project’s Run Script (Project Target -> Build Phase -> Add Run Script)

Without above script you will face issue when uploading app to App Store as what we just made is Universal framework and Apple does not allow extra architectures.

Step 4: Build your Framework

Build your Framework by choosing ‘UniversalYudizFramework’ target pressing ⌘ + B.

After build is completed, Finder opens with your Framework in that.

Step 5: Add this framework to your any of your project

Note:- If you are getting following error,

… Reason: image not found

Make sure your framework is added in both ‘Embedded Binaries’ and ‘Linked Framework and Libraries’.


Sandeep Joshi iOS Team Lead

I’m Sandeep Joshi - an iOS developer at Yudiz Solutions Pvt. Ltd. - a leading iPhone App Development company. I am ambitious and intensely interested in what I do. You'll quickly find that I do not merely develop software - I develop highly maintainable, elegant code that will save you enormous sums in the long run.

Comments are closed.