2015-11-03 16:02:42 +01:00
|
|
|
Kivy for iOS
|
2011-12-06 18:18:42 +01:00
|
|
|
============
|
|
|
|
|
2015-08-13 05:11:32 +02:00
|
|
|
This toolchain is designed to compile the necessary libraries for iOS to run
|
|
|
|
your application and manage the creation of the Xcode project.
|
2011-12-06 18:18:42 +01:00
|
|
|
|
2018-10-28 16:24:11 +01:00
|
|
|
We do not provide any binary distributions of this toolchain.
|
|
|
|
You do need to compile it at least once before creating your Xcode project.
|
2015-02-20 11:34:06 +01:00
|
|
|
|
|
|
|
The toolchain supports:
|
|
|
|
|
2018-10-28 16:24:11 +01:00
|
|
|
- iPhone Simulator (x86_64)
|
2015-02-20 11:34:06 +01:00
|
|
|
- iPhone / iOS (armv7 and arm64)
|
|
|
|
|
2015-08-13 05:11:32 +02:00
|
|
|
These recipes are not ported to the new toolchain yet:
|
2015-02-24 12:03:54 +01:00
|
|
|
|
2015-02-25 19:48:58 +01:00
|
|
|
- lxml
|
2015-02-24 12:03:54 +01:00
|
|
|
|
2015-02-20 11:34:06 +01:00
|
|
|
|
|
|
|
Requirements
|
|
|
|
------------
|
|
|
|
|
2015-08-13 05:11:32 +02:00
|
|
|
Currently, the toolchain requires a few tools for compilation. You will need:
|
2015-02-20 11:34:06 +01:00
|
|
|
|
2018-11-01 01:51:56 +01:00
|
|
|
#. Ensure you have python3 installed - this is needed for toolchain.py::
|
2018-10-28 16:24:11 +01:00
|
|
|
|
2018-11-01 01:51:56 +01:00
|
|
|
brew install python
|
|
|
|
|
|
|
|
#. Ensure you have the right dependencies installed for python3::
|
|
|
|
|
|
|
|
pip3 install -r requirements.txt
|
2018-10-28 16:24:11 +01:00
|
|
|
|
|
|
|
#. Xcode 10 or above, with an iOS SDK and command line tools installed::
|
2015-03-05 17:29:44 +01:00
|
|
|
|
|
|
|
xcode-select --install
|
|
|
|
|
2015-08-13 05:11:32 +02:00
|
|
|
#. Using brew, you can install the following dependencies::
|
2012-07-07 22:19:36 +02:00
|
|
|
|
2015-02-20 11:34:06 +01:00
|
|
|
brew install autoconf automake libtool pkg-config
|
2012-07-07 22:19:36 +02:00
|
|
|
brew link libtool
|
2012-07-18 19:52:11 +02:00
|
|
|
|
2018-11-01 01:51:56 +01:00
|
|
|
#. Install Cython (0.26.1)::
|
2012-12-14 00:54:05 +01:00
|
|
|
|
|
|
|
# pip method if available (sudo might be needed.)
|
2018-11-01 01:51:56 +01:00
|
|
|
pip install cython==0.26.1
|
2015-02-20 11:34:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
Using the toolchain
|
|
|
|
-------------------
|
|
|
|
|
|
|
|
Any Python extensions or C/C++ library must be compiled: you need to have what
|
|
|
|
we call a `recipe` to compile it. For example, Python, libffi, SDL2, SDL_image,
|
|
|
|
freetype... all the dependencies, compilation and packaging instructions are
|
|
|
|
contained in a `recipe`.
|
|
|
|
|
2015-08-13 05:11:32 +02:00
|
|
|
You can list the available recipes and their versions with::
|
2015-02-20 11:34:06 +01:00
|
|
|
|
|
|
|
$ ./toolchain.py recipes
|
|
|
|
freetype 2.5.5
|
|
|
|
hostpython 2.7.1
|
|
|
|
ios master
|
|
|
|
kivy ios-poly-arch
|
|
|
|
libffi 3.2.1
|
2016-01-14 11:47:09 +01:00
|
|
|
openssl 1.0.2e
|
2015-02-20 11:34:06 +01:00
|
|
|
pyobjus master
|
|
|
|
python 2.7.1
|
|
|
|
sdl2 iOS-improvements
|
|
|
|
sdl2_image 2.0.0
|
|
|
|
sdl2_mixer 2.0.0
|
|
|
|
sdl2_ttf 2.0.12
|
|
|
|
|
2015-08-13 05:11:32 +02:00
|
|
|
Then, start the compilation with::
|
2015-02-20 11:34:06 +01:00
|
|
|
|
|
|
|
$ ./toolchain.py build kivy
|
|
|
|
|
2016-01-14 11:51:07 +01:00
|
|
|
You can build recipes at the same time by adding them as parameters::
|
|
|
|
|
|
|
|
$ ./toolchain.py build openssl kivy
|
|
|
|
|
2016-07-28 09:46:11 +02:00
|
|
|
Recipe builds can be removed via the clean command e.g.::
|
|
|
|
|
|
|
|
$ ./toolchain.py clean openssl
|
|
|
|
|
2015-08-13 05:11:32 +02:00
|
|
|
The Kivy recipe depends on several others, like the sdl* and python recipes.
|
|
|
|
These may in turn depend on others e.g. sdl2_ttf depends on freetype, etc.
|
|
|
|
You can think of it as follows: the kivy recipe will compile everything
|
2015-02-20 11:34:06 +01:00
|
|
|
necessary for a minimal working version of Kivy.
|
|
|
|
|
2015-08-13 05:11:32 +02:00
|
|
|
Don't grab a coffee, just do diner. Compiling all the libraries for the first
|
2016-12-14 12:57:06 +01:00
|
|
|
time, 4x over (remember, 4 archs, 2 per platforms by default) will take time.
|
2015-02-20 11:34:06 +01:00
|
|
|
|
2016-04-20 13:02:51 +02:00
|
|
|
For a complete list of available commands, type::
|
|
|
|
|
|
|
|
$ ./toolchain.py
|
|
|
|
|
2015-02-20 11:34:06 +01:00
|
|
|
Create the Xcode project
|
|
|
|
------------------------
|
|
|
|
|
2015-08-13 05:11:32 +02:00
|
|
|
The `toolchain.py` can create the initial Xcode project for you::
|
2015-02-20 11:34:06 +01:00
|
|
|
|
2016-04-14 01:23:49 +02:00
|
|
|
$ ./toolchain.py create <title> <app_directory>
|
2015-02-20 11:34:06 +01:00
|
|
|
$ ./toolchain.py create Touchtracer ~/code/kivy/examples/demo/touchtracer
|
|
|
|
|
|
|
|
Your app directory must contain a main.py. A directory named `<title>-ios`
|
|
|
|
will be created, with an Xcode project in it.
|
2015-08-13 05:11:32 +02:00
|
|
|
You can open the Xcode project using::
|
2015-02-20 11:34:06 +01:00
|
|
|
|
|
|
|
$ open touchtracer-ios/touchtracer.xcodeproj
|
|
|
|
|
|
|
|
Then click on `Play`, and enjoy.
|
|
|
|
|
2016-06-28 12:31:35 +02:00
|
|
|
.. note::
|
2015-02-20 11:34:06 +01:00
|
|
|
|
|
|
|
Everytime you press `Play`, your application directory will be synced to
|
|
|
|
the `<title>-ios/YourApp` directory. Don't make changes in the -ios
|
|
|
|
directory directly.
|
|
|
|
|
2016-06-28 12:31:35 +02:00
|
|
|
Configuring your App
|
|
|
|
--------------------
|
|
|
|
|
2016-11-23 13:18:41 +01:00
|
|
|
You can configure and customize your app in various ways:
|
|
|
|
|
|
|
|
#. Set the icon and launch images in XCode. Note that XCode requires that you
|
|
|
|
specify these assests per device or/and iOS version.
|
|
|
|
|
|
|
|
#. When you first build your XCode project, a 'main.m' file is created in your
|
|
|
|
XCode project folder. This file configures your environment variables and
|
|
|
|
controls your application startup. You can edit this file to customize your
|
|
|
|
launch environment.
|
|
|
|
|
|
|
|
#. Kivy uses SDL, and as soon as the application starts the SDL main, the launch
|
|
|
|
image will disappear. To prevent that, you need to have 2 files named
|
|
|
|
`Default.png` and `Default-Landscape.png`, and put them
|
|
|
|
in the `Resources` folder in Xcode (not in your application folder)
|
2016-06-28 12:31:35 +02:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
If you wish to restrict your apps orientation, you should do this via
|
|
|
|
the 'export_orientation' function in 'main.m'. The XCode orientation
|
2016-11-26 11:23:43 +01:00
|
|
|
settings should be set to support all.
|
|
|
|
|
|
|
|
Using recipes
|
|
|
|
-------------
|
|
|
|
|
|
|
|
Recipes are used to install and compile any libraries you may need to use. These
|
2016-11-26 11:25:22 +01:00
|
|
|
recipes follow the same format as those used by the
|
2016-11-26 11:29:58 +01:00
|
|
|
`Python-for-Android <https://github.com/kivy/python-for-android>`_ sister project.
|
|
|
|
Please refer to the
|
2016-11-26 11:27:17 +01:00
|
|
|
`recipe documentation <https://python-for-android.readthedocs.io/en/latest/recipes/>`_
|
2016-11-26 11:29:58 +01:00
|
|
|
there for more detail.
|
2016-06-28 12:31:35 +02:00
|
|
|
|
2016-11-23 13:18:41 +01:00
|
|
|
Reducing the application size
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
If you would like to reduce the size of your distributed app, there are a few
|
|
|
|
things you can do to achieve this:
|
|
|
|
|
|
|
|
#. Minimize the `build/python/lib/python27.zip`: this contains all the python
|
|
|
|
modules. You can edit the zip file and remove all the files you'll not use
|
|
|
|
(reduce encodings, remove xml, email...)
|
|
|
|
|
|
|
|
#. Go to the settings panel > build, search for "strip" options, and
|
|
|
|
triple-check that they are all set to NO. Stripping does not work with
|
|
|
|
Python dynamic modules and will remove needed symbols.
|
|
|
|
|
|
|
|
#. By default, the iOS package compiles binaries for all processor
|
|
|
|
architectures, namely x86, x86_64, armv7 and arm64 as per the guidelines from
|
|
|
|
Apple. You can reduce the size of your ipa significantly by removing the
|
|
|
|
x86 and x86_64 architectures as they are usually used only for the emulator.
|
|
|
|
|
|
|
|
The procedure is to first compile/build all the host recipes as is::
|
|
|
|
|
|
|
|
./toolchain.py build hostpython
|
|
|
|
|
|
|
|
Then build all the rest of the recipes using --arch=armv7 --arch=arm64
|
|
|
|
arguments as follows::
|
|
|
|
|
|
|
|
./toolchain.py build kivy --arch=armv7 --arch=arm64
|
|
|
|
|
|
|
|
Note that these packages will not run in the iOS emulators, so use them
|
|
|
|
only for deployment.
|
|
|
|
|
2017-10-25 16:10:15 +02:00
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
./toolchain.py <command> [<args>]
|
|
|
|
|
|
|
|
Available commands:
|
|
|
|
build Build a recipe (compile a library for the required target
|
|
|
|
architecture)
|
|
|
|
clean Clean the build of the specified recipe
|
|
|
|
distclean Clean the build and the result
|
|
|
|
recipes List all the available recipes
|
|
|
|
status List all the recipes and their build status
|
|
|
|
|
|
|
|
Xcode:
|
|
|
|
create Create a new xcode project
|
|
|
|
update Update an existing xcode project (frameworks, libraries..)
|
|
|
|
launchimage Create Launch images for your xcode project
|
|
|
|
icon Create Icons for your xcode project
|
|
|
|
pip Install a pip dependency into the distribution
|
|
|
|
|
2015-03-05 17:29:44 +01:00
|
|
|
FAQ
|
|
|
|
---
|
|
|
|
|
|
|
|
Fatal error: "stdio.h" file not found
|
|
|
|
You need to install the Command line tools: `xcode-select --install`
|
2018-10-28 16:24:11 +01:00
|
|
|
|
2016-04-12 22:02:25 +02:00
|
|
|
You must build with bitcode disabled (Xcode setting ENABLE_BITCODE should be No).
|
|
|
|
We don't support bitcode. You need to go to the project setting, and disable bitcode.
|
2015-11-03 16:02:42 +01:00
|
|
|
|
|
|
|
Support
|
|
|
|
-------
|
|
|
|
|
|
|
|
If you need assistance, you can ask for help on our mailing list:
|
|
|
|
|
|
|
|
* User Group : https://groups.google.com/group/kivy-users
|
|
|
|
* Email : kivy-users@googlegroups.com
|
|
|
|
|
2018-10-28 16:24:11 +01:00
|
|
|
We also have a Discord channel:
|
2015-11-03 16:02:42 +01:00
|
|
|
|
2018-10-28 16:24:11 +01:00
|
|
|
* Server : https://chat.kivy.org
|
|
|
|
* Channel : #support
|
2015-11-03 16:02:42 +01:00
|
|
|
|
|
|
|
Contributing
|
|
|
|
------------
|
|
|
|
|
|
|
|
We love pull requests and discussing novel ideas. Check out our
|
|
|
|
`contribution guide <http://kivy.org/docs/contribute.html>`_ and
|
|
|
|
feel free to improve Kivy for iOS.
|
|
|
|
|
|
|
|
The following mailing list and IRC channel are used exclusively for
|
|
|
|
discussions about developing the Kivy framework and its sister projects:
|
|
|
|
|
|
|
|
* Dev Group : https://groups.google.com/group/kivy-dev
|
|
|
|
* Email : kivy-dev@googlegroups.com
|
|
|
|
|
2018-10-28 16:24:11 +01:00
|
|
|
Discord channel:
|
2015-11-03 16:02:42 +01:00
|
|
|
|
2018-10-28 16:24:11 +01:00
|
|
|
* Server : https://chat.kivy.org
|
|
|
|
* Channel : #dev
|
2015-11-03 16:02:42 +01:00
|
|
|
|
|
|
|
License
|
|
|
|
-------
|
|
|
|
|
|
|
|
Kivy for iOS is released under the terms of the MIT License. Please refer to the
|
|
|
|
LICENSE file.
|