Check out aiproxy.pro

Xcode phantom errors

Clear derived data (located at ~/Library/Developer/Xcode/DerivedData)
AND remove MyApp.xcodeproj/project.xcworkspace

Refresh SPM packages after clearing derived data

After clearing derived data, the package dependencies in my Xcode project tree are always red.
In Xcode, go to:

File > Packages > Reset Package Caches  

credit: https://www.reddit.com/r/iOSProgramming/comments/wut32p/comment/ilcjsnq

Try this to improve debugger times

See if it improves debugger times

How to view symbolicated crash reports

Crash reports are now in Xcode Organizer at Window > Organizer

Open an Xcode project from shell

cd ~/dev/my-proj  
xed .  

(xcode, add local development package)

Add a SPM package to a sample project, while allowing the package to be edited:

Go to File > Add Package Dependencies  
Press the “Add local” button at the button of the window  
Choose the folder containing the package  

Source: https://forums.swift.org/t/how-to-add-local-swift-package-as-dependency/26457/48

(xcode, add or remove swift package)

(xcode, instruments, time profiler)

Long press the Play button, select Profile (or use cmd+i), select Time Profiler, tap the record button

(xcode, lldb, debugger, view image)

It’s helpful to view intermediate images when debugging image transformation code.

- Encounter a breakpoint in transformation code
- Tap the ‘Show variables view’ button in bottom right of debug area
- Highlight the image variable
- Press spacebar

(xcode, more shortcuts)

Returning to Apple work. Refresher:

