Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Package Your App for iOS

For help with packaging your app for iOS, check out Kivy documentation - Create a package for iOS.

00:00 Instructions for building an application for iOS are a little more complex than Android. For the most up-to-date information, you should always use Kivy’s official packaging documentation.

00:14 You’ll need to run the command seen on-screen before you can package your application for iOS on your Mac.

00:39 The second command may not be needed, but there’s no harm in running it. If you’ve not used pip to install cython, as seen in the previous section to create an Android app, then you’ll need to do that too.

01:02 Once those are all installed successfully, you’ll need to install kivy-ios.

01:18 To ensure you avoid hard-to-diagnose problems with Xcode, you’ll need to keep your kivy-ios/ folder outside of the tree where your existing Python project is located. If you don’t do this, then Xcode will generate errors during the build process that can be hard to track down. So, on-screen, you’ll see the creation of a kivy-ios/ folder, which is outside of the path of the folder where the development has been happening so far, as seen on-screen.

01:47 First, the new directory is created … and then navigated to … and then the toolchain build is started, which can take some time. If you’ve installed but not run Xcode, then you’ll need to run it first, as this will install the extras, such as iPhone Simulator, that are needed for the iOS packaging to work.

02:26 If you run into SSL errors, then you probably don’t have Python’s OpenSSL set up. The command seen on-screen should fix that.

02:47 Once you’ve done that, try running the toolchain command again. When you’ve run all the previous commands successfully, you can create your Xcode project using the toolchain script.

03:01 Your main application’s entry point must be named main.py before you create the Xcode project. To ensure only the needed files are copied, main.py will be copied into a new folder within the project, but it will be called kivy-ios-source to make identification easier.

03:22 First, change back to the original kivy/ project directory. Next, the source directory is created. And finally, the calculator.py file is copied into it, renaming it in the process.

03:46 Next, the toolchain command is used to create the project. Note that title will be the name of the project, and it can’t contain any spaces or illegal characters. Also, note that the app_directory must be a fully qualified path.

04:03 On-screen, you can see the command that I ran, but your version will probably be different, as you’re using a different directory, so you’ll need to alter your command to suit.

04:15 First, navigate back to the kivy-ios/ directory, and then use the toolchain create command to create the Xcode project with the appropriate name and application source specified.

04:42 Now the project can be opened in Xcode using the project info that was output at the end of the project creation step.

04:58 The default settings will generate some warnings in Xcode, but regardless of these, you should be able to run the program by pressing the button at the top of the screen, as seen.

05:11 After a short delay, you should see the iPhone Simulator on-screen running your kvcalc program. Note that if you want to submit your application to the App Store, then you’ll have to create a developer account at developer.apple.com and pay the yearly fee.

05:32 In the next section of the course, you’ll take a look back at what you’ve learned.

Become a Member to join the conversation.