Skip to content

Conversation

andrija-ostojic
Copy link
Collaborator

Summary

This PR fixes an issue that appears when using the library in App Extensions, because the library is accessing UIApplication.shared which is not permitted from an App Extension.

Related issue:

Changes

Type

  • Feature: This pull request introduces a new feature.
  • Bug fix: This pull request fixes a bug.
  • Refactor: This pull request refactors existing code.
  • Documentation: This pull request updates documentation.
  • Other: This pull request makes other changes.

Additional information

  • I resolved the issue by wrapping the problematic piece of code inside #if APP_EXTENSION.
    Notice that there is no ! sign in front of APP_EXTENSION which should be the case intuitively, but after some research and testing we found out that this macro actually means that we are NOT in an app extension :)

    • Before Swift even existed, Xcode’s build system and Apple’s Clang compiler used a C preprocessor macro called APP_EXTENSION. Now it can't be changed because of ABI stability.
    • APP_EXTENSION means “this code is being compiled in a context where app extensions exist (i.e., an app)“, not “this code is an app extension.”
    • This came from the Objective-C and C++ world — the Clang driver defines it inversely to prevent linking unsafe APIs into app extensions.
  • I bumped the version to 2.0.1 too

  • This pull request introduces a breaking change.

Description

Checklist

  • I have performed a self-review of my own code.
  • I have tested my changes, including edge cases.
  • I have added necessary tests for the changes introduced (if applicable).
  • I have updated the documentation to reflect my changes (if applicable).

Additional notes

None

@andrija-ostojic andrija-ostojic self-assigned this Oct 10, 2025
@andrija-ostojic andrija-ostojic added the bug Something isn't working label Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant