Skip to content

Commit 729209c

Browse files
committed
Update project for Xcode 12
Also revised the documentation.
1 parent b1bf98d commit 729209c

File tree

4 files changed

+55
-50
lines changed

4 files changed

+55
-50
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ The MIT License
22

33
SetupXcodeDerivedDataRamDisk
44

5-
Copyright (c) 2017 ikiApps LLC
5+
Copyright (c) 2020 ikiApps LLC
66

77
Permission is hereby granted, free of charge, to any person obtaining a copy
88
of this software and associated documentation files (the "Software"), to deal

README.md

+21-19
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
# Get the Fastest Build Times in Xcode
22

3-
Instead of having Xcode’s Derived Data be based in a spinning disk or solid-state drive, moving it to a RAM disk can make the performance of Xcode build operations *as fast as possible* and make it so that your Derived Data content is continually freshened.
3+
Instead of having Xcode’s Derived Data based in a spinning disk or solid-state drive, move it to a RAM disk. Then, the performance of Xcode build operations run *as fast as possible.* A side benefit is the contents do not persist across reboots and, therefore, do not accumulate excessively.
44

5-
I’ve crafted a script in Swift to perform the necessary configuration. I start the script in a launch agent that runs at startup so that my RAM disk is always available. Returning to a standard Xcode configuration simply requires ejecting the RAM disk.
5+
I have crafted a script in Swift to perform the necessary configuration for you. It can automatically start using a launch agent at startup, so the RAM disk is always available. Returning to a standard Xcode configuration requires ejecting the RAM disk.
66

7-
The reason this works is because the RAM disk is mounted to the default path for the DerivedData folder that Xcode uses. You can verify this path in Xcode under Locations in Preferences.
7+
It works because the RAM disk mounts to the default path for the DerivedData folder that Xcode uses. You can verify this path in Xcode under Locations in Preferences. The RAM disk gets used by command-line builds and is thereby compatible with alternative IDEs such as AppCode.
88

99
## Installation
1010

11-
The install path is defined in the build settings under `INSTALL_DIR`. This is where the binary product will be copied every time the project is built. A default path of `$(HOME)/bin` has been set. This value is set by two settings in Xcode's build settings: `INSTALL_ROOT` and `INSTALL_PATH`.
11+
Define the install path in the build settings under `INSTALL_DIR`. The binary product is copied to this location when building the project. A default path of `$(HOME)/bin` is set. Configuration of this value is by two settings in Xcode's build settings: `INSTALL_ROOT` and `INSTALL_PATH`.
1212

13-
**Therefore, the following steps should be completed to build and install the compiled version of the script.**
13+
**Complete the following steps to build and install the compiled version of the script.**
1414

1515
* If needed, change the size of `RAMDISK_GB` in `main.swift`
16-
* If needed, change the install path under Targets > SetupXcodeDerivedDataRamDisk > Build Settings > Installation Build Products Location + Installation Directory
16+
* If needed, change the install path under Targets > SetupXcodeDerivedDataRamDisk > Build Settings > Installation Build Products Location + Installation Directory
1717
* Build the project in Xcode
1818

1919
## Alternative installation
2020

21-
Copy `main.swift` to a local path of your choosing such as
21+
Copy `main.swift` to a local path of your choosing, such as
2222

23-
~/bin/setupXcodeDerivedDataRAMDisk.swift
24-
25-
Make it executable using `chmod +x ~/bin/setupXcodeDerivedDataRAMDisk.swift`.
23+
~/bin/setupXcodeDerivedDataRAMDisk.swift
24+
25+
Make it executable with
26+
27+
chmod +x ~/bin/setupXcodeDerivedDataRAMDisk.swift
2628

2729
## Run at startup
2830

29-
Create a file with the following content. **Edit it so that it fits your system. Replace ${INSERT_YOUR_USERNAME} with your username. Add `.swift` to the filename if using the text-based script.**
31+
Create a file with the following content. **Edit it to fit your system. Replace ${INSERT_YOUR_USERNAME} with your username. Add `.swift` to the filename if using the text-based script.**
3032

3133
<?xml version=1.0 encoding=UTF-8?>
3234
<!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
@@ -46,14 +48,14 @@ Create a file with the following content. **Edit it so that it fits your system.
4648
</dict>
4749
</plist>
4850

