Cellular App Improvement is the method of constructing an utility for cellular gadgets, corresponding to smartphones and tablets. Typically, cellular apps are tougher to develop than net apps, as a result of they should be designed from scratch for every platform, whereas net growth shares frequent codes throughout totally different gadgets.
Every working system has its personal language used for coding a native app (one created with know-how devoted to a selected platform). For example, Android makes use of Java, whereas iOS makes use of Swift. Often, it’s higher to make use of the devoted tech for apps that require excessive efficiency, like gaming or heavy animations. Quite the opposite, hybrid apps use cross-platform languages (i.e. Python) that may be run on a number of working techniques.
Cellular App Improvement is extremely related for AI because it allows the combination of recent applied sciences into individuals day by day life. LLMs are so well-liked now as a result of they’ve been deployed into user-friendly apps in your telephone, simply accessible anytime and anyplace.
By this tutorial, I’ll clarify learn how to construct a cross-platform cellular app with Python, utilizing my Memorizer App for example (hyperlink to full code on the finish of the article).
Setup
I’m going to make use of the Kivy framework, which is essentially the most used for cellular growth within the Python group. Kivy is an open-source bundle for cellular apps, whereas KivyMD is the library that leverages Google’s Materials Design and makes the utilization of this framework a lot simpler (much like Bootstrap for net dev).
## for growth
pip set up kivy==2.0.0
pip set up kivymd==0.104.2
## for deployment
pip set up Cython==0.29.27
pip set up kivy-ios==1.2.1
The very first thing to do is to create 2 recordsdata:
- foremost.py (the identify should be this) which shall comprise the Python code of the app, principally the back-end
- elements.kv (you possibly can name it otherwise) which shall comprise all of the Kivy code used for the app format, you possibly can see it because the front-end
Then, within the foremost.py file we import the bundle to initialize an empty app:
from kivymd.app import MDApp
class App(MDApp):
def construct(self):
self.theme_cls.theme_style = "Mild"
return 0
if __name__ == "__main__":
App().run()
Earlier than we begin, I shall briefly describe the appliance I’m constructing. It’s a easy app that helps to memorize stuff: the consumer inserts pair of phrases (i.e. one thing in English and the equal in one other language, or a date and the historic occasion linked to that). Then, the consumer can play the sport by attempting to recollect shuffled info. As a matter of truth, I’m utilizing it to memorize Chinese language vocabulary.
As you possibly can see from the picture, I’m going to incorporate:
- an intro display screen to show the emblem
- a house display screen that may redirect to the opposite screens
- a display screen to avoid wasting phrases
- a display screen to view and delete saved info
- a display screen to play the sport.
So, we are able to write all of them down within the elements.kv file:

As a way to embrace Kivy file within the app, we have to load it from the foremost.py with the builder class, whereas the display screen class hyperlinks the screens between the 2 recordsdata.
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.screenmanager import Display
class App(MDApp):
def construct(self):
self.theme_cls.theme_style = "Mild"
return Builder.load_file("elements.kv")
class IntroScreen(Display):
cross
class HomeScreen(Display):
cross
class PlayScreen(Display):
cross
class SaveScreen(Display):
cross
class EditScreen(Display):
cross
if __name__ == "__main__":
App().run()
Please word that even when the app itself is fundamental, there’s a fairly tough characteristic: db administration by way of cellular. That’s why we’re going to use additionally the native Python bundle for databases:
import sqlite3
Improvement — fundamentals
We’re gonna heat up with the Intro Display: it merely accommodates an picture brand, some textual content labels, and a button to maneuver to a different display screen.

I think about that straightforward as a result of it doesn’t require any Python code, it may be dealt with by the elements.kv file. The change of display screen triggered by the button should be linked to the basis like this:

The identical goes for the Dwelling Display: because it’s only a redirect, it may be all managed with Kivy code. You simply need to specify that the display screen should have 1 icon and three buttons.

You might have observed that on prime of the display screen there’s a “house” icon. Please word that there’s a distinction between a easy icon and an icon button: the latter is pushable. On this display screen it’s only a easy icon, however on the opposite screens it is going to be an icon button used to deliver you again to the Dwelling Display from another display screen of the app.

