kivy-project
First create uv project which psproject will use the pyproject.toml as project info
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]
update app.py code with the following
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:
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
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.