November 22, 2021
Andrew Wright, Ph. D.
This post is about getting Kivy, Spyder, Anaconda, Xcode, and an iPhone working together. I have discovered that these tools are evolving rapidly, so these videos and explanations might go out-of-date quickly. Since I’m using these tools in my classes, I should be keeping them up-to-date. However, I updated the video in June of 2021, and it was out-of-date in August, 2021!
Setting up the tools:
There are a number of tools needed to get python to play nice with Xcode and to get Xcode to compile for iPhone.
Install Anaconda [video]
Install Spyder [video]
Simple test program [video]
Add Kivy to Spyder
Inside the ipython window in Spyder, install the kivy package using conda:
conda install kivy –channel conda-forge
The channel conda-forge is not in the standard channels, but it is a legitimate anaconda channel.
Install Xcode from the App Store. Download.
Go to Xcode->Preferences->Accounts. Click the + sign (if there are no accounts shown).
Use Apple ID for your account. This will require you to sign in with your Apple ID.
Set your team. You may only have one option.
Manage certificates. I think you do something with keychain access. I did this ages ago, and it appears to carry on through the years. Build a default code with Xcode for IOS. File->New Project. Follow the prompts.
Look on internets for how to do this.
Use brew to install tools:
see the kivy.org documentation. Look for, how to package your application.
On the step “pip install |cython_install|” you just need to do “pip install Cython”. On my system, Cython is installed with anaconda.
I got stuck on more of these steps. It looks like there are compatibility issues between versions. I’m not a fan of spending lots of time doing low-level adjustments in system files to get a tool working. If the basic doesn’t work, then I’m going to wait until errors get repaired.
Once you have the tools installed, you need to test them.
Make your code. This code was adapted from the default code in the kivy documentation.
from kivy.app import App
from kivy.uix.button import Label
Plug your device into your computer via USB. Wait for a bit.
Compile for your device. Product -> Destination (select your device from the menu).
Lots of stuff happens. Maybe errors if your certificates aren’t set up. Eventually, if it works, you’ll have an icon on your device. Double click the icon. MORE ERRORS. Go to Settings->General->Device Management and Profiles. Poke around until you find a button to trust the developer you set up in Xcode. Double click icon again, and the app should run.
Cross compile (may need some more software install)
Here is Kivy’s documentation on how to do the next steps: https://kivy.org/doc/stable/guide/packaging-ios.html
I’m not sure from reading the documentation about how kivy code connects with kivy-ios. It looks like the tools are completely external to the anaconda/spyder environment.
I think the short version of this story is … do your desktop apps in Spyder. Run on your desktop. Maybe those apps can be used on mobile with the kivy-ios/Xcode kludge, and maybe kivy will help with the gui/look-and-feel so that everything looks the same.
It’s still not perfect (one tool to rule them all). But, things are a little closer than the last time I jumped down this rabbit hole.