Close Menu
geekfence.comgeekfence.com
    What's Hot

    Open Cosmos launches first satellites for new LEO constellation

    January 25, 2026

    Achieving superior intent extraction through decomposition

    January 25, 2026

    How UX Research Reveals Hidden AI Orchestration Failures

    January 25, 2026
    Facebook X (Twitter) Instagram
    • About Us
    • Contact Us
    Facebook Instagram
    geekfence.comgeekfence.com
    • Home
    • UK Tech News
    • AI
    • Big Data
    • Cyber Security
      • Cloud Computing
      • iOS Development
    • IoT
    • Mobile
    • Software
      • Software Development
      • Software Engineering
    • Technology
      • Green Technology
      • Nanotechnology
    • Telecom
    geekfence.comgeekfence.com
    Home»iOS Development»Using Apple Foundation Models to Summarize Text
    iOS Development

    Using Apple Foundation Models to Summarize Text

    AdminBy AdminDecember 16, 2025No Comments7 Mins Read0 Views
    Facebook Twitter Pinterest LinkedIn Telegram Tumblr Email
    Using Apple Foundation Models to Summarize Text
    Share
    Facebook Twitter LinkedIn Pinterest Email


    The Apple Foundation Models provides a large language model (LLM) that Apple has optimized to run locally on end-user devices, such as laptops, desktops, or mobile devices. Traditional LLMs operate in data centers equipped with high-powered GPUs, which require substantial memory and substantial power. Bringing that functionality to an end-user device requires significant changes to the model. In Apple’s case, the two most important changes to produce Foundation Models are reducing the number of parameters and quantizing model values.

    These reduced models still contain all the inherent risks of LLMs, such as hallucinations, while these changes to fit onto an end-user device make some uses either impossible or less effective. You can still find it valuable for some tasks, such as summarizing text, understanding text, modifying text, and simple generation tasks, such as writing and data generation. In this tutorial, you’ll modify an app to use Apple Foundation Models to summarize text.

    Apple Foundation Model Requirements

    To use the on-device language model, the user needs to have hardware that supports Apple Intelligence. The user must also turn on Apple Intelligence on their device, and the device must be running version 26 or later of the operating system. When developing, your computer must run macOS 26.0 or later, or you must run your apps on a device that natively supports Apple Intelligence and runs iOS 26 or iPadOS 26 or later. Even if the Simulator is running an appropriate version of the OS, it will only work if the underlying macOS supports Apple Foundation Models.

    When following along with this tutorial, also note that macOS 26 virtual machines often fail to support Apple Foundation Models. You’ll need either a physical Mac running macOS 26 or later, or a device with Apple Foundation Models support to run the app.

    Checking For Model Availability

    Download the materials for this tutorial, and open the starter project. You’ll see a project that implements a share extension that currently echoes any text sent to the extension in a new window. This app has two schemas: LocalSummarizer, which contains the app, and SummarizeExtension, which includes the share extension. Select the SummarizeExtension schema. Build and run the app. You will be asked to select an app to run with the extension. Choose the Safari app in the Simulator, as it provides an easy way to send data to the extension for testing.

    Bring up any web page that contains a long field of text. Tap and hold on some text, and then select the text.

    Selecting Text and Sharing.

    Now long-press on the selected text, and select Share. If you don’t see a Share option in the menu, click the right chevron. Choose the LocalSummarizer option with the Kodeco Logo. This will load a Text Summary overlay window that will show the selected text.

    Selected text echoed on the page.

    You can tap the Copy Summary button to copy the text to the clipboard and swipe down on the window to go back to the original app. In this tutorial, you’ll update this app to use Apple Foundation Models to display a summary of the selected text instead.

    Before using Apple Foundation Models, you must ensure the user’s device supports it and that the user has turned it on. To do this, create a new SwiftUI view named ModelCheckView.swift under the SummarizeExtension folder. To do this, go to File ▸ File from Template… and select SwiftUI View. Give the view the ModelCheckView.swift name and make sure the SummarizeExtension target is the only one selected.

    Now open the ModelCheckView.swift file. Add the import needed to use Foundation Models at the top:

    
    import FoundationModels
    

    Then add the following properties to the top of the struct:

    
    let sharedText: String
    let onDone: () -> Void
    let model = SystemLanguageModel.default
    

    You will use the sharedText property to pass the text to be summarized into the view that displays the summarization. You can pass a method to onDone that will be called when the user closes the summarizing view. You place an instance of SystemLanguageModel.default into model. This property provides access to Foundation Models in your app. Also, delete the #Preview macro and its closure.

    Now replace the view with:

    
    // 1
    switch model.availability {
    // 2
    case .available:
      SummaryView(sharedText: sharedText, onDone: onDone)
    // 3
    case .unavailable(.deviceNotEligible):
      Text("Apple Intelligence is not available on this device.")
    case .unavailable(.appleIntelligenceNotEnabled):
      Text("Apple Intelligence is available, but not enabled on this device.")
    case .unavailable(.modelNotReady):
      Text("The model isn't ready. Try again later.")
    // 4
    case .unavailable:
      Text("An unknown error prevents Apple Intelligence from working.")
    }
    

    This code handles current error conditions and provides a default for any future error states, displaying related text for each.

    1. The model.availability property contains an enum with the availability status for the default model. You use a switch statement to display different information for each status.
    2. For the case when Foundation Models is available and working, you will display the existing SummaryView, passing in the sharedText and onDone properties passed into this view.
    3. You display a text message for each of the current errors to help the user identify what needs to be done to allow the app to work. Note that if you get modelNotReady in the Simulator, it’s usually because the device running the Simulator does not support Foundation Models. This message also appears in many cases if you attempt to run the app on a Simulator running within a virtual machine on a device that doesn’t support Foundation Models.
    4. This case handles any errors not specifically handled earlier. This will future-proof the app to display an error message to the user, even if it can’t provide details.

    Now you need to update the extension to display this view instead of the current SummaryView view. Open ShareViewController.swift, which is a wrapper that bridges the traditional UIKit extension into SwiftUI. Find the showSwiftUIView(with:) method. Change the first line to:

    
    let wvc = UIHostingController(
      rootView: ModelCheckView(
        sharedText: text,
        onDone: closeExtension
      )
    )
    

    This will call your new intermediate ModelCheckView instead of the SummaryView directly. Run the app, select some text and then share it to the SummarizeExtension. You should see the same thing as before if your device or Simulator supports Foundation Models. Otherwise, you’ll see the appropriate error.

    Model Not Ready View

    For testing, you can also test different availability options for Foundation Models from within XCode. Select a Scheme (either LocalSummarizer or SummarizeExtension), click on the dropdown arrow and select Edit Scheme….

    Edit Scheme Menu Options

    Under Run, select the Options tab. You’ll see a dropdown with several options for Simulated Foundation Models Availability. This option defaults to Off, which allows the device’s actual status through to the app. You can change to another available status, and the app will reflect that change. If you select Apple Intelligence Not Enabled, the app will display that message.

    Schema Set to 'Apple Intelligence Not Enabled

    Don’t forget to set this back to Off before continuing to save yourself frustration.

    Next, you will set up the app itself to provide a similar status view. Open ContentView.swift under the LocalSummarizer target. You’ll use a simpler version of the last view. Add the following import to the top:

    
    import FoundationModels
    

    This lets you reference Foundation Models on the view. Now change the body to:

    
    switch SystemLanguageModel.default.availability {
    case .available:
      Text("This device support Apple Foundation Models.")
    case .unavailable(.deviceNotEligible):
      Text("Apple Intelligence is not available on this device.")
    case .unavailable(.appleIntelligenceNotEnabled):
      Text("Apple Intelligence is available, but not enabled on this device.")
    case .unavailable(.modelNotReady):
      Text("The model isn't ready. Try again later.")
    case .unavailable:
      Text("An unknown error prevents Apple Intelligence from working.")
    }
    

    As before, this displays a description for all errors along with a message when Foundation Models is available.

    Now that you’ve ensured Foundation Models is available on the user’s device, you will use it to summarize text in the next section.



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email

    Related Posts

    A Deep Dive into SwiftData migrations – Donny Wals

    January 24, 2026

    AI, find me some work…

    January 23, 2026

    Swift adapter design pattern – The.Swift.Dev.

    January 22, 2026

    Text is not visible when the button is in disabled state

    January 21, 2026

    What’s New in SwiftUI for iOS 18

    January 19, 2026

    WWDC 2023: A Reflection on Apple’s “Spatial Computing” Journey

    January 17, 2026
    Top Posts

    Understanding U-Net Architecture in Deep Learning

    November 25, 202511 Views

    Hard-braking events as indicators of road segment crash risk

    January 14, 20269 Views

    Microsoft 365 Copilot now enables you to build apps and workflows

    October 29, 20258 Views
    Don't Miss

    Open Cosmos launches first satellites for new LEO constellation

    January 25, 2026

    Press Release Open Cosmos, the company building satellites to understand and connect the world, has…

    Achieving superior intent extraction through decomposition

    January 25, 2026

    How UX Research Reveals Hidden AI Orchestration Failures

    January 25, 2026

    ByteDance steps up its push into enterprise cloud services

    January 25, 2026
    Stay In Touch
    • Facebook
    • Instagram
    About Us

    At GeekFence, we are a team of tech-enthusiasts, industry watchers and content creators who believe that technology isn’t just about gadgets—it’s about how innovation transforms our lives, work and society. We’ve come together to build a place where readers, thinkers and industry insiders can converge to explore what’s next in tech.

    Our Picks

    Open Cosmos launches first satellites for new LEO constellation

    January 25, 2026

    Achieving superior intent extraction through decomposition

    January 25, 2026

    Subscribe to Updates

    Please enable JavaScript in your browser to complete this form.
    Loading
    • About Us
    • Contact Us
    • Disclaimer
    • Privacy Policy
    • Terms and Conditions
    © 2026 Geekfence.All Rigt Reserved.

    Type above and press Enter to search. Press Esc to cancel.