49-
Give it a name like `com.ikiApps.setupXcodeDerivedDataRamDisk.plist` and copy it to
51+
Give it a name, for example, `com.ikiApps.setupXcodeDerivedDataRamDisk.plist`, and copy it to
52+
53+
~/Library/LaunchAgents
54+
55+
User readable is the minimum permission for the property list. That corresponds to a permission value of 0400 for chmod.
5056

51-
~/Library/LaunchAgents
52-
53-
The minimum permission for this property list launch agent file is that it is readable by you. That corresponds to a permission value of 0400 in chmod terms.
57+
Make sure Xcode is not running, and manually test starting the agent with the following command:
5458

55-
The agent can be started manually using
59+
launchctl load com.ikiApps.setupXcodeDerivedDataRamDisk.plist
5660

57-
launchctl load com.ikiApps.setupXcodeDerivedDataRamDisk.plist
58-
59-
If everything went well, the script will now run every time you login. You can see the mounted RAM disk in the Finder when it is available. It will also be available in the list of mounts using the `mount` or `df` command.
61+
If everything went well, the script should now run every time you log in. You can see the mounted RAM disk in the Finder when it is available. It will also be available in the list of mounts using the `mount` or `df` command.

SetupXcodeDerivedDataRamDisk.xcodeproj/project.pbxproj

