PEP 730: CPython Adds iOS Support

BY Mark Howell 1 years ago5 MINS READ
article cover

Today in Edworking News we want to talk about PEP 730 – Adding iOS as a Supported Platform

Abstract

This PEP proposes adding iOS as a supported platform in CPython. The initial goal is to achieve Tier 3 support for Python 3.13. This PEP describes the technical aspects of the changes that are required to support iOS. It also describes the project management concerns related to the adoption of iOS as a Tier 3 platform.

Motivation

Over the last 15 years, mobile platforms have become increasingly important parts of the computing landscape. iOS is one of two operating systems that control the vast majority of these devices. However, there is no official support for iOS in CPython. The BeeWare Project and Kivy have both supported iOS for almost 10 years. This support has been able to generate applications that have been accepted for publication in the iOS App Store. This demonstrates the technical feasibility of iOS support.
It is important for the future of Python as a language that it is able to be used on any hardware or OS that has widespread adoption. If Python cannot be used on a platform that has widespread use, adoption of the language will be impacted as potential users will adopt other languages that do provide support for these platforms.

Python adds iOS as a supported platform (Tier 3)

Development Landscape

  • iOS provides a single API, but two distinct ABIs: `iphoneos` (physical devices) and `iphonesimulator`.

  • iOS supports "fat" binaries, containing multiple CPU architectures, but cannot span ABIs. For distribution, the "XCframework" structure is used.

  • iOS runs on a Darwin kernel, similar to macOS, but needs differentiation at an implementation level due to platform differences.

  • Apple's references to iPadOS in marketing have no development implications, as binaries for `iphoneos` or `iphonesimulator` ABIs can be deployed on iPads.

  • Other Apple platforms like tvOS, watchOS, and visionOS use different ABIs and are not covered by this PEP.

POSIX Compliance

  • iOS is broadly a POSIX platform but with significant restrictions:
    - No multiprocess support (`fork` and `spawn` exist but do not function as expected).
    - Threading is supported, but there are significant limitations to socket handling.

Dynamic Libraries

  • Apps can use dynamically loaded libraries with strict guidelines on how content is packaged for use on iOS.

  • Binary modules cannot be stored in usual directories like lib-dynload; they must be in the app’s Frameworks folder.

Console and Interactive Usage

  • A traditional CPython REPL or interactive "python.exe" is not viable because mobile devices do not provide a TTY-style console with stdin, stdout, or stderr.

  • An embedded distribution suitable for native iOS applications with IDE-style interfaces is the goal.

Specification

Platform Identification

  • `sys.platform` will identify as "ios" on both simulator and physical devices.

  • ABI and CPU architecture details will be identified by `sys.implementation._multiarch`.

  • A new method, `platform.ios_ver()`, will provide iOS version information.

Subprocess Support

  • iOS will disable subprocesses, raising exceptions if attempts are made to start subprocesses, and `os.fork` and `os.spawn` calls will raise an `OSError`.

Dynamic Module Loading

  • Import requests for Python binary modules will be converted to Framework locations.

Compilation

  • The dynamically-linkable `libpython3.x.dylib` is the only supported binary format.

  • Compilation requires using cross-platform tooling in CPython’s configure build system.

  • An Xcode project will be provided for running the CPython test suite.

Distribution

  • Adding iOS as a Tier 3 platform requires support for compiling an iOS-compatible build from an unpatched CPython code checkout, not official end-user iOS artifacts.

CI Resources

  • Anaconda has offered to provide hardware to run iOS buildbots.

  • GitHub Actions can host iOS simulators on their macOS machines.

Packaging

  • iOS will not use a universal wheel format. Individual ABI-arch combination wheels will be provided.

PEP 11 Update

  • PEP 11 will be updated to include iOS ABIs. Ned Deily will serve as the initial core team contact.

Backwards Compatibility

  • Adding iOS support does not introduce backwards compatibility concerns to CPython.

  • There may be some implications for projects that have historically provided CPython support (BeeWare and Kivy).

Security Implications

  • Adding iOS does not introduce any new security implications.

How to Teach This

  • Documentation and tutorials demonstrating how end-users can add iOS support to their Xcode projects will be provided.

Reference Implementation

The BeeWare Python-Apple-support repository, Briefcase, and Toga Testbed are examples of such implementations.

