Skip to content

Commit c8312aa

Browse files
committed
Update Xcode integration guide
Resolves #987
1 parent 4722cad commit c8312aa

File tree

7 files changed

+20
-15
lines changed

7 files changed

+20
-15
lines changed

README.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ The guided setup is only intended for introductory purposes. Once you are famili
8282

8383
To get the most from Periphery, it’s important to understand how it works. Periphery first builds your project; it does this to generate the “index store”. The index store contains detailed information about the declarations (class, struct, func, etc.) in your project and their references to other declarations. Using this store, Periphery builds an in-memory graph of the relational structure of your project, supplementing it with additional information obtained by parsing each source file. Next, the graph is mutated to make it more suitable for detecting unused code, e.g., marking your project’s entry points. Finally, the graph is traversed from its roots to identify unreferenced declarations.
8484

85-
> **Tip**
86-
>
85+
> [!TIP]
8786
> The index store only contains information about source files in the build targets compiled during the build phase. If a given class is only referenced in a source file that was not compiled, then Periphery will identify the class as unused. It's important to ensure you build all the targets you expect to contain references. For an Xcode project, this is controlled using the `--schemes` option. For a Swift package, all targets are built automatically.
8887
8988
If your project consists of one or more standalone frameworks that do not also contain some kind of application that consumes their interfaces, you need to tell Periphery to assume that all public declarations are used with the `--retain-public` option.
@@ -125,8 +124,7 @@ class InformalGreeter: Greeter {
125124
}
126125
```
127126

128-
> **Tip**
129-
>
127+
> [!TIP]
130128
> You can ignore all unused parameters from protocols and conforming functions with the `--retain-unused-protocol-func-params` option.
131129
132130
#### Overrides
@@ -363,11 +361,11 @@ The `kind` override allows you to specify a custom kind that will be shown in th
363361

364362
## Xcode Integration
365363

366-
Before setting up Xcode integration, we highly recommend you first get Periphery working in a terminal, as you will be using the same command via Xcode.
364+
Before setting up Xcode integration, first get Periphery working in a terminal, as you will be using the same command via Xcode. Your project may require passing the `-destination` argument to xcodebuild. This can be done by supplying it as an additional argument, e.g. `periphery scan ... -- -destination "generic/platform=iOS Simulator"`.
367365

368366
### Step 1: Create an Aggregate Target
369367

370-
Select your project in the Project Navigator and click the + button at the bottom left of the Targets section. Select **Cross-platform** and choose **Aggregate**. Hit Next.
368+
Select your project in the Project Navigator and click the + button at the bottom left of the Targets section. Select **Other** and choose **Aggregate**. Hit Next.
371369

372370
![Step 1](assets/xcode-integration/1.png)
373371

@@ -381,19 +379,28 @@ In the **Build Phases** section, click the + button to add a new Run Script phas
381379

382380
![Step 3](assets/xcode-integration/3.png)
383381

384-
In the shell script window, enter the Periphery command. Be sure to include the `--format xcode` option.
382+
Copy and paste your Periphery command into the script input.
383+
384+
> [!TIP]
385+
> 1. Include the `--format xcode` option to ensure results are always formatted correctly so that Xcode can parse them.
386+
> 2. Use the absolute path to `periphery`.
385387
386388
![Step 4](assets/xcode-integration/4.png)
387389

388-
### Step 3: Select & Run
390+
### Step 3: Disable User Script Sandboxing
391+
392+
You must disable **User Script Sandboxing** for the Run Script phase. Periphery requires access to your project's index store and source files, which are blocked by Xcode's default sandbox. To disable sandboxing, set the `ENABLE_USER_SCRIPT_SANDBOXING` option to `No` in the Build Settings for the Periphery aggregate target.
393+
394+
![Step 4](assets/xcode-integration/5.png)
395+
396+
### Step 4: Select & Run
389397

390398
You're ready to roll. You should now see the new scheme in the dropdown. Select it and hit run.
391399

392-
> **Tip**
393-
>
400+
> [!TIP]
394401
> If you'd like others on your team to be able to use the scheme, you'll need to mark it as _Shared_. This can be done by selecting _Manage Schemes..._ and selecting the _Shared_ checkbox next to the new scheme. The scheme definition can now be checked into source control.
395402
396-
![Step 5](assets/xcode-integration/5.png)
403+
![Step 5](assets/xcode-integration/6.png)
397404

398405
## Excluding Files
399406

@@ -467,8 +474,7 @@ Periphery can analyze projects using other build systems, though it cannot drive
467474
}
468475
```
469476

470-
> **Tip**
471-
>
477+
> [!TIP]
472478
> Relative paths are assumed to be relative to the current directory.
473479
474480
You can then invoke Periphery as follows:
@@ -477,8 +483,7 @@ You can then invoke Periphery as follows:
477483
periphery scan --generic-project-config config.json
478484
```
479485

480-
> **Tip**
481-
>
486+
> [!TIP]
482487
> Both options support multiple paths.
483488
484489
## Platforms

assets/xcode-integration/1.png

524 KB
Loading

assets/xcode-integration/2.png

521 KB
Loading

assets/xcode-integration/3.png

530 KB
Loading

assets/xcode-integration/4.png

501 KB
Loading

assets/xcode-integration/5.png

828 KB
Loading

assets/xcode-integration/6.png

562 KB
Loading

0 commit comments

Comments
 (0)