Photo by Sonja Langford on Unsplash

Architecture Module Generator for iOS

Tick-tock, tick-tock.. You have sitted your desk on Saturday to code your weekend project. There are limited time to work to save work-life balance. Lines of codes are getting increased. And time flies, too. Tick-tock, tick-tock...

We don’t stop the time but can do something. Use the time well!

If you are iOS Developer I assume you have worked on several project and several architectural pattern to handle clean code. Default architecture of Xcode is MVC which stands for Model View Controller. But we know that it’s a limited architecture and doesn’t provides a clean code if your app is so complex. Therefore we use several solution like MVVM, VIPER, MVP etc. If we want to use this architectures in our apps, we must do some configuration for each scene of iOS application. This configurations are getting crowded while your app’s complexity is getting bigger. So it produces boilerplate configuration codes for us.

Think about that VIPER has more distributed layers then MVVM. So If you want to create a new scene for your app, you should create View layer with both controller and xib file, Interactor layer, Presenter layer, Router layer and module configuration file. So it’s a pain to do the same think again and again for each page.

FKArchitectureGeneratorCLI

I have create a command line interface to solve the boilerplate problem.

Apple doesn’t allow us to make a plugin since Xcode 8. It only allows plugins developed for Xcode editor and it’s not what I need. You can look at that issue.

You can view the source code of the project from GitHub. It’s so simple to use the cli.

Setup

  1. Open ‘Go to Folder’ menu.

2. Type /usr/local/bin path. If there aren’t bin folder in the local directory just create it.

3. Click here and download the cli which is called fk.

4. Open downloads directory and a terminal window. You can see fk file is type of TextEdit Document. We should convert it to executable file.

5. Just type the command “chmod +x fk” and press enter. You can realize that fk file converted to executable file.

6. Finally just drag the fk file from the Download directory to /usr/local/bin path. Enter your mac’s account password and confirm. It’s ready to go.

How to use?

Open terminal and type “fk viper Medium” command.

For the first run, it prompts an window ask a permission to run cli. It’s because this app is not downloaded from the App Store. Just open the Security & Privacy from System Preferences, and press to Allow Anyway button.

After typing “fk viper Medium” command again, a popup appears. Just press Open

And you can use the cli whenever you want to create a new module in your iOS app.

Conclusion

Cli is only supporting VIPER and MVVM architecture modules. you can download the MVVM module typing “fk mvvm ModuleName”.

Each Swift file has mark indicating fk-architecture-generator-cli-macos. If you don’t want the mark in Swift files, just create module with the following command “fk viper ModuleName -u” or “fk viper ModuleName --unmarked”

Just type fk --help to view how to use the command line interface.

return 👨‍💻

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store