Xcode simulation and tooling integration for testing


Edworking is the best and smartest decision for SMEs and startups to be more productive. Edworking is a FREE superapp of productivity that combines all you need for work powered by AI in the same superapp, connecting Task Management, Docs, Chat, Videocall, and File Management. Save money today by not paying for Slack, Trello, Dropbox, Zoom, and Notion.

Remember these 3 key ideas for your startup:

  1. Expand to iOS: Leverage the new capability to run Python on iOS platforms, tapping into one of the largest mobile operating system user bases. Official support can dramatically increase your application's reach and adoption.

  2. Adapt to Framework Constraints: Be aware of the strict packaging and dynamic library requirements for iOS applications, which can affect the way you structure your app’s libraries. This ensures smooth functionality and compliance with Apple's guidelines.

  3. Integrate and Automate: Use tools like GitHub Actions and Anaconda’s buildbot resources to automate your build and testing processes, maximizing efficiency and reliability in your development workflow.
    For more detailed comprehension and to explore potential implementations, visit the Python PEP 730.

    This approach toward integrating iOS opens up new avenues for Python developers to delve into the mobile domain, potentially expanding the Python ecosystem and enriching both developer and user experiences.
    For more details, see the original source.

article cover
About the Author: Mark Howell Linkedin

Mark Howell is a talented content writer for Edworking's blog, consistently producing high-quality articles on a daily basis. As a Sales Representative, he brings a unique perspective to his writing, providing valuable insights and actionable advice for readers in the education industry. With a keen eye for detail and a passion for sharing knowledge, Mark is an indispensable member of the Edworking team. His expertise in task management ensures that he is always on top of his assignments and meets strict deadlines. Furthermore, Mark's skills in project management enable him to collaborate effectively with colleagues, contributing to the team's overall success and growth. As a reliable and diligent professional, Mark Howell continues to elevate Edworking's blog and brand with his well-researched and engaging content.

Trendy NewsSee All Articles
CoverEdit PDFs Securely & Freely: Breeze PDF In-Browser SolutionBreeze PDF is a free, offline browser-based PDF editor ensuring privacy. It offers text, image, and signature additions, form fields, merging, page deletion, and password protection without uploads.
BY Mark Howell 1 mo ago
CoverDecoding R1: The Future of AI Reasoning ModelsR1 is an affordable, open-source AI model emphasizing reasoning, enabling innovation and efficiency, while influencing AI advancements and geopolitical dynamics.
BY Mark Howell 26 January 2025
CoverSteam Brick: A Minimalist Gaming Console Redefines PortabilitySteam Brick: A modified, screenless Steam Deck for travel, focusing on portability by using external displays and inputs. A creative yet impractical DIY project with potential risks.
BY Mark Howell 26 January 2025
CoverVisual Prompt Injections: Essential Guide for StartupsThe Beginner's Guide to Visual Prompt Injections explores vulnerabilities in AI models like GPT-4V, highlighting security risks for startups and offering strategies to mitigate potential data compromises.
BY Mark Howell 13 November 2024
CoverGraph-Based AI: Pioneering Future Innovation PathwaysGraph-based AI, developed by MIT's Markus J. Buehler, bridges unrelated fields, revealing shared complexity patterns, accelerating innovation by uncovering novel ideas and designs, fostering unprecedented growth opportunities.
BY Mark Howell 13 November 2024
CoverRevolutionary Image Protection: Watermark Anything with Localized MessagesWatermark Anything enables embedding multiple localized watermarks in images, balancing imperceptibility and robustness. It uses Python, PyTorch, and CUDA, with COCO dataset, under CC-BY-NC license.
BY Mark Howell 13 November 2024
CoverJungle Music's Role in Shaping 90s Video Game SoundtracksJungle music in the 90s revolutionized video game soundtracks, enhancing fast-paced gameplay on PlayStation and Nintendo 64, and fostering a cultural revolution through its energetic beats and immersive experiences.
BY Mark Howell 13 November 2024
CoverMastering Probability-Generating Functions: A Guide for EntrepreneursProbability-generating functions (pgfs) are mathematical tools used in probability theory for data analysis, risk management, and predictive modeling, crucial for startups and SMEs in strategic decision-making.
BY Mark Howell 31 October 2024
Try EdworkingA new way to work from  anywhere, for everyone for Free!
Sign up Now