Make Custom iOS Framework[EASY] in iOS 14 & Swift 5

Samyak Pawar
3 min readNov 21, 2020

Making your own iOS framework is super cool! It not only helps in getting recognition in the iOS community but also increases your chances to get hired by adding it in your resume.

What is an iOS Framework?

Just like we create functions in our apps so we can reuse the code multiple times in our app, a custom iOS Framework helps us to reuse the code across multiple apps.

Let’s create our first custom iOS framework called “iPhone” which will simply help in rounding corners of any UIView just like the screen corners of an iPhone screen.

Step 1: Create a new Xcode project.

Make sure you choose “Framework” and click next. Then, give your Framework a name( I’m naming it “iPhone”) and click create.

Step 2 : Create a new Swift file or add an existing file.

Step 3: Explicitly declare all your variables, classes and structures in the files you create or add as public.

Here, I just created a structure with a function that takes any UIView and corner radius as input and gives the view rounding corners of the specified radius.

Step 4: Add the “iPhone.framework” file in any other iOS app you wish to use this framework.

Just like how we had the option to “Add files to “iphone”…” in step 2, repeat the same process in the app Xcode file where we want to add the framework. Then locate and choose the “iPhone.framework” and keep the configuration just as shown above and click on Add.

Step 5: Choose “Embed without Signing” in the Frameworks, Libraries and Embedded content.

Step 6: To use the Framework in any file in the iOS app, just import the framework first.

Here, I’ve created a UIView and a UIButton and after importing “iPhone”, I’m using the framework function to get those rounded corners to both of my views inside my viewDidLoad.

Step 7: Run the project and see the magic of your framework in action!

Now, you’re all set to brag about making your own framework to all your friends!

If you find this article useful or you’re facing any issues or queries, feel free to reach me on my LinkedIn or E-mail.

My E-mail: samyak.professional@gmail.com

--

--