kivy-project

First create uv project which psproject will use the pyproject.toml as project info

psproject init HelloWorld

cd into the new project - if terminal app only usage

cd HelloWorld

vscode users can instead open the folder by

code HelloWorld

You should now have a HelloWorld/pyproject.toml looking like this:

[project]
name = "helloworld"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
authors = [
    { name = "Py-Swift", email = "xyz@mail.com" }
]
requires-python = ">=3.13"
dependencies = []

[project.scripts]
helloworld = "helloworld:main"

[build-system]
requires = ["uv_build>=0.9.2,<0.10.0"]
build-backend = "uv_build"

[dependency-groups]
iphoneos = []

[tool.psproject]
app_name = "HelloWorld"
backends = []
cythonized = false
extra_index = []
pip_install_app = false

[tool.psproject.ios]
backends = []
extra_index = [
    "https://pypi.anaconda.org/beeware/simple",
    "https://pypi.anaconda.org/pyswift/simple",
    "https://pypi.anaconda.org/kivyschool/simple"
]

[tool.psproject.ios.info_plist]

[tool.psproject.ios.swift_packages]

[tool.psproject.macos]
backends = []
extra_index = []

[tool.psproject.macos.info_plist]

[tool.psproject.macos.swift_packages]

[tool.psproject.swift_packages]

Now change the following properties to run a kivy based app:

[project]
name = "helloworld"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
authors = [
    { name = "Py-Swift", email = "xyz@mail.com" }
]
requires-python = ">=3.13"
dependencies = [
    "kivy>=2.3.1",
]

[project.scripts]
helloworld = "helloworld:main"

[build-system]
requires = ["uv_build>=0.9.2,<0.10.0"]
build-backend = "uv_build"

[dependency-groups]
iphoneos = []

[tool.psproject]
app_name = "HelloWorld"
backends = [
    "kivyschool.kivylauncher"
]
cythonized = false
extra_index = []
pip_install_app = false

[tool.psproject.ios]
backends = []
extra_index = [
    "https://pypi.anaconda.org/beeware/simple",
    "https://pypi.anaconda.org/pyswift/simple",
    "https://pypi.anaconda.org/kivyschool/simple"
]

[tool.psproject.ios.info_plist]

[tool.psproject.ios.swift_packages]

[tool.psproject.macos]
backends = []
extra_index = []

[tool.psproject.macos.info_plist]

[tool.psproject.macos.swift_packages]

[tool.psproject.swift_packages]

Add Kivy as dependency

uv add kivy
uv sync

update app.py code with the following

from kivy.app import App
from kivy.lang import Builder

kv = """
Button:
    text: "Hello World"
"""


class MainApp(App):
    def build(self):
        return Builder.load_string(kv)

def main():
    app = MainApp()
    app.run()

To create the xcode project, type the following command

psproject create xcode

Copy your main Python file to the Xcode project

After creating the Xcode project, you need to copy your __main__.py (main entry point) to the app directory:

cp src/helloworld/__main__.py project_dist/xcode/app/

Replace helloworld with your actual app name. This file will be bundled with your iOS app and serves as the entry point for your Python application.

To update the xcode project's site-packages, type the following command

psproject update site-packages

Customize mobile vs desktop settings

The project_dist/xcode/app/__main__.py can be different from src/helloworld/__main__.py! This allows you to run your app with different parameters or configurations for mobile vs desktop:

Desktop version (src/helloworld/__main__.py):

from kivy.config import Config
from helloworld import main  # Replace 'helloworld' with your app module name from src/

# Set window size for desktop
Config.set('graphics', 'width', '1280')
Config.set('graphics', 'height', '720')

if __name__ == "__main__":
    main()

Mobile version (project_dist/xcode/app/__main__.py):

from helloworld import main  # Replace 'helloworld' with your app module name from src/

if __name__ == "__main__":
    main()

This separation lets you optimize settings, features, and UI layouts specifically for each platform without cluttering your code with conditional checks.