With the current trends in the software development field, agility and faster delivery of software applications have become an essential part of the IT industry. In fact, this has been one of the main reasons for the evolution of many of the modern technologies and trends, such as single-page applications, lightweight frameworks, and microservices architecture.
Even with the massive improvements in the technologies, IDEs, and tools, developers still write much code to get the job done. To increase software developers’ productivity and to reduce the cost of software development, the Clowiz platform has been created.
Clowiz is a cloud-based platform that enables developers to generate software artifacts (using CodeGen), end-to-end features (using FeatureGen), and full end-to-end apps (using AppGen) without writing a single line of code.
In this article, we are going to:
- Create and set up the following projects:
- iOS Swift App
- Spring Boot Rest API
- Generate app artifacts using Clowiz:
- Generate and use the following artifacts in the iOS App:
- List ViewController
- Add/Edit ViewController
- List View
- Add/Edit View
- Alamofire Sevice
- Generate and use the following artifacts in the Spring Boot App:
- JPA Repository
- Rest API Controller
- Generate and use the following artifacts in the iOS App:
- Run and test the project
Create iOS Swift App
- Create a new iOS Storyboard project with a Single View App.
- Add Alamofire POD to the project. (How to add Alamofire to xCode, Alamofire latest version)
- Delete the “Main.storyboard” file and its references from the “Info.plist” file. (Create project without storyboard)
- Rename the file “ViewController.swift” to “TabBarVC.swift”.
- Change the class name to TabBarVC.
- Change the rootViewCntroller to a to our TabBarVC by replacing the scene function in the SceneDelegate.swift file with the following:
- Create a new subclass of UIViewController and call it “HomeVC.swift” with the following content:
- Add UINavigationController to your tabs in the TabBarVC class.
Running the app displays the TabBar and an empty Home navigation page, now we can extend the app and add more functionalities to it.
Generate iOS Artifacts
- Go to Clowiz, then navigate to CodeGen https://www.clowiz.com/
- From the technologies, choose iOS.
- In the metadata section, name your artifacts, e.g., Employee.
- For the first field, in the field name, type Name and keep is as Text.
- Create two more fields, e.g., Email and Salary, with data types of email and double.
- Check all fields as required.
CodeGen has generated the following artifacts for the project:
Cell View: represents the data in each table row:
Add Edit View: holds the input fields(name, email, salary input fields) and their labels.
Add Edit VC: used to add and edit data.
List VC: used to list and delete data.
Service: service layer that uses Alamofire to handle the API requests.
Now let’s add the generated code to the project, you can press on Download Generated Code under the generated code section in CodeGen, then add the downloaded files to the project app folder, or you can copy-paste the generated code to the project. (Please note the file name should match the class name with .swift extension)
Add the EmployeeListViewController to a navigation bar in the TabBar class.
To keep the project simple and easy to maintain, divide it into groups (AddView, AddViewController, CellView, ListViewController, Model, Service).
To run the app, use one of the simulators provided, and press run.
Running the application displays the two tab items Home and Employee. The Employee tab contains a table to list all the employees, search bar, and a button to add a new employee.
As soon as you access the Employee tab, you get a Network error because we still don’t have an API to handle the requests.
Create Spring Boot Rest API
Spring Boot reduces lots of development time and increases productivity. It avoids writing lots of boilerplate Codes, Annotations, and XML Configuration, however, just to get started, a lot of code is needed, but don’t worry, Clowiz supports Spring Boot, and can generate the code for our API in a minute.
Create a new Spring Boot project using Spring Initializr:
- Leave the default settings as Maven Project, Java, and the version.
- In the Group field type: com.app
- In the Artifact field type: iosBackend
- From the Options, change the package name to com.app
- Search and add the following dependencies:
- Spring web
- Spring Data JPA
- MySQL Driver
- Press on Generate to download the project.
Using any eclipse based IDE:
- Import the downloaded project. (File -> Import -> Existing Maven Project)
- Add the following to the “application.properties” file in the “src/main/resources package”.
We don’t have to create a database manually; Spring JPA does that automatically, note the parameter
createDatabaseIfNotExist = true in the database URL.
Generate Spring Boot Artifacts
Back to Clowiz, press on the Spring Boot icon in the technologies section to generate the needed source code for the API.
For this tutorial, use the following generated artifacts:
Hibernate JPA Entity (The model).
Mature Spring RestController.
As we did in the iOS project, copy-paste the generated code to the right packages with the correct classes names, or you can download it by pressing Download Generated Code.
To keep the project simple and easy to maintain, divide it into packages (controllers, models, repositories).
Check that the URL in the iOS Service class matches with the Spring Boot properties file server IP.
To run the project, open the IosBackendApplication.java class, right-click and Run As Java Application.
Running the App
After running the Spring Boot API, rerun the iOS project.
- Go to the Employee tab
- Press on the Add button
- Fill in Employee data
- Press on save
- Tap on a row to edit it
- Swipe a row to delete it