# What are the compiler technologies that support the App Intents framework?

**URL:** <https://forums.swift.org/t/what-are-the-compiler-technologies-that-support-the-app-intents-framework/59981>\
**Category:** Using Swift\
**Created:** [August 30, 2022, 12:05pm UTC](https://forums.swift.org/t/what-are-the-compiler-technologies-that-support-the-app-intents-framework/59981 "2022-08-30T12:05:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gwendal.roue](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gwendal.roue/32/13992_2.png) [@gwendal.roue](https://forums.swift.org/u/gwendal.roue)\
**Post date:** [August 30, 2022, 12:05pm UTC](https://forums.swift.org/t/what-are-the-compiler-technologies-that-support-the-app-intents-framework/59981/1 "2022-08-30T12:05:35Z")

</div>

Hello,

While looking at [WWDC 2022 - Dive into App Intents](https://developer.apple.com/videos/play/wwdc2022/10032), my attention was caught by two sentences pronounced by the speaker Michael Gorbach during the presentation:

- 07:32 ["These must be provided as a dictionary literal, since the compiler will read this code at build time."](https://developer.apple.com/videos/play/wwdc2022-10032/?time=452)
- 29:06 ["Xcode will generate a metadata file inside your app or extension bundle during your build process, containing information received from the Swift compiler as it runs on your code."](https://developer.apple.com/videos/play/wwdc2022-10032/?time=1746)

For example, declaring a struct that conforms to the `AppShortcutsProvider` protocol is enough for iOS to vend app shortcuts to the end user:

```swift
import AppIntents

struct MyShortcuts: AppShortcutsProvider {
    static var appShortcuts: [AppShortcut] {
        AppShortcut(...)
    }
}

```

My app _does not run_ any line of the above code. And yet the mere _presence_ of this type in my target has consequences. Surely some technique(s) I'm totally unaware of is at play here.

The transcript mentions "literals", "build time" and "build process", although a close inspection of the build logs did not make anything pop up to my eyes (maybe I did not look close enough).

Has anyone some insight about the techniques that are at play here? The requirement for "literals" make me think of a pre-release of [SE-0359](https://github.com/apple/swift-evolution/blob/main/proposals/0359-build-time-constant-values.md). The "during your build process" snippet may just refer to some Xcode proprietary technology, perhaps akin to package plugins. Yet I can't quite figure out what "information received from the Swift compiler as it runs on your code" refers to.

---

<div class="post-metadata">

**Author:** ![sveinhal](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sveinhal/32/3992_2.png) [@sveinhal](https://forums.swift.org/u/sveinhal)\
**Post date:** [August 30, 2022, 12:38pm UTC](https://forums.swift.org/t/what-are-the-compiler-technologies-that-support-the-app-intents-framework/59981/2 "2022-08-30T12:38:01Z")

</div>

When I saw this, I just assumed that this was a build tool package plugin at play, which would somehow scan my source code and generate the entitlements needed. But I haven't looked into any of that, so this is pure speculation.

---

<div class="post-metadata">

**Author:** ![mgorbach](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/mgorbach/32/25144_2.png) [@mgorbach](https://forums.swift.org/u/mgorbach)\
**Post date:** [September 8, 2022, 6:03pm UTC](https://forums.swift.org/t/what-are-the-compiler-technologies-that-support-the-app-intents-framework/59981/3 "2022-09-08T18:03:09Z")

</div>

This is indeed build time extraction. There is an "Extract app intents metadata" step in the build log. The way this works is that the Swift compiler outputs some information that it generates while compiling your code, which describes what types are available in your code, as well as type-level and some value-level information from your App Intents method implementations. This information is parsed by another tool which generates a metadata.appintents directory in your built product which contains files that describe your intents, and other information we need to know without running your app, such as information needed to render your intents in Shortcuts.

---

<div class="post-metadata">

**Author:** ![John\_McCall](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/john_mccall/32/1351_2.png) [@John\_McCall](https://forums.swift.org/u/John_McCall)\
**Post date:** [September 8, 2022, 8:43pm UTC](https://forums.swift.org/t/what-are-the-compiler-technologies-that-support-the-app-intents-framework/59981/4 "2022-09-08T20:43:29Z")

</div>

The interaction with SE-0359 is basically that Swift uses an underscored version of that feature to force the operand to be a literal so that the static extraction of these values by that secondary tool cannot fail.

---

<div class="post-metadata">

**Author:** ![gwendal.roue](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/gwendal.roue/32/13992_2.png) [@gwendal.roue](https://forums.swift.org/u/gwendal.roue)\
**Post date:** [September 9, 2022, 6:56am UTC](https://forums.swift.org/t/what-are-the-compiler-technologies-that-support-the-app-intents-framework/59981/5 "2022-09-09T06:56:15Z")

</div>

Thank you Michael :-) And thanks for the name of the "Extract app intents metadata" step 👍

---

<div class="post-metadata">

**Author:** ![tstromberg](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tstromberg/32/18093_2.png) [@tstromberg](https://forums.swift.org/u/tstromberg)\
**Post date:** [September 23, 2022, 9:08pm UTC](https://forums.swift.org/t/what-are-the-compiler-technologies-that-support-the-app-intents-framework/59981/6 "2022-09-23T21:08:38Z")

</div>

Out of curiosity, what files is the tooling in the "Extract app intents metadata" step looking at for this information?

---

<div class="post-metadata">

**Author:** ![dziobaczy](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dziobaczy/32/42538_2.png) [@dziobaczy](https://forums.swift.org/u/dziobaczy)\
**Post date:** [February 3, 2023, 12:39pm UTC](https://forums.swift.org/t/what-are-the-compiler-technologies-that-support-the-app-intents-framework/59981/7 "2023-02-03T12:39:29Z")

</div>

I find out that there is no way for me to exclude the "Extract app intents metadata" step, even if all `AppIntentes` related coded is hidden behind some debug flag.

It just goes like "Extracted no relevant App Intents symbols, skipping writing output" and that step takes it 13 seconds for my app.

The only way is to replace the executable for `appintentsmetadataprocessor`. Anyone experiences this step to take so long too?

---

<div class="post-metadata">

**Author:** ![Frederiks96](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/frederiks96/32/25111_2.png) [@Frederiks96](https://forums.swift.org/u/Frederiks96)\
**Post date:** [February 14, 2023, 3:06pm UTC](https://forums.swift.org/t/what-are-the-compiler-technologies-that-support-the-app-intents-framework/59981/8 "2023-02-14T15:06:32Z")

</div>

Yes. I am seeing this step taking between 1 and 2 minutes on each build.

---

<div class="post-metadata">

**Author:** ![jiaqiaolin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jiaqiaolin/32/37288_2.png) [@jiaqiaolin](https://forums.swift.org/u/jiaqiaolin)\
**Post date:** [September 14, 2024, 9:26am UTC](https://forums.swift.org/t/what-are-the-compiler-technologies-that-support-the-app-intents-framework/59981/9 "2024-09-14T09:26:28Z")

</div>

When I use cocoaPods to manager my AppIntent file, I always failed to the "Extract app intents metadata" step. If anybody knows about why or give me some clue?
