For 25 days in December of 2020, Paul Hudson (@twostraws) tweeted out one Xcode tip per day (At 9:41 PM). Here’s everything I found useful with links to the related tweets.
- To auto-generate a memberwise initializer for a class, highlight the class name in the code, then go to Editor > Refactor > Generate Memberwise Initializer. Tweet Link
- While your app is running, you can click on the controls icon to bring up the Environment Overrides section. Here you can dynamically toggle settings such as dark mode, bold text, and high contrast mode. You can also toggle between light and dark mode in the simulator with the shortcut Shift + Cmd + A Tweet Link
- You can double click an opening or closing brace to select the entire block of code it contains. Tweet Link
- You can toggle Spell Check in the menu under Edit > Format > Spelling and Grammar > Check Spelling While Typing. Tweet Link
- You can batch fix all issues with Editor > Fix All Issues. Tweet Link
- When using Xcode’s Find Navigator (Shift + Cmd + F) and going through found instances, you can use the delete key to remove that instance from the list, which narrows down your found instances. Tweet Link
- Use the shortcut Option + Cmd + P to resume the preview. You can also use Option + Cmd + Return to hide and show the preview window. Tweet Link
- To split the screen between the simulator and Xcode, with the simulator active go to Window > Tile Window to Right of Screen. Tweet Link
- You can resize the window that pops up while Xcode tries to autocomplete by dragging the side of the window. Tweet Link
- To create a debugging breakpoint on the line your cursor is on, use the shortcut Cmd + \ or just click on the line number. You can remove a breakpoint by just dragging it off of the line numbers. Tweet Link
- To run your tests in a different order every time go to Product (Hold down Option) > Test. On the Info tab, click Options then check Randomize Execution Order. Tweet Link
- To navigate within a file quickly use the breadcrumbs at the top of the file. You can start typing to filter out the list that appears sort of like a mini-find menu. Tweet Link
- To get a quick overview of a file use Cmd + Ctl + Up. This will create a list of properties, method names, comments, and such. Press the shortcut again and you’ll get an overview of all the tests in a file. Tweet Link
- To create a documentation comment use Option + Cmd + / right above any method. Tweet Link
- To sort files within folders in the sidebar, right-click on any file group and choose “Sort By Name” to arrange them A-Z. Tweet Link
- To use source control in Xcode make sure you select the checkbox “Create Git repository on my Mac” when creating a new project or go to Source Control > New Git Repositories to create one in an existing project. Then go to Xcode > Preferences, click the Source Control Tab and make sure the “Show Source Control changes” checkbox is checked. Revision to lines will be shown beside the line numbers in blue tabs. Click them to view previous versions of that line. Tweet Link
- You can turn on the minimap by going to Editor > Minimap. Hover over the minimap and hold Cmd to reveal all the methods within the file. Tweet Link
- To re-run the previous test use the shortcut Ctrl + Cmd + Option + g. Tweet Link
- To set your own keyboard shortcuts go to Xcode > Preferences > Key Bindings tab. Tweet Link
- In Xcode’s “Find” menu you can click on each of breadcrumb-like texts (Find > Text > Containing) to bring up more options. You can also click on the search icon to see your recent searches. Tweet Link
- To properly indent pasted or copied code, select the code block and use the shortcut Cmd + I to properly indent it. Tweet Link
- You can test in-app purchases without App Store Connect. Make a new StoreKit Config File, and add your IAP. Now go to the Product menu, hold down Option, and click Run. From the Options tab of the window, change StoreKit Config, and now you’ll use the test IAP. Tweet Link
- To get documentation on any of the build settings Hold Option and double a setting to bring up a dialog with more information. You can also view this by having a build option selected and clicking on the question mark icon(Quick help inspector) in the right sidebar. Tweet Link
- You can pin previews to the Preview pane using the pin icon in the lower left. This will ensure that the preview remains in the pane even when switching to another View in the navigator. Tweet Link
@joekotlan on X