Skip to content

Fix Apple Pencil compatibility for M4 iPad Pro and M2/M3 iPad Air models#474

Merged
Zandor300 merged 8 commits intomasterfrom
copilot/fix-apple-pencil-compatibility
Mar 2, 2026
Merged

Fix Apple Pencil compatibility for M4 iPad Pro and M2/M3 iPad Air models#474
Zandor300 merged 8 commits intomasterfrom
copilot/fix-apple-pencil-compatibility

Conversation

Copy link
Contributor

Copilot AI commented Nov 17, 2025

Fix incorrect Apple Pencil compatibility for recent iPad models

Based on Apple's official documentation at https://support.apple.com/en-au/HT211029:

Changes Summary:

iPad (10th gen) & iPad (A16)

  • Before: Apple Pencil (USB-C) only
  • After: Apple Pencil (1st gen) + Apple Pencil (USB-C)

iPad Air 11" & 13" (M2)

  • Before: Apple Pencil (2nd gen) + Apple Pencil Pro
  • After: Apple Pencil (USB-C) + Apple Pencil Pro

iPad Air 11" & 13" (M3)

  • Before: Apple Pencil (2nd gen) + Apple Pencil Pro
  • After: Apple Pencil (USB-C) + Apple Pencil Pro

iPad Pro 11" & 13" (M4)

  • Before: Apple Pencil (2nd gen) + Apple Pencil (USB-C) + Apple Pencil Pro
  • After: Apple Pencil (USB-C) + Apple Pencil Pro

Technical Changes:

  • Add template support for value 13 (firstGeneration + firstGenerationUsbC combination)
  • Update iPad (10th gen) - Change applePencilSupport from 3 to 13
  • Update iPad (A16) - Change applePencilSupport from 3 to 13
  • Update iPad Air 11" (M2) - Change applePencilSupport from 24 to 34
  • Update iPad Air 13" (M2) - Change applePencilSupport from 24 to 34
  • Update iPad Air 11" (M3) - Change applePencilSupport from 24 to 34
  • Update iPad Air 13" (M3) - Change applePencilSupport from 24 to 34
  • Update iPad Pro 11" (M4) - Change applePencilSupport from 234 to 34
  • Update iPad Pro 13" (M4) - Change applePencilSupport from 234 to 34
  • Regenerate Device.generated.swift from template
  • Add comprehensive tests for all affected devices
  • Remove sourceLocation debug lines from generated file
  • Add changelog entry
  • Fix trailing whitespace lint errors

Files Changed:

  • Source/Device.swift.gyb - Updated device definitions and added template case for value 13
  • Source/Device.generated.swift - Regenerated from template without sourceLocation lines
  • Tests/Tests.swift - Added tests validating all changes
  • CHANGELOG.md - Added bug fix entry

Note: This project requires macOS with Xcode to build and test. The CI pipeline will validate these changes on macOS.

Original prompt

This section details on the original issue you should resolve

