TL;DR

I use Xcode every day, but I know nothing about Xcode. In this article, I will explore what indexing is and how it works. At the end of the article, I have written a simple command-line tool to query the information stored in indexing DataStore.

Image for post

Summary

1\. Xcode Indexing
  1.1\. What indexing is

2\. How indexing work
  2.1\. Unit file and record file
  2.2\. Using IndexStore to query DataStore
  2.3\. Xcode Indexing Log
3\. Extend Reading

Xcode Indexing

What indexing is

Indexing support a range of IDE features like code navigation, syntax highlighting, code auto-completion, jump-to-definition, find usages, refactor. You use these features every day as an iOS developer.

Image for post

How indexing works

When Xcode loads a project that hasn’t been build, it will start indexing the project.

Image for post

Image for post

Activity monitor is a handy tool to help you find out the running processes, the Xcode and SKAgent pop up from the list after I open the project.

Image for post

So, the question is what **SKAgent is? **The SKAgent is the component of SourceKit framework runs the compilation commands to generate the indexing information. The SKAgent executable binary locates at /Applications/Xcode.app/Contents/SharedFrameworks/SourceKit.framework/Versions/A/XPCServices/com.apple.dt.SKAgent.xpc/Contents/MacOS/com.apple.dt.SKAgent

Image for post

The SKAgent is a XPC Service operated by SourceKit uses the XPCmechanism to communicate with Xcode.

Image for post

#ios #indexing #clang #xcode

Uncovering Xcode Indexing
3.30 GEEK