Skip to content

Commit 82ace11

Browse files
authored
Split sections out to their own files (#42)
1 parent 667e383 commit 82ace11

16 files changed

+470
-455
lines changed

README.md

Lines changed: 15 additions & 455 deletions
Large diffs are not rendered by default.

breakpoints.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[Return to root](README.md)
2+
3+
# Breakpoints
4+
5+
### Use breakpoints as "bookmarks"
6+
7+
> Any time I am exploring or getting familiar with a new codebase in Xcode, especially very large projects, I use disabled breakpoints as “bookmarks” to keep track of where I am, where I have been, and things I want to remember or need to revisit. Sometimes I even do this when debugging issues in codebases that I know well.
8+
9+
Source: [Jesse Squires](https://www.jessesquires.com/blog/2020/01/21/xcode-tip-breakpoints-as-bookmarks/)
10+
11+
### Quickly toggling breakpoints
12+
13+
Use **⌘ \\** to toggle a breakpoint on the current line.
14+
15+
Source: [Paul Hudson](https://www.hackingwithswift.com/articles/229/24-quick-xcode-tips)
16+
17+
### Play sound files in breakpoints
18+
19+
> Audible Xcode breakpoints allow a sound effect to be played while continuing the executable without interruptions. This can be a really useful debugging tool. Custom Xcode breakpoint sound files can be found on GitHub at [Xcode Breakpoint Sounds](https://github.com/matthewreagan/Xcode-Breakpoint-Sounds).
20+
21+
Source: [Matt Reagan](http://mattreagandev.com/?article=20170306)
22+
23+
### Automate user actions with LLDB expressions
24+
25+
When developing a view that requires app navigation to reach, you can use breakpoints to speed up iterations by simulating user actions, instead of modifying or hacking code that you might forget to remove later. Using breakpoints this way instead of adding temporary debug or development code eliminates the possibility of shipping that code by accident.
26+
27+
For example, on a login screen, you can set a breakpoint on `viewDidLoad()`, or `view{Will|Did}Appear()`, then edit the breakpoint to add a Debugger Command action to invoke other methods in the view controller, like a `loginSuccess()` method. Then, set the breakpoint to automatically continue after evaluating the actions. This essentially bypasses login, but only when running the app through Xcode, and only when that breakpoint is enabled.
28+
29+
Another use case: you can pre-populate text fields, make text fields first responders, and change mutable variables at runtime. Once set, enable or disable these breakpoints to simulate different user interaction flows.
30+
31+
Example debugger commands: `expr loginSuccess()`, `expr nameTextField?.text = "Erwin Maza"`, etc.
32+
33+
Source: [Erwin Mazariegos](https://github.com/erwinmaza)

build-times.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[Return to root](README.md)
2+
3+
# Build times
4+
5+
### Measuring build times for type checking
6+
7+
You can use the Swift compiler flags `-warn-long-function-bodies` and `-warn-long-expression-type-checking` to emit warnings for functions or expressions that take longer than a set time to type check. Surfacing these within your projects can help improve and manage type checking times which contribute to overall build times.
8+
9+
Source: [Jesse Squires](https://www.jessesquires.com/blog/2017/09/18/measuring-compile-times-xcode9/)
10+
11+
### Fix slow codesigning
12+
13+
> Poking around, I came across this [thread](https://developer.apple.com/forums/thread/66418). While I didn’t have the main problem described there of duplicate certificates, buried in that thread was the following advice: trim `~/Library/Preferences/com.apple.security.plist`
14+
>
15+
> Opening that file up revealed that I had several entries, all except one pointing to non-existent files with the one valid entry pointing to my login keychain. After removing the invalid entries, code signing only took up to 1 second, max. This shaved 40-60 seconds off of my full release builds and 10 seconds off of incremental ones. Huge savings.
16+
17+
Source: [Paul Kim](https://www.noodlesoft.com/blog/2020/08/24/a-couple-of-random-xcode-tips-to-speed-up-your-builds/)
18+
19+
### Copying framework headers
20+
21+
> Another thing I noticed in the cleanup was that some of my frameworks were being copied without their headers.
22+
> [...]
23+
> Apparently, there’s a hidden setting in your `project.pbxproj` file for copying frameworks where you can specify whether headers get copied over.
24+
25+
The only way to enable/disable this is to edit the `project.pbxproj` by hand. The flag in question is `RemoveHeadersOnCopy`.
26+
27+
Source: [Paul Kim](https://www.noodlesoft.com/blog/2020/08/24/a-couple-of-random-xcode-tips-to-speed-up-your-builds/)

code.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[Return to root](README.md)
2+
3+
# Code
4+
5+
### Generating class initializers
6+
7+
Xcode can generate class initializers. Select your class name, then go to the Editor menu and choose Refactor > Generate Memberwise Initializer.
8+
9+
Source: [Paul Hudson](https://www.hackingwithswift.com/articles/229/24-quick-xcode-tips)
10+
11+
### Selecting blocks of code
12+
13+
You can double click a brace to select the entire block of code it contains.
14+
15+
Source: [Paul Hudson](https://www.hackingwithswift.com/articles/229/24-quick-xcode-tips)
16+
17+
### Apply all fix-its
18+
19+
Go to the Editor menu and choose Fix All Issues (**⌃⌥⌘ F**) to apply fix-its all at once.
20+
21+
Source: [Paul Hudson](https://www.hackingwithswift.com/articles/229/24-quick-xcode-tips)

crashes.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[Return to root](README.md)
2+
3+
# Crashes
4+
5+
### Viewing .crash files
6+
7+
In Xcode’s Organizer, in the Crashes section, you can right-click or ctrl-click on any row and choose Show in Finder. This will reveal a `.crashpoint` file — do a "Show Package Contents" and then dig in further. You will find `.crash` files with the full crash logs, which provide a lot more info than what you see in Organizer.
8+
9+
Source: [Brent Simmons](https://inessential.com/2021/03/16/the_hottest_of_all_xcode_tips)

debugging.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[Return to root](README.md)
2+
3+
# Debugging
4+
5+
### `NSDoubleLocalizedStrings` and Friends
6+
7+
> The `NSDoubleLocalizedStrings` user default is a reasonably well-known and officially documented localization debugging aide. It repeats the text of each localized string, making it double-length so that you can test whether your layout still works.
8+
>
9+
> Another longstanding one is `NSShowNonLocalizedStrings`, which logs to Console when a string can’t be found.
10+
>
11+
> Interface Builder also lets you preview views using an “Accented Pseudolanguage” and a “Bounded String Pseudolanguage.” These correspond to the `NSAccentuateLocalizedStrings` and `NSSurroundLocalizedStrings` user defaults.
12+
>
13+
> Finally, there are `NSForceRightToLeftLocalizedStrings` and `AppleTextDirection` to enable the “Right to Left Pseudolanguage.” This lets you use test right-to-left layout (e.g. for Arabic) using strings from your development language.
14+
15+
Source: [Michael Tsai](https://mjtsai.com/blog/2018/03/27/nsdoublelocalizedstrings-and-friends/)
16+
17+
### Use frame variable in LLDB
18+
19+
> Did you know that most of the time you want to use `v` instead of `po` or `p` in lldb?
20+
>
21+
> This is something that the majority of Swift developers don't realise but `v` is an alias for `frame variable` that was added back in Xcode 10.2, it's a faster and more reliable way to get your info.
22+
23+
Source: [Krzysztof Zabłocki](https://twitter.com/merowing_/status/1392389928844156928)

interface-builder.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[Return to root](README.md)
2+
3+
# Interface Builder
4+
5+
- [Xcode Interface Builder Tips](https://useyourloaf.com/blog/xcode-interface-builder-tips/), Keith Harrison
6+
- [More Interface Builder Tips And Tricks](https://useyourloaf.com/blog/more-interface-builder-tips-and-tricks/), Keith Harrison

keyboard-shortcuts.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
[Return to root](README.md)
2+
3+
# Keyboard Shortcuts
4+
5+
### Cheatsheet
6+
7+
A handy list of Xcode keyboard shortcuts.
8+
9+
Source: [Keith Harrison](https://useyourloaf.com/blog/xcode-keyboard-shortcuts/)
10+
11+
### Jump to a specific line
12+
13+
Open the file you want. Press **⌘L**, type a line number and Xcode will jump directly to that line.
14+
15+
### Re-indenting/Formatting code
16+
17+
Press **⌃I** to apply Xcode's indentation and formatting.
18+
19+
### Adding comments quickly
20+
21+
Use **⌘/** to toggle comments for the current line or selection. Use **⌥⌘/**, pressed directly before a method to have Xcode generate a documentation comment.
22+
23+
Source: [Paul Hudson](https://www.hackingwithswift.com/articles/229/24-quick-xcode-tips)
24+
25+
### Jump to file in source navigator
26+
27+
Press **⌘⇧J** to quickly jump to the current open file in the navigator to easily see and select related files.
28+
29+
Source: [Jeroen Leenarts](https://leenarts.net/2020/02/18/frequently-used-keyboard-shortcuts-i-use-inwith-xcode/)
30+
31+
### Open the jump bar
32+
33+
Press **⌃6** to open the symbol jump bar in Xcode. Now start typing. Try it, jumping to a function in the current file, never has been so easy.
34+
35+
Source: [Jeroen Leenarts](https://leenarts.net/2020/02/18/frequently-used-keyboard-shortcuts-i-use-inwith-xcode/)
36+
37+
### Remapping unhelpful keys
38+
39+
Some great shortcuts (e.g. **⇧⌘O** for Open Quickly) are next to useless shortcuts (**⇧⌘P**, for the never times you want to print code.) It takes only seconds to remove unhelpful keys, and you can even remap things like **⌘P** to resuming SwiftUI's preview.
40+
41+
Source: [Paul Hudson](https://www.hackingwithswift.com/articles/229/24-quick-xcode-tips)
42+
43+
### Increase or decrease editor font size
44+
45+
Press **⌘+** to increase and **⌘-** to decrease.
46+
47+
### Move cursor to the top or bottom of the file
48+
49+
Press **⌘↑** to move to the top of the file. Press **⌘↓** to move to the bottom of the file.
50+
51+
### Show and hide debug area
52+
53+
Press **⌘⇧Y** to open and close the debug area.
54+
55+
### Generating an interface file
56+
57+
Press **⌃⌘⇧** to display a generated interface, showing properties, function signatures, and comments for a type. Press it again, to jump to tests for that file if they exist.
58+
59+
Source: [Paul Hudson](https://www.hackingwithswift.com/articles/229/24-quick-xcode-tips)
60+
61+
### Trigger Custom Behaviors
62+
63+
If you find yourself wasting time continually opening and closing the `Navigator`, `Inspectors`, or the `Preview` when you switch the type of file you're working on, you can define custom `Behaviors` and assign keyboard shortcuts to them.
64+
65+
Xcode Behaviors set the state of the Xcode interface when events occur such as a build starting. Custom Behaviors allow you to define your own triggers.
66+
67+
* Go to `Xcode -> Preferences`
68+
* Open the `Behaviors` tab
69+
* Click `+` at the bottom of the list and name the new Behavior (E.g. `IB File`, `Code File`, `SwiftUI File`)
70+
* On the right side, set the state of the `Navigator`, `Inspectors`, `Preview` or other elements
71+
* Assign a keyboard shortcut next to each name
72+
73+
Now you can quickly set the state of your panels to focus on the type of work you're doing.
74+
75+
Source: [Erwin Mazariegos](https://github.com/erwinmaza)
76+
77+
### Open Human Interface Guidelines
78+
79+
Press **⌘⇧H** to open the Human Interface Guidelines in your web browser.
80+
81+
### Show/hide the preview canvas
82+
83+
It takes up a lot of space, you can quickly toggle it.
84+
85+
> **⌘ ⌃ ↵**
86+
> `Editor menu > Canvas`
87+
88+
Source: [Sarun Wongpatcharapakorn](https://sarunw.com/posts/xcode-shortcuts-for-swiftui/)
89+
90+
### Refresh Preview Canvas
91+
92+
If you type too fast Xcode can stop updating the preview, so you may have to trigger a refresh.
93+
94+
> **⌘ ⌥ P**
95+
> `Editor menu > Canvas > Refresh Canvas`
96+
97+
This will refresh your preview and start automatically updating again.
98+
99+
Source: [Sarun Wongpatcharapakorn](https://sarunw.com/posts/xcode-shortcuts-for-swiftui/)
100+
101+
### Move line of code up or down
102+
103+
You can use a keyboard shortcut to move a line of code up or down, which can be useful for re-ordering things. This can be the current line or you can select multiple lines to move together.
104+
105+
To move line of code up:
106+
107+
> **⌘ ⌥ \[**
108+
> `Editor menu > Structure > Move Line Up`
109+
110+
To move line of code down:
111+
112+
> **⌘ ⌥ \]**
113+
> `Editor menu > Structure > Move Line Down`
114+
115+
Source: [Sarun Wongpatcharapakorn](https://sarunw.com/posts/xcode-shortcuts-for-swiftui/)

refactoring.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Return to root](README.md)
2+
3+
# Refactoring
4+
5+
### Faster Xcode Rename Refactoring
6+
7+
If you use the rename refactoring in Xcode a lot, you can save some time by skipping the code folding animation:
8+
9+
```bash
10+
defaults write com.apple.dt.Xcode CodeFoldingAnimationSpeed -int 0
11+
```
12+
13+
Source: [Daniel Martín](https://twitter.com/dmartincy/status/1173289543124029440) (via [Michael Tsai](https://mjtsai.com/blog/2019/09/16/faster-xcode-rename-refactoring/))

search.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[Return to root](README.md)
2+
3+
# Search
4+
5+
### Deleting search results
6+
7+
When you search using Xcode’s find navigator, you can click on individual results and tap Backspace to remove them.
8+
9+
Source: [Paul Hudson](https://www.hackingwithswift.com/articles/229/24-quick-xcode-tips)

0 commit comments

Comments
 (0)