<issue_title>Incorrect Apple Pencil compatibility for M4 iPad Pro and M2/M3 iPad Air models</issue_title>
<issue_description>Device.applePencilSupport currently lists incorrect Apple Pencil compatibility for several recent iPad models.
Apple’s official documentation: https://support.apple.com/en-au/HT211029

  • M4 iPad Pro (11/13") – Does not support Apple Pencil (2nd gen). Supports Pencil Pro and Pencil (USB-C).
  • iPad Air (M2/M3, 11" & 13") – Supports Pencil Pro and Pencil (USB-C), not 2nd gen.
  • iPad (10th gen) & iPad (A16) – Supports Pencil (USB-C) and Pencil (1st gen).

Proposed fix:

case .iPadPro11M4, .iPadPro13M4:
    return [.firstGenerationUsbC, .pro]

case .iPadAir11M2, .iPadAir13M2, .iPadAir11M3, .iPadAir13M3:
    return [.firstGenerationUsbC, .pro]

case .iPad10, .iPadA16:
    return [.firstGenerationUsbC, .firstGeneration]
</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@github-actions
Copy link

github-actions bot commented Nov 17, 2025

8 Warnings
⚠️ Plist changed, don't forget to localize your plist values
⚠️ Source/Device.generated.swift#L777 - TODOs should be resolved (Replace with proper implementa…).
todo Device.generated.swift:777
⚠️ Source/Device.generated.swift#L1368 - TODOs should be resolved (Replace with proper implementa…).
todo Device.generated.swift:1368
⚠️ Source/Device.generated.swift#L1639 - TODOs should be resolved (Replace with proper implementa…).
todo Device.generated.swift:1639
⚠️ Source/Device.generated.swift#L1824 - TODOs should be resolved (Replace with proper implementa…).
todo Device.generated.swift:1824
⚠️ Source/Device.generated.swift#L1989 - TODOs should be resolved (Replace with proper implementa…).
todo Device.generated.swift:1989
⚠️ Source/Device.generated.swift#L2710 - TODOs should be resolved (Replace with proper implementa…).
todo Device.generated.swift:2710
⚠️ Source/Device.generated.swift#L2772 - TODOs should be resolved (Replace with proper implementa…).
todo Device.generated.swift:2772

SwiftLint found issues

Warnings

File Line Reason
Device.generated.swift 777 TODOs should be resolved (Replace with proper implementa...). (todo)
Device.generated.swift 1368 TODOs should be resolved (Replace with proper implementa...). (todo)
Device.generated.swift 1639 TODOs should be resolved (Replace with proper implementa...). (todo)
Device.generated.swift 1824 TODOs should be resolved (Replace with proper implementa...). (todo)
Device.generated.swift 1989 TODOs should be resolved (Replace with proper implementa...). (todo)
Device.generated.swift 2710 TODOs should be resolved (Replace with proper implementa...). (todo)
Device.generated.swift 2772 TODOs should be resolved (Replace with proper implementa...). (todo)

Errors

File Line Reason
Device.generated.swift 626 Function should have complexity 10 or less: currently complexity equals 140 (cyclomatic_complexity)

Generated by 🚫 Danger

@Zandor300
Copy link
Member

@copilot remove sourceLocation lines from generated Swift file.

Copilot AI changed the title [WIP] Fix incorrect Apple Pencil compatibility for iPad models Fix Apple Pencil compatibility for M4 iPad Pro and M2/M3 iPad Air models Nov 17, 2025
Copilot AI requested a review from Zandor300 November 17, 2025 21:27
Copy link
Contributor Author

Copilot AI commented Nov 17, 2025

@copilot remove sourceLocation lines from generated Swift file.

Done! Regenerated the file using gyb.py --line-directive '' to suppress the sourceLocation debug markers. All 1235 lines removed while preserving the Apple Pencil compatibility fixes. (774cb6c)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes incorrect Apple Pencil compatibility information for recent iPad models by updating the applePencilSupport property to match Apple's official documentation. The changes correct compatibility for M4 iPad Pro, M2/M3 iPad Air, and 10th generation iPad models.

Key changes:

  • Added template support for the value 13 combination (1st gen + USB-C Pencil) in the code generation template
  • Updated 8 iPad models with corrected Apple Pencil support values
  • Added comprehensive test coverage for all affected devices

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
Source/Device.swift.gyb Updated applePencilSupport values for 8 iPad models (iPad 10th gen, iPad A16, 4 iPad Air models, 2 iPad Pro M4 models) and added template case for value 13
Source/Device.generated.swift Regenerated Swift code from template with corrected Apple Pencil support arrays for all affected devices
Tests/Tests.swift Added testApplePencilSupport() function with 50 lines of assertions validating correct Pencil support for all 8 affected iPad models

@Zandor300
Copy link
Member

@copilot Please add a changelog entry and fix linting errors from swiftlint on the lines you changed. Don't apply linting fixes to lines that you haven't touched previously inside this PR.

Copy link
Contributor Author

Copilot AI commented Dec 2, 2025

@copilot Please add a changelog entry and fix linting errors from swiftlint on the lines you changed. Don't apply linting fixes to lines that you haven't touched previously inside this PR.

Added changelog entry and fixed trailing whitespace on blank lines in testApplePencilSupport(). (2011d0e)

Copilot AI requested a review from Zandor300 December 2, 2025 09:57
@Zandor300 Zandor300 force-pushed the copilot/fix-apple-pencil-compatibility branch from 9b4a20f to ff78b6e Compare December 3, 2025 19:31
@Zandor300
Copy link
Member

@copilot You need to rebase on master.

Copy link
Contributor Author

Copilot AI commented Dec 3, 2025

@copilot You need to rebase on master.

I'm unable to perform a rebase as it requires force push, which I don't have access to. Could you please rebase this branch on master? Once done, I can continue with any additional changes needed.

@Zandor300 Zandor300 force-pushed the copilot/fix-apple-pencil-compatibility branch from 4ed1389 to a50c628 Compare December 3, 2025 20:02
@Zandor300 Zandor300 marked this pull request as ready for review March 2, 2026 15:27
Copilot AI and others added 2 commits March 2, 2026 17:39
Co-authored-by: Zandor300 <6069593+Zandor300@users.noreply.github.com>
Copilot AI and others added 6 commits March 2, 2026 17:44
Co-authored-by: Zandor300 <6069593+Zandor300@users.noreply.github.com>
Co-authored-by: Zandor300 <6069593+Zandor300@users.noreply.github.com>
The firstGenerationUsbC raw value (0x03) overlapped with firstGeneration
(0x01) and secondGeneration (0x02), causing contains() checks to return
incorrect results. Changed to proper power-of-2 values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Zandor300 Zandor300 force-pushed the copilot/fix-apple-pencil-compatibility branch from 46fce1b to a43c030 Compare March 2, 2026 16:45
///
/// - returns: An initialized `Device`.
public static func mapToDevice(identifier: String) -> Device { // swiftlint:disable:this cyclomatic_complexity function_body_length
public static func mapToDevice(identifier: String) -> Device {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Function should have complexity 10 or less: currently complexity equals 140
cyclomatic_complexity Device.generated.swift:626

@Zandor300 Zandor300 merged commit 5314fea into master Mar 2, 2026
10 checks passed
@Zandor300 Zandor300 deleted the copilot/fix-apple-pencil-compatibility branch March 2, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect Apple Pencil compatibility for M4 iPad Pro and M2/M3 iPad Air models

3 participants