After we use an icon, we’ve to offer the tag (i.e. “house” shows a little bit home). I discover this code very helpful, simply run it and it’ll present all of the out there icons.
Improvement — superior
Let’s step up our recreation and cope with the DB via the Save Display. It should permit the consumer to avoid wasting totally different phrases for various classes (i.e. to review a number of languages). That means:
- selecting an present class (i.e. Chinese language), so querying the prevailing ones
- creating a brand new class (i.e. French)
- two textual content inputs (i.e. a phrase and its translation)
- a button to avoid wasting the shape, so writing a brand new row within the DB.

Once you run the app for the primary time, the DB should be created. We will do this in the primary perform of the app. For comfort, I’m going so as to add additionally one other perform that queries the DB with any SQL you cross on.
class App(MDApp):
def query_db(self, q, knowledge=False):
conn = sqlite3.join("db.db")
db = conn.cursor()
db.execute(q)
if knowledge is True:
lst_tuples_rows = db.fetchall()
conn.commit()
conn.shut()
return lst_tuples_rows if knowledge is True else None
def construct(self):
self.theme_cls.theme_style = "Mild"
q = "CREATE TABLE if not exists SAVED (class textual content, left
textual content, proper textual content, distinctive (class,left,proper))"
self.query_db(q)
return Builder.load_file("elements.kv")
The tough half is the DB icon that, when pushed, exhibits all the prevailing classes and permits the number of one. Within the elements.kv file, below the Save Display (named “save”), we add an icon button (named “category_dropdown_save”) that, if pressed, launches the Python dropdown_save() perform from the primary app.

That perform is outlined within the foremost.py file and returns a dropdown menu such that, when an merchandise is pressed it will get assigned to a variable named “class”.

That final line of code hyperlinks the class variable with the label that seems within the front-end. The display screen supervisor calls the display screen with get_screen() and identifies the merchandise by id:

When the consumer enters the Save Display, the class variable needs to be null till one is chosen. We will specify the properties of the display screen when one enters and when one leaves. So I’m going so as to add a perform within the display screen class that empties the App variable.
class SaveScreen(Display):
def on_enter(self):
App.class = ''
As soon as the class is chosen, the consumer can insert the opposite textual content inputs, that are required to avoid wasting the shape (by pushing the button).

As a way to be sure that the perform doesn’t save if one of many inputs is empty, I’ll use a dialog field.
from kivymd.uix.dialog import MDDialog
class App(MDApp):
dialog = None
def alert_dialog(self, txt):
if not self.dialog:
self.dialog = MDDialog(textual content=txt)
self.dialog.open()
self.dialog = None
def save(self):
self.class = self.root.get_screen('save').ids.class.textual content
if self.class == '' else self.class
left = self.root.get_screen('save').ids.left_input.textual content
proper = self.root.get_screen('save').ids.right_input.textual content
if "" in [self.category.strip(), left.strip(), right.strip()]:
self.alert_dialog("Fields are required")
else:
q = f"INSERT INTO SAVED VALUES('{self.class}',
'{left}','{proper}')"
self.query_db(q)
self.alert_dialog("Saved")
self.root.get_screen('save').ids.left_input.textual content = ''
self.root.get_screen('save').ids.right_input.textual content = ''
self.class = ''
After studying to this point, I’m assured that you simply’re in a position to undergo the complete code and perceive what’s happening. The logic of the opposite screens is fairly related.
Check
You possibly can check the app on the iOS simulator on MacBook, that replicates an iPhone setting without having a bodily iOS system.
Xcode must be put in. Begin by opening the terminal and operating the next instructions (the final one will take about half-hour):
brew set up autoconf automake libtool pkg-config
brew hyperlink libtool
toolchain construct kivy
Now determine your app identify and use it to create the repository, then open the .xcodeproj file:
toolchain create yourappname ~/some/path/listing
open yourappname-ios/yourappname.xcodeproj

Lastly, in case you are working with iOS and also you need to check an app in your telephone after which publish it on the App Retailer, Apple requires you to pay for a developer account.
Conclusion
This text has been a tutorial to reveal learn how to design and construct a cross-platform cellular app with Python. I used Kivy to design the consumer interface and I confirmed learn how to make it out there for iOS gadgets. Now you can also make your personal cellular apps with Python and Kivy.
Full code for this text: GitHub
I hope you loved it! Be happy to contact me for questions and suggestions or simply to share your fascinating tasks.
👉 Let’s Join 👈

(All photos, until in any other case famous, are by the creator)