Skip to content

Remove #if canImport(FoundationModels) checks from codebase#34078

Open
Cramsden wants to merge 1 commit into
mainfrom
cr/FXIOS-15960_remove_unneeded_import_check
Open

Remove #if canImport(FoundationModels) checks from codebase#34078
Cramsden wants to merge 1 commit into
mainfrom
cr/FXIOS-15960_remove_unneeded_import_check

Conversation

@Cramsden

Copy link
Copy Markdown
Contributor

📜 Tickets

Jira ticket

💡 Description

removes all #if canImport(FoundationModels) checks across the codebase, keeping the positive (FoundationModels / iOS 26) path and dropping the pre-iOS 26 fallback branches and now-stale explanatory comments. Bitrise is now on iOS26 so we don't need these anymore.

🎥 Demos

Before After
Demo

📝 Checklist

  • I filled in the ticket numbers and a description of my work
  • I updated the PR name to follow our PR naming guidelines
  • I ensured unit tests pass and wrote tests for new code
  • If working on UI, I checked and implemented accessibility (Dynamic Text and VoiceOver)
  • If adding telemetry, I read the data stewardship requirements and will request a data review
  • If adding or modifying strings, I read the guidelines and will request a string review from l10n
  • If needed, I updated documentation and added comments to complex code

@Cramsden Cramsden requested a review from a team as a code owner May 30, 2026 03:07
@Cramsden Cramsden requested review from dataports and ih-codes and removed request for dataports May 30, 2026 03:07
@mobiletest-ci-bot

Copy link
Copy Markdown
Messages
📖 Project coverage: 42.74%

💪 Quality guardian

4 tests files modified. You're a champion of test coverage! 🚀

🥇 Perfect PR size

Smaller PRs are easier to review. Thanks for making life easy for reviewers! ✨

🎉 BrowserViewController got smaller

Nice! BrowserViewController.swift got smaller by 6 lines.

✅ New file code coverage

No new file detected so code coverage gate wasn't ran.

✅ Existing file code coverage

No modified file had significant enough changes for the coverage gate to run.

Client.app: Coverage: 41.32

File Coverage
Toast.swift 81.59%
AppleIntelligenceUtil.swift 93.55%
SaveLoginAlert.swift 0.0% ⚠️
AppLaunchUtil.swift 58.51%
PrivacyPreferencesViewController.swift 0.0% ⚠️
MainMenuViewController.swift 8.76% ⚠️
BrowserViewController.swift 37.71% ⚠️
Experiments.swift 79.34%
CreditCardBottomSheetViewController.swift 17.29% ⚠️
ZoomPageBar.swift 85.47%
SummarizerNimbusUtils.swift 100.0%
TabTraySelectorView.swift 58.66%

ComponentLibrary: Coverage: 38.39

File Coverage
CloseButton.swift 62.5%
BottomSheetViewController.swift 4.59% ⚠️

SummarizeKit: Coverage: 71.85

File Coverage
FoundationModelsSummarizer.swift 90.14%
SummarizerConfig.swift 100.0%
LanguageModelSessionProtocol.swift 0.0% ⚠️
SummarizerServiceFactory.swift 66.67%
InfoView.swift 82.42%
LanguageModelSessionAdapter.swift 0.0% ⚠️
SummarizerError.swift 63.33%

Generated by 🚫 Danger Swift against 22b6f11

Comment on lines -409 to -415
#if canImport(FoundationModels)
let glassEffect = UIGlassEffect()
glassEffect.isInteractive = true
effectView.effect = glassEffect
#else
effectView.effect = UIBlurEffect(style: .systemUltraThinMaterial)
#endif

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some of these are tricky. They look as if we are missing the fallback but the function is marked @available so I guess it makes sense. 😆

}

func isAppleSummarizerEnabled() -> Bool {
#if canImport(FoundationModels)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this become an @available iOS 26 check? Is apple summarizer only possible iOS 26+? 🤔 We might have to check with @issammani .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This function is not doing anything iOS26 specific. The function that actually writes to user defaults to say it is available is marked as only for iOS 26 but if the user default value is not written it will return false so this should not need to be marked with an iOS 26 check.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ok I didn't walk through the codepath but I do see in SummarizerServiceFactory.swift there's a isAppleSummarizerEnabled and iOS 26 availability check. Hopefully that means <iOS 26 drops back to the hosted model just fine.

@Cramsden Cramsden requested a review from ih-codes June 10, 2026 17:24
}

func isAppleSummarizerEnabled() -> Bool {
#if canImport(FoundationModels)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ok I didn't walk through the codepath but I do see in SummarizerServiceFactory.swift there's a isAppleSummarizerEnabled and iOS 26 availability check. Hopefully that means <iOS 26 drops back to the hosted model just fine.

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.

3 participants