bazelbuild / rules_apple

Bazel rules to build apps for Apple platforms.
Apache License 2.0
511 stars 268 forks source link

Support iOS 16 AppEntity #1766

Open erikkerber opened 1 year ago

erikkerber commented 1 year ago

Looks like there's a new tool that will extract metadata from code and turn them into appintents

❯ xcrun appintentsmetadataprocessor --help
usage: /Applications/Xcode-14.1.0.app/Contents/Developer/usr/bin/appintentsmetadataprocessor --output PATH --target-triple VALUE --module-name VALUE --toolchain-dir PATH --binary-file PATH --source-files [PATH]
  -h, --help                         This help text.
  -o, --output PATH                  The path to produce the compiled output bundle.
  -t, --target-triple VALUE          Target triple used for build.
  -m, --module-name VALUE            Module name of target.
  -c, --toolchain-dir PATH           Toolchain path used for build.
  -b, --binary-file PATH             Binary file path containing extracted metadata.
  -s, --source-files PATH            Source file paths to produce the compiled output bundle.
  -d, --disable-output-generation    Disable output generation.
  -r, --sdk-root PATH                SDK root file path.
  -p, --dependency-file PATH         Dependency info file path.
  -f, --force                        Force execution - Disregard dependency file.
  -g, --stringsdata-file PATH        stringsdata file path.

https://developer.apple.com/documentation/AppIntents/AppEntity

bazelbuild Slack thread: https://bazelbuild.slack.com/archives/CD3QY5C2X/p1669231881137459

What the tool does can be reproduced simply by using those APIs in an ios_application target, and rules_xcodeproj can be used in a pinch to test this out. My best guess is it seems to be running it against all sources for an Xcode iOS application target.

``` 2022-11-23 13:20:58.761 appintentsmetadataprocessor[62072:29097131] Starting appintentsmetadataprocessor export 2022-11-23 13:21:03.323 appintentsmetadataprocessor[62072:29097131] Writing Metadata.appintents 2022-11-23 13:21:03.324 appintentsmetadataprocessor[62072:29097131] Metadata root: /Users/ekerber/Library/Developer/Xcode/DerivedData/Slack-bvwscvpyghvogxbdfhfsrahbyxcv/Build/Products/Debug-iphonesimulator/bazel-out/applebin_ios-ios_sim_arm64-dbg-ST-efefcef94047/bin/App/Slack.app/Metadata.appintents 2022-11-23 13:21:03.351 appintentsmetadataprocessor[62072:29097131] Writing ExtractedAppShortcutsMetadata.stringsdata file 2022-11-23 13:21:03.352 appintentsmetadataprocessor[62072:29097131] Writing ExtractedParameterSummaryMetadata.stringsdata file ```

The metadata extraction is skipped if an app target does not link AppIntent.framework:

``` ExtractAppIntentsMetadata (in target 'asdf' from project 'asdf') cd /Users/ekerber/Desktop/asdf /Applications/Xcode-14.1.0.app/Contents/Developer/usr/bin/appintentsmetadataprocessor --output /Users/ekerber/Library/Developer/Xcode/DerivedData/asdf-fjjbitzkoyhvpbaepoiqplaybtxv/Build/Products/Debug/asdf.app/Contents/Resources --toolchain-dir /Applications/Xcode-14.1.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain --module-name asdf --source-files /Users/ekerber/Desktop/asdf/asdf/ViewController.swift /Users/ekerber/Desktop/asdf/asdf/AppDelegate.swift --sdk-root /Applications/Xcode-14.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk --target-triple arm64-apple-macos13.0 --binary-file /Users/ekerber/Library/Developer/Xcode/DerivedData/asdf-fjjbitzkoyhvpbaepoiqplaybtxv/Build/Products/Debug/asdf.app/Contents/MacOS/asdf --dependency-file /Users/ekerber/Library/Developer/Xcode/DerivedData/asdf-fjjbitzkoyhvpbaepoiqplaybtxv/Build/Intermediates.noindex/asdf.build/Debug/asdf.build/Objects-normal/arm64/asdf_dependency_info.dat --stringsdata-file /Users/ekerber/Library/Developer/Xcode/DerivedData/asdf-fjjbitzkoyhvpbaepoiqplaybtxv/Build/Intermediates.noindex/asdf.build/Debug/asdf.build/Objects-normal/arm64/ExtractedAppShortcutsMetadata.stringsdata note: Metadata extraction skipped. No AppIntents.framework dependency found. (in target 'asdf' from project 'asdf') ```

Similar prior work: #298

erikkerber commented 1 year ago

Resolved with https://github.com/bazelbuild/rules_apple/commit/fddc4a484761717451ea7466965d78658dc5f118

keith commented 1 year ago

Thats not on main yet, worth tracking here i think