+9-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
isa = PBXProject;
8787
attributes = {
8888
LastSwiftUpdateCheck = 0730;
89-
LastUpgradeCheck = 0930;
89+
LastUpgradeCheck = 1200;
9090
ORGANIZATIONNAME = ikiApps;
9191
TargetAttributes = {
9292
65633CB31CA7AB9F0042FE05 = {
@@ -96,11 +96,11 @@
9696
};
9797
buildConfigurationList = 65633CAF1CA7AB9F0042FE05 /* Build configuration list for PBXProject "SetupXcodeDerivedDataRamDisk" */;
9898
compatibilityVersion = "Xcode 3.2";
99-
developmentRegion = English;
99+
developmentRegion = en;
100100
hasScannedForEncodings = 0;
101101
knownRegions = (
102-
English,
103102
en,
103+
Base,
104104
);
105105
mainGroup = 65633CAB1CA7AB9F0042FE05;
106106
productRefGroup = 65633CB51CA7AB9F0042FE05 /* Products */;
@@ -128,6 +128,7 @@
128128
isa = XCBuildConfiguration;
129129
buildSettings = {
130130
ALWAYS_SEARCH_USER_PATHS = NO;
131+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
131132
CLANG_ANALYZER_NONNULL = YES;
132133
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
133134
CLANG_CXX_LIBRARY = "libc++";
@@ -147,6 +148,7 @@
147148
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
148149
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
149150
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
151+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
150152
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
151153
CLANG_WARN_STRICT_PROTOTYPES = YES;
152154
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -184,6 +186,7 @@
184186
isa = XCBuildConfiguration;
185187
buildSettings = {
186188
ALWAYS_SEARCH_USER_PATHS = NO;
189+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
187190
CLANG_ANALYZER_NONNULL = YES;
188191
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
189192
CLANG_CXX_LIBRARY = "libc++";
@@ -203,6 +206,7 @@
203206
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
204207
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
205208
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
209+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
206210
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
207211
CLANG_WARN_STRICT_PROTOTYPES = YES;
208212
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -232,6 +236,7 @@
232236
65633CBC1CA7AB9F0042FE05 /* Debug */ = {
233237
isa = XCBuildConfiguration;
234238
buildSettings = {
239+
CODE_SIGN_IDENTITY = "-";
235240
DEPLOYMENT_LOCATION = YES;
236241
DSTROOT = "$(HOME)";
237242
INSTALL_PATH = /bin;
@@ -244,6 +249,7 @@
244249
65633CBD1CA7AB9F0042FE05 /* Release */ = {
245250
isa = XCBuildConfiguration;
246251
buildSettings = {
252+
CODE_SIGN_IDENTITY = "-";
247253
DEPLOYMENT_LOCATION = YES;
248254
DSTROOT = "$(HOME)";
249255
INSTALL_PATH = /bin;

SetupXcodeDerivedDataRamDisk/main.swift

+24-27
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env xcrun swift
22

3-
// SetupXcodeDerivedDataRamDisk 2.3.0
3+
// SetupXcodeDerivedDataRamDisk 2.3.1
44
//
5-
// Copyright (c) 2019 ikiApps LLC.
5+
// Copyright (c) 2020 ikiApps LLC.
66
//
77
// Permission is hereby granted, free of charge, to any person obtaining a copy
88
// of this software and associated documentation files (the "Software"), to deal
@@ -25,40 +25,35 @@
2525
import Foundation
2626

2727
/**
28-
Create a Derived Data RAM disk for use by Xcode.
29-
The regex matching is designed for English language systems.
30-
Tested with macOS 10.14.3 (Mojave), Xcode 10.2 and Swift 5.0.
28+
Create a Derived Data RAM disk for use by Xcode.
29+
The regular expression matching is for English language systems.
30+
This script got tested with macOS 10.15.7 (Catalina), Xcode 12.01, and Swift 5.3.
3131

32-
The disk is mounted into the default path for Xcode's Derived Data path and will
33-
be used automatically by Xcode if the path is corresponds to the one set in
34-
Xcode's preferences.
32+
The disk is mounted into the default path for Xcode's Derived Data path and will be used
33+
automatically by Xcode if it corresponds to the one set in Xcode's preferences.
3534

36-
The console app, built in Xcode, can be added as a startup agent inside
37-
~/Library/LaunchAgents. The raw script itself can also be made executable like a
38-
shell script.
35+
The console app, built with Xcode, can be added as a startup agent inside `~/Library/LaunchAgents`.
36+
The raw script itself can also be made executable like a shell script.
3937

40-
The path below refers to a bin directory contained in your home directory.
41-
This folder needs to be created if it does not already exist.
38+
The path below refers to a bin directory contained in your home directory.
39+
Create this folder if it does not already exist.
4240

43-
The console app or script copied into that directory will need to have execute
44-
(+x) permissions. The property list inside LaunchAgents only requires read (+r)
45-
permissions to work. It is sufficient to simply copy the property list into the
46-
LaunchAgents directory. The directory itself will have to be created if it does
47-
not already exist.
41+
The console app or script copied into that directory needs execute (+x) permissions. The property
42+
list inside LaunchAgents only requires read (+r) permissions to work. It is sufficient to copy the
43+
property list into the LaunchAgents directory. Create the directory if it does not already exist.
4844

49-
Here is the content of an example property list (plist) that will have the RAM
50-
disk created at startup.
45+
Here is the content of an example property list (plist) that will have the RAM disk created at startup.
5146

52-
** REMEMBER TO CHANGE THE USERNAME BELOW TO MATCH YOUR USERNAME. **
47+
** REMEMBER TO CHANGE THE USERNAME BELOW TO MATCH YOUR USERNAME. **
5348

54-
filename: com.ikiapps.setupXcodeDerivedDataRamDisk.plist
49+
Example filename: com.ikiApps.setupXcodeDerivedDataRamDisk.plist
5550
-------------------------------------------------------------------
5651
<?xml version=1.0 encoding=UTF-8?>
5752
<!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
5853
<plist version=1.0>
5954
<dict>
6055
<key>Label</key>
61-
<string>com.ikiapps.setupXcodeDerivedDataRamDisk.plist</string>
56+
<string>com.ikiApps.setupXcodeDerivedDataRamDisk.plist</string>
6257
<key>ProgramArguments</key>
6358
<array>
6459
<string>/usr/bin/xcrun</string>
@@ -72,14 +67,15 @@ filename: com.ikiapps.setupXcodeDerivedDataRamDisk.plist
7267
</plist>
7368
-------------------------------------------------------------------
7469

75-
The launch agent can be tested with:
70+
Manually test the launch agent with:
7671

77-
launchctl load ~/Library/LaunchAgents/com.ikiapps.setupXcodeDerivedDataRamDisk.plist
72+
launchctl load ~/Library/LaunchAgents/com.ikiApps.setupXcodeDerivedDataRamDisk.plist
7873

7974
*/
8075

8176
/// File systems:
82-
enum FileSystemType {
77+
enum FileSystemType
78+
{
8379
case apfs
8480
case hfsPlus
8581
}
@@ -92,7 +88,8 @@ let encoding: String.Encoding = .utf8
9288
let fileSystem = FileSystemType.apfs
9389

9490
/// Error cases:
95-
enum RamDiskSetupError: Error {
91+
enum RamDiskSetupError: Error
92+
{
9693
case taskFailed
9794
}
9895

0 commit comments

Comments
 (0)