Cell App Improvement is the method of constructing an utility for cellular gadgets, reminiscent of smartphones and tablets. Usually, cellular apps are tougher to develop than net apps, as a result of they have to be designed from scratch for every platform, whereas net growth shares frequent codes throughout completely different gadgets.
Every working system has its personal language used for coding a native app (one created with expertise devoted to a particular 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 methods.
Cell App Improvement is extremely related for AI because it permits the combination of recent applied sciences into folks day by day life. LLMs are so fashionable now as a result of they’ve been deployed into user-friendly apps in your cellphone, simply accessible anytime and anyplace.
By this tutorial, I’ll clarify methods to construct a cross-platform cellular app with Python, utilizing my Memorizer App for instance (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 neighborhood. 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 (just 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 information:
- most important.py (the title have to be this) which shall comprise the Python code of the app, mainly the back-end
- elements.kv (you may name it in a different way) which shall comprise all of the Kivy code used for the app format, you may see it because the front-end
Then, within the most important.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 = "Gentle"
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 reality, I’m utilizing it to memorize Chinese language vocabulary.

As you may see from the picture, I’m going to incorporate:
- an intro display screen to show the brand
- a house display screen that may redirect to the opposite screens
- a display screen to save lots of 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:

With a purpose to embody Kivy file within the app, we have to load it from the most important.py with the builder class, whereas the display screen class hyperlinks the screens between the 2 information.
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 = "Gentle"
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 be aware that even when the app itself is primary, there’s a fairly difficult function: db administration through 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 incorporates an picture brand, some textual content labels, and a button to maneuver to a different display screen.

I contemplate that simple 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 have to 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’ll have seen that on prime of the display screen there’s a “house” icon. Please be aware 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 will probably be an icon button used to carry you again to the Dwelling Display from some other display screen of the app.

After we use an icon, now we have to supply the tag (i.e. “house” shows slightly home). I discover this code very helpful, simply run it and it’ll present all of the obtainable icons.
Improvement — superior
Let’s step up our sport and cope with the DB by way of the Save Display. It should enable the consumer to save lots of completely different phrases for various classes (i.e. to review a number of languages). That means:
- selecting an current 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 save lots of the shape, so writing a brand new row within the DB.

While you run the app for the primary time, the DB have to be created. We are able to do this in the principle operate of the app. For comfort, I’m going so as to add additionally one other operate that queries the DB with any SQL you cross on.
class App(MDApp):
def query_db(self, q, information=False):
conn = sqlite3.join("db.db")
db = conn.cursor()
db.execute(q)
if information is True:
lst_tuples_rows = db.fetchall()
conn.commit()
conn.shut()
return lst_tuples_rows if information is True else None
def construct(self):
self.theme_cls.theme_style = "Gentle"
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 difficult half is the DB icon that, when pushed, exhibits all the prevailing classes and permits the number of one. Within the elements.kv file, beneath the Save Display (named “save”), we add an icon button (named “category_dropdown_save”) that, if pressed, launches the Python dropdown_save() operate from the principle app.

That operate is outlined within the most important.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 are able to specify the properties of the display screen when one enters and when one leaves. So I’m going so as to add a operate 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 save lots of the shape (by pushing the button).

With a purpose to ensure that the operate 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 thus far, I’m assured that you just’re in a position to undergo the total code and perceive what’s occurring. The logic of the opposite screens is fairly related.
Check
You’ll be able to check the app on the iOS simulator on MacBook, that replicates an iPhone atmosphere without having a bodily iOS machine.
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 resolve your app title and use it to create the repository, then open the .xcodeproj file:
toolchain create yourappname ~/some/path/listing
open yourappname-ios/yourappname.xcodeproj

Lastly, if you’re working with iOS and also you need to check an app in your cellphone 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 methods to design and construct a cross-platform cellular app with Python. I used Kivy to design the consumer interface and I confirmed methods to make it obtainable for iOS gadgets. Now you can also make your individual cellular apps with Python and Kivy.
Full code for this text: GitHub
I hope you loved it! Be at liberty to contact me for questions and suggestions or simply to share your fascinating initiatives.
👉 Let’s Join 👈

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