How to Copy Code from Photos with iOS 15 Live Text

Apple's iOS 15 introduced Live Text, an on-device optical character recognition (OCR) feature that automatically detects text within images, including photos and screenshots. For programmers, this feature provides a seamless bridge between physical media or non-selectable screenshots and mobile development environments. By utilizing the Apple Neural Engine, Live Text enables developers to instantly highlight, copy, and paste syntax-heavy code snippets directly into iOS coding apps without manual retyping.

How Live Text Functions

Live Text relies on deep learning models running locally via the device's Neural Engine on devices equipped with an A12 Bionic chip or newer. When an image is opened in the Photos app, Camera, or Quick Look, the operating system performs real-time image analysis.

The machine learning framework identifies characters, whitespace, and punctuation marks common in programming languages, such as curly braces, brackets, and semicolons. Once the text is mapped, the system treats it as native digital text overlaying the image canvas.

The Process of Extracting Code to Dev Apps

Developers can move code from a photograph or screenshot into an IDE or code editor using a straightforward workflow:

  1. Capture the Source: Take a photograph of a screen, book, or whiteboard, or take a screenshot of code from a video or non-copyable application.
  2. Access the Image: Open the captured file in the Photos app or tap the preview thumbnail immediately after capturing a screenshot.
  3. Engage Live Text: Tap the Live Text icon in the bottom-right corner of the interface, or press and hold directly on the code snippet to initiate a standard text selection.
  4. Select and Copy: Drag the selection handles over the desired lines of code, accounting for indentation, and tap Copy from the contextual menu.
  5. Paste into Development Apps: Switch to an iOS development environment—such as Swift Playgrounds, Textastic, Runestone, or a web-based editor—and tap Paste.

Formatting and Accuracy Considerations

Live Text generally preserves indentation, capitalization, and special characters, which are critical for programming syntax. However, OCR accuracy can occasionally vary depending on source image quality:

  • Monospaced Fonts: Live Text performs exceptionally well on standard monospaced coding fonts (such as Menlo, Fira Code, or SF Mono) captured in high resolution.
  • Character Ambiguity: Developers should quickly verify ambiguous characters after pasting, such as distinguishing between uppercase O and zero 0, or lowercase l and the numeral 1.
  • Indentation: While basic line breaks and spaces are retained, complex tab-spaced blocks in indentation-sensitive languages (like Python) may require minor manual formatting adjustments after being pasted.