Skip to content

fix: accessing Availability.h macros in Swift (Xcode 26 support) #4013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 16, 2025

Conversation

liamnichols
Copy link
Contributor

Issue #

#4003

Description

Starting in Xcode 26, the Availability.h/AvailabilityInternal.h headers that contained the __IPHONE_OS_VERSION_MIN_REQUIRED and __MAC_OS_X_VERSION_MIN_REQUIRED preprocessor macros are no longer implicitly exposed to Swift code via the os_availability/os_availability_internal modules which has prevented the Amplify SDK from compiling.

I saw that the xcode-26 branch just commented out the problematic code as a workaround, but I wanted to propose a more suitable fix that involved explicitly exposing the macro values to the AWSCognitoAuthPlugin target via a new AmplifyAvailability system library target.

The new target defines a module map that exposes the AmplifyAvailability.h header and within this header, we just redefine the Availability.h preprocessor macros via getIOSVersionMinRequired() and getMACOSXVersionMinRequired(). These new static symbols are now exposed to the Swift code and can be used instead to provide support both in Xcode 26 and older versions.

General Checklist

  • Added new tests to cover change, if needed
  • Build succeeds with all target using Swift Package Manager
  • All unit tests pass
  • All integration tests pass
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)
  • Documentation update for the change if required
  • PR title conforms to conventional commit style
  • New or updated tests include Given When Then inline code documentation and are named accordingly testThing_condition_expectation()
  • If breaking change, documentation/changelog update with migration instructions

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@liamnichols liamnichols requested a review from a team as a code owner June 30, 2025 10:39
@liamnichols liamnichols changed the title Fix accessing Availability.h macros in Swift (Xcode 26 support) fix: accessing Availability.h macros in Swift (Xcode 26 support) Jun 30, 2025
@harish-suthar
Copy link

harish-suthar commented Jul 7, 2025

@liamnichols This looks a prominent fix any ideas by when can we see this merged and released?

CC: @harsh62

@harsh62
Copy link
Member

harsh62 commented Jul 7, 2025

@harish-suthar Thanks for tagging me.

@liamnichols Thanks for you contribution. The change on a high level looks good. I've approved and ran the workflows to check the health of the PR.

I will work with my team to get feedback.

@harsh62 harsh62 self-requested a review July 7, 2025 15:56
@harsh62
Copy link
Member

harsh62 commented Jul 7, 2025

@liamnichols @harish-suthar This needs to be build on the minimum version of Xcode supported by Amplify which is Xcode 15. At the moment its failing with:

Error: cannot find 'getIOSVersionMinRequired' in scope

@liamnichols
Copy link
Contributor Author

@liamnichols @harish-suthar This needs to be build on the minimum version of Xcode supported by Amplify which is Xcode 15. At the moment its failing with:

Error: cannot find 'getIOSVersionMinRequired' in scope

Hi @harsh62, thanks for pointing this out.. I don't have access to Xcode 15 locally so I hadn't realised this 🙇 I've made some changes to use a regular .target instead of .systemLibrary that defines a small .c file rather than using inline functions, I think this should work better with Xcode 15 but I still haven't tested it myself.

If you could re-run CI that would be appreciated 🙏

@harsh62 harsh62 added the first-time-contributor The contribution is the first for this user in the repo label Jul 16, 2025
Copy link
Member

@harsh62 harsh62 left a comment

Choose a reason for hiding this comment

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

LGTM

@harsh62 harsh62 merged commit c6df692 into aws-amplify:main Jul 16, 2025
9 checks passed
@liamnichols
Copy link
Contributor Author

Thanks for merging this @harsh62! Would it be possible if you could share timelines for releasing updates to amplify-swift and amplify-ui-swift-liveness that contain this patch?

No worries if it won't be for a while, I just need to know if it is worth me creating some forks and using them in the meantime or not 🙂

@harsh62
Copy link
Member

harsh62 commented Jul 16, 2025

I am gonna try to release this week, with a couple of other fixes in the pipeline. At most it could slip into next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-time-contributor The contribution is the first for this user in the repo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants