XCode
lastmod 2025-05-16created 2014-01-1142 edits
Xcode is a suite of OS X development tools developed by Apple. Version 3.2 is included with Mac OS X 10.6 but is not installed automatically. Earlier versions of Mac OS X do not support 3.2, so older versions can be downloaded free of charge from Apple Developer Connection.
Xcode's main program is the integrated development environment of the same name. It includes Apple's developer documentation and Interface Builder, which is used to build graphical interfaces.
Xcode includes modified versions of the free software GCC (GCC, apple-darwin9-gcc-4.2.1, apple-darwin9-gcc-4.0.1) and supports C, C++, Fortran, Objective-C, Objective-C++, Java, AppleScript, Python, and Ruby, including various programming models for Cocoa, Carbon, and Java. Third parties provide support for GNU Pascal, Free Pascal, Ada, C#, Perl, Haskell, and D. Xcode uses GDB as its debugger back end.
Categories
- ObjectiveC:DefaultClassTemplate: how to write a basic Objective-C class.
- XCode:iPhone:Basic - basics of iPhone app development.
- Core MIDI - Communicate with MIDI devices such as hardware keyboards and synthesizers.
- Core Audio
- Apple
- iOS
- Objective-C
- xtool - a tool for building and deploying iOS apps without Xcode
License agreement
Install commandline tools
The following error usually occurs after an OS update; in that case, the command above fixes it.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Compile options
Preprocessor-Options
GCC preprocessor directive options used in XCode (based on LLVM GCC 4.2)
- -x objective-c++
- http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Preprocessor-Options.html
- Sets the source language to Objective-C++. (Add it to 'Other C++ Flags'.)
Command Line Tools
To use commands such as compiling from the command line, you must install them separately from the Apple website. If they still don't run properly after installation, enter the command below.
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/
Keyboard shortcut
A list of XCode keyboard shortcuts.
| Key | Brief | Remarks (ko) |
| Common | ||
| Shift + Command + F | Show the find navigator | Switches to the search navigation bar. |
| Shift + Command + O | Open Quickly (File or Symbol) | Opens a dialog for quickly looking up symbols. |
| Control + Command + Up (Down) | Header / Source File switch | Switches between the header and source file. |
| Control + I | Re indent | Readjusts the tabs (indent) of the source code. |
| Control + Command + Left (Right) | Go Back (Go Forward) | Goes back to the previously focused position in the Editor. |
| Debugging | ||
| Command + Y | Deactivate Breakpoints | Disables all breakpoints. |
| Control + Command + Y | Continue (Stop) | Resumes or pauses the program while debugging. |
| F6 | Step Over | Advances the debugging cursor one step. (It does not change the depth of the call stack.) |
| F7 | Step Into | Advances the debugging cursor one step. |
| F8 | Step Out | Exits the current call stack frame. |
Build Path
The default location where build output is stored is as follows.
Marker
A feature that adds marks, similar to #region in C#. Add it to the code as follows.
Debugging
Notes related to debugging.
Memory trace
To trace the memory at the location where an error occurred, do the following.
- Application (app) tab > Edit Scheme... > Run > Arguments > Environment Variables
- NSZombieEnabled : YES
- MallocstackLoggingNoCompact : 1
Once the settings above are done, you can get the address of where the error occurred, as below.
Enter the following command after the (gdb) prompt in the black debug area at the bottom (Shift + Cmd + Y)
or
This lets you find the source code location where the error occurred.
Wireless debugging
After connecting the device via USB, select the following menu:
XCode-Menu-Window-Devices_and_Simulators.png
Select the Connect via network checkbox.
XCode-Devices_and_Simulators.png
Provisioning
- Fixing Xcode No matching provisioning profiles found 1
- Creating iOS certificates and provisioning profiles 2
Troubleshooting
Loading Environment Variables in Xcode
To add environment variables to XCode, add them under User-Defined in Project > Build Settings. Note that you can add CPATH, LIBRARY_PATH, etc. here.
XCode Auto Completion
Error: The app icon set named "AppIcon" did not have any applicable content
You must put a 120x120 image of exactly that size into images.xcassets.
NSPOSIXErrorDomain: Operation not permitted
- (macOS - Error) Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"
- Xcode12, building for iOS Simulator architecture arm64
- Updated to iOS 12.1/Xcode 10.1 and getting a flood of "Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 'Permission denied' errors"
There are the following options.
- Delete the DerivedData folder 3
- Clean the project
- Reinstall Xcode (a lower version that worked well)
- Delete Build Setting > VALID_ARCHS.
Note that if this error occurs in Godot, check whether the TargetFrameworks version in the .csproj file matches the version for the release build.
warning: pointer is missing a nullability type specifier
When the following warning is printed:
<File>: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
To remove the warning, add the -Wno-nullability-completeness option.
Favorite site
XCode usage and terminology
- Stackoverflow: Find method references in Xcode
- Using cpp files (C++) in XCode (Objective-C) (1)
- Making and using wrapper classes for cpp files (C++) (2)
- Cocoa: What is "File's Owner" in a nib?
- iOS: Creating and using a .a Library
- Xcode LLDB debugging techniques