Reveal file in project tree cmd+shift+j
Toggle project drawer cmd+0
Toggle inspector drawer cmd+opt+0
Toggle console and debug panel cmd+shift+y
Navigate between headings in project drawer cmd+1 through cmd+9
Go back cmd+ctrl+left-arrow
Go forward cmd+ctrl+right-arrow
Go to compilation errors cmd+5
Browse symbols in currenct file ctrl+6
Fuzzy file search cmd+shift+o
Show autocomplete suggestions ctrl+space
Run cmd+r
Stop cmd+.
Format code (indent, reindent, format) ctrl+i
Indent code cmd+]
Deindent code cmd+[
Format single line into multi ctrl+m
Interface builder quick add cmd+shift+l
Interface builder toggle inspect panel cmd+opt+0
Simulator switch to dark mode cmd+shift+a
Refresh SwiftUI preview cmd+opt+p
Multiple cursors (adjacent) cmd+shift+down-arrow
Multiple cursors (adjacent) opt mouse-drag
Multiple cursors (non-adjacent) ctrl+shift mouse-click
Edit scheme cmd+shift+comma
Show single editor pane cmd+shift+ctrl+enter
Create docstring (cursor on fn signature) cmd+opt+/
Open ‘quick actions’ in editor cmd+shift+a
Set breakpoint cmd+\
Go to line cmd+l

Edits to a fresh Xcode install:

Settings > Editing > Uncheck suggest completions while typing  
                   > Uncheck use escape key to show completion suggestions  
                   > Check 'Automatically trim trailing whitespace'  
                   > Check 'Including whitespace-only lines'  
Settings > Behaviors > Running > Generates Output > Uncheck 'Show debugger'  


(xcode, simulator location, simulator disk location)

~/Library/Developer/Xcode/iOS DeviceSupport  

Source: https://stackoverflow.com/a/57929678/143447

(xcode, simulators, erase all, start over, simulator reset)

In shell:

xcrun simctl shutdown all && xcrun simctl erase all  

(xcode, build directory, change derived data location)

File > Project Settings > Derived Data > Project-relative Location > Enter “Build”


(xcode, swiftui preview, toggle, turn off preview)

Toggle preview: cmd+opt+enter
Refresh preview: cmd+opt+p
Show editor only: cmd+enter

(xcode, new xcode setup)

Initial setup:

sudo xcode-select -switch /Applications/Xcode6-Beta5.app  

Preferences > Text Editing:  
        Automatically trim trailing whitespace  
        Including whitespace-only lines  
        Suggest completions while typing  

Preferences > General:  
        Show live issues  

Preferences > Key Bindings:  
    Show completions: ctrl+n  // (autocomplete, suggestions)  

Edit > Format > Spelling and Grammar > Uncheck 'Check spelling while typing'  


(xcode, turn off noisy logs, ios simulator, simulator logs)

xcrun simctl spawn booted log config --subsystem com.apple.CoreTelephony --mode level:off  
xcrun simctl spawn booted log config --subsystem com.apple.boringssl --mode level:off  
xcrun simctl openurl booted "https://www.example.com/content?id=2"  
simctl openurl myapp://  

(xcode, view debugger, lldb)

Right click on a view and “Print description”. Then use lldb with the address:

expr ((UILabel *)0x7f8ff9d102e0).text = @"Hi"  
po ((UILabel *)0x7f8ff9d102e0).text  


(lldb) expr UILabel *$label = (id)0x7f8ff9d102e0  
(lldb) po $label.text  

After using expr to change a property of the view, I can use CATransaction.flush() instead of continuing within debugger to see updates.

It’s possible to use swift too, but obj-c is better for this:

(lldb) expr let $label = unsafeBitCast(0x7f8ff9d102e0, to: UILabel.self)  

Put this in ~/.lldbinit

command regex let s/(.+): (.+) = (0x[[:xdigit:]]+)/expr let $%1 = unsafeBitCast(%3, to: %2.self)/  


(lldb) let label: UILabel = 0x7f8ff9d102e0  
(lldb) po $label  

(xcode, mute simulator, turn iOS simulator volume down)

cmd+down_arrow repeatedly

(xcode, create docstring template, create comment block)

Put cursor in method signature, then opt+cmd+/

(xcode, show indexing progress, show files indexed)

Turn this on to see how far along Xcode’s file indexer is:

defaults write com.apple.dt.Xcode IDEIndexerActivityShowNumericProgress -bool true  

(xcode, show compilation time)

Turn this on to see the amount of time each build takes:

defaults write com.apple.dt.Xcode ShowBuildOperationDuration -bool YES  

(xcode, time profile)

Add to “other swift flags” to debug long compilation times:

-Xfrontend -debug-time-function-bodies  
-Xfrontend -warn-long-function-bodies=100  

(xcode, open symbol split plane, assistant editor)


(xcode, run without building)


(xcode, index, turn off indexing, xcode, defaults)

defaults write com.apple.dt.XCode “IDEIndexDisable” 1

(xcode, device logs, ios logs, xcode, crash log)

Window > Devices and Simulators (or Cmd+Shift+2)
Tap on connected device.
:: Scroll up in main pane
Tap on the “View Device Logs” button

(xcode, go to next issue)


(xcode, shortcut change)

Keybindings > All > “show completion list” set to ctrl+n

(xcode, rename project, perl rename, destructive, sed)

This is how I rename a full project in Xcode.
Check source into version control before attempting.
In this example, I’m renaming the Xcode project ‘RenameMe’ to ‘GreatProject’:

rename s/RenameMe/GreatProject/ ./*  
rename s/RenameMe/GreatProject/ ./GreatProject/*  
find * -type f | LC_CTYPE=C xargs -I {} sed -i '' 's/RenameMe/GreatProject/g' '{}'  


(xcode, vertical split, window, split, xcode, stack horizontally)

View > Assistant Editor > Stack all views horizontally

(xcode, error about briding header, not able to find bridging header)

Quit and restart workspace

(xcode, enable writing comments, you’re shitting me)

Punch this into shell:

sudo /usr/libexec/xpccachectl --verbose  

(xcode, git, warnings, “missing from working copy”)

Disable Xcode’s management of version control. Manage it myself:

Xcode > Preferences > Source Control > Disable source control  

(xcode, extraneous logs, log xcode, system, nw_socket_set_common_sockopts)

Go to Edit Scheme > Run > Arguments > Environment Variables and add:

Name:OS_ACTIVITY_MODE value:disable  

(xcode, playground, disable automatic execution)

Tap and hold the play button in the bottom right corner of the editor pane,
an option will display to manually run.

Next, bind the “Execute Playground” menu item to cmd+p, (this will disable print, which I don’t need anyway)
Now run the playground with cmd+p


(xcode, provisioning location, provisioning profile)

~/Library/MobileDevice/Provisioning Profiles
Xcode > Preferences > Accounts > View Details

(xcode shortcut, jump to issue, jump and fix issue)

cmd+' or cmd+ctrl+'

(xcode, shrink window, window half size, xcode window size)

Xcode normally refuses to shrink to half my screen’s width.
I use spectacle to snap windows to half the screen, but Xcode gives me problems.
The trick is to turn off Xcode’s toolbar! Then it happily snaps to half the screen:
Go to View > Hide Toolbar

(xcode, swift interface, header)

If Xcode is showing declarations instead of full definitions,
go to Navigate > Jump to Original Source

(xcode, show help shortcut)

Then start typing for fuzzy search (for example, try ‘interface’)

(xcode, behavior, do nothing special when program creates output)

Behaviors > Running > Generates Output, uncheck “show project navigator”


(xcode shortcuts)

Edit scheme: cmd+shift+,
Open documentation: cmd+shift+0
Format code (indent, reindent, format): ctrl+i
Toggle project navigator: cmd+0
Stop build, stop running: cmd+.
Autocomplete: ctrl+n (I change this from the default of ctrl+space)
Hide issues and message bubbles: cmd+ctrl+m (this stopped working at some point)

(xcode, using xcodebuild, run app)

Run app on simulator:

xcodebuild -configuration Debug -sdk iphonesimulator -workspace <workspace-name>.xcworkspace -scheme <scheme-name> -destination platform='iOS Simulator',OS=7.0.3,name='iPhone 5s'  

List schemes:

xcodebuild -configuration Debug -sdk iphonesimulator -workspace Turtle4.xcworkspace -list  

(xcode, switch command line tools version)

Modify the location at Xcode > Preferences > Locations > Command Line Tools


(xcode, switch debugger back to gdb)

  1. Cmd+opt+R
  2. Switch “debugger” to GDB
    Source: http://stackoverflow.com/a/9925360/143447


(xcode, toggle editor)

Toggle between editor and assistant with cmd+enter and cmd+opt+enter

(xcode, hack, version hacking)

To get a device with a more recent SDK on it than is compatible with current Xcode version, get the latest Xcode dmg and copy these directories:

/Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs$ sudo cp -Rf iPhoneSimulator5.1.sdk /Xcode4/Platforms/iPhoneSimulator.platform/Developer/SDKs/  

/Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs$ sudo cp -Rf iPhoneOS5.1.sdk /Xcode4/Platforms/iPhoneOS.platform/Developer/SDKs/  

/Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport$ sudo cp -vRf 5.1\ \(9B176\) /Xcode4/Platforms/iPhoneOS.platform/DeviceSupport/  

Source: http://stackoverflow.com/questions/9649313/is-there-a-way-to-downgrade-from-ios-5-1-to-ios-5-0

(xcode3, template project)

Copy an existing template to start.

Mac templates are here:
/Developer/Library/Xcode/Project Templates/Application

iPhone templates are here:
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Library

Create my own template at:
~/Library/Application Support/Developer/Shared/Xcode/Project Templates/

(xcode, debugging, create global breakpoint)

Punch cmd+8 and then tap the little plus sign at the bottom, and tap “add symbolic breakpoint”:

symbol: objc_exception_throw  
Module: libobjc.A.dylib  

Then right click it and select Move Breakpoint To > User
When the breakpoint hits, to get the exception message type po $eax


(xcode, replicate results in shell)

Use the /bin/csh shell to replicate commands from the “Build Results” phase.


(xcode, breakpoint on assertion)

Go to the XCode 4 breakpoint navigator.
Click the + button and choose “Add Symbolic Breakpoint”
Set Symbol to:

"-[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]"  

Click “Done”
From: http://stackoverflow.com/questions/6007938/how-to-make-xcode4-stop-at-nsassert-failure

(xcode shortcuts, show header files, show interfaces)

Switch between header files and source with cmd+ctrl+up and cmd+ctrl+down
Navigate back and forwards with cmd+ctrl+left and cmd+ctrl+right

(xcode3, switch xcode versions)

Switching between versions of Xcode:

~$ sudo xcode-select -switch <location-of-xcode1>  
~$ sudo xcode-select -switch <location-of-xcode2>  

(xcode3, sdk location on disk)

iOS SDKs are now in ~/Developer/iPhone*/SDKs

To weak link a framework:

Or add -weak_freamwork UIKit to Other Linker Flags

(xcode3, modifications)


(xcode3, step through assembly)

Go to Run > Debugger Display > Disassembly Only, then use “step into” just like normal.
For instance, put a breakpoint right at NSApplicationMain and start stepping through assembly to see what it does.

(xcode 3, unnecessary undo warning)

Turn off warn before undo:

defaults write com.apple.Xcode XCShowUndoPastSaveWarning NO  

Source: http://borkware.com/quickies/one?topic=xcode

(xcode 3, hide project tree, hide file list)

Hide project tree and file list:

Hide file list:

(xcode 3, split screen vertically)

Hold opt and click the tiny box in the upper right under the lock icon.

(xcode 3, documentation, open class documentation)

opt+double click on a symbol

Rearranging stuff in xcode to match the filesystem is a pain,
I have found this works to move all images to their own directory:

  1. Delete all images in the Resources group and select Move to Trash

  2. Restore everything but the project file:

     git status | awk '{if ($2 == "deleted:") {print $3}}' | xargs git checkout  
  3. Create a new directory on the file system called Images

  4. Move all png files to the images directory

  5. Drag the images directory into Xcode under the Resources group (recursively create groups must be checked)

shift+opt+cmd L/R arrow

(xcode 3, sort files alphabetically)

Select the folder to sort, click on Edit > Sort > By Name

(xcode 3, gripe, file tree out of sync)

Do not drag and drop any file from any “group” into another group, it won’t move on the filesystem and you are left with a project drawer that doesn’t reflect your file structure.

Instead, delete any groups you are about to change in xcode, make the changes on the file system, then go to Add > Existing File and make sure “recursively create groups” is selected.