Siri IntentHandler import syntax

Using Xcode 10b5, I finally figured out how to find the auto-generated source code for the Intents.intentdefinition file for a custom intent. However, said source is deeply buried inside Xcode folders. Specifically, this is the directory that Xcode points to if you click the right arrow from the inspector:


/Library/Developer/Xcode/DerivedData/MyApp-[...]/Build/Intermediates.noindex/MyApp.build/Debug-iphonesimulator/MyFramework.build/DerivedSources/IntentDefinitionGenerated/Intents/MyIntent.h


So, I've tried a crazy number of syntax variations for the #import on that. Things like:


#import <MyFramework/MyIntent.h>

#import "MyIntent.h"

---many other variations---


Nothing working. I'm about ready to give up and just copy/paste the header into my code. Surely there is a "proper" way to import this auto-generated header as that would be the whole point of auto-generating it?

Answered by jonprescott in 324877022

There are the DERIVED_FILES_DIR and DERIVED_FILE_DIR (both point to same place) environment variables that should point to the directory containing MyIntent.h. If you add $(DERIVED_FILES_DIR) to your "User Header search path" build setting, you can use #include "MyIntent.h". Or, if you add the file path to your "Header Search Paths" build setting, you can use <MyIntent.h>.


This must be a bug in Xcode 10 beta. I'm using Xcode 9 with flex and bison to build lexers and parsers from specification files using a Run Script phase to run the flexc++ and bisonc++ tools (third-party C++ based lexer and parser). Specifying the input and output file specifications in the Run Script phase specification does the right thing, and the compilers pick them up with no trouble. Might be worth a bug report on Xcode 10 beta.


If you want to see the environment variables and their contents for your project, add a dummy Run Script phase that does nothing. Make sure the "show environment variables" checkbox is checked, then build your project. If you go to the Build Log, and expand the results of the Run Script step, you should see the environment variables and their definitions.

Accepted Answer

There are the DERIVED_FILES_DIR and DERIVED_FILE_DIR (both point to same place) environment variables that should point to the directory containing MyIntent.h. If you add $(DERIVED_FILES_DIR) to your "User Header search path" build setting, you can use #include "MyIntent.h". Or, if you add the file path to your "Header Search Paths" build setting, you can use <MyIntent.h>.


This must be a bug in Xcode 10 beta. I'm using Xcode 9 with flex and bison to build lexers and parsers from specification files using a Run Script phase to run the flexc++ and bisonc++ tools (third-party C++ based lexer and parser). Specifying the input and output file specifications in the Run Script phase specification does the right thing, and the compilers pick them up with no trouble. Might be worth a bug report on Xcode 10 beta.


If you want to see the environment variables and their contents for your project, add a dummy Run Script phase that does nothing. Make sure the "show environment variables" checkbox is checked, then build your project. If you go to the Build Log, and expand the results of the Run Script step, you should see the environment variables and their definitions.

Siri IntentHandler import syntax
 
 
Q