This file outlines known issues and possible workarounds when using Qt for Mac OS X. Contact Qt's technical support team if you find additional issues which are not covered here. (See also the document Qt is Mac OS X Native.)
- Qt Could Not Resolve Sdk Path For Mac Os X 10 13 Download
- Qt Could Not Resolve Sdk Path For Mac Os X High Sierra Download
- Qt Could Not Resolve Sdk Path For Mac Os X El Capitan
- Qt Could Not Resolve Sdk Path For Mac Os X Update
- Qt Could Not Resolve Sdk Path For Mac Os X Versions
- Qt Could Not Resolve Sdk Path For Mac Os X 10 12
- Qt Could Not Resolve Sdk Path For Mac Os X 10 11
Type./configure -help to get a list of all available options. Note that you will need to specify -universal if you want to build universal binaries, and also supply a path to the -sdk option if your development machine has a PowerPC CPU. By default, Qt is built as a framework, but you can built it as a set of dynamic libraries (dylibs) by specifying the -no-framework option. QWSMAC is defined when the Mac OS X GUI is present. QTMACUSECOCOA is defined when Qt is built to use the Cocoa framework. If it is not present, then Qt is using Carbon. A additional flag, QOSMAC, is defined as a convenience whenever QOSDARWIN is defined.
GUI Applications
Mac OS X handles most applications as 'bundles'. A bundle is a directory structure that groups related files together (e.g., widgets.app/). GUI applications in particular must be run from a bundle or by using the open(1), because Mac OS X needs the bundle to dispatch events correctly, as well as for accessing the menu bar.
If you are using older versions of GDB you must run with the full path to the executable. Later versions allow you to pass the bundle name on the command line.
Painting
Mac OS X always double buffers the screen so the Qt::WA_PaintOnScreen attribute has no effect. Also it is impossible to paint outside of a paint event so Qt::WA_PaintOutsidePaintEvent has no effect either.
Library Support
Qt libraries as frameworks
By default, Qt is built as a set of frameworks. Frameworks is the Mac OS X 'preferred' way of distributing libraries. There are definite advantages to using them. See Apple's Framework Programming Guide for more information.
In general, this shouldn't be an issue because qmake takes care of the specifics for you. The Framework Programming Guide discusses issues to keep in mind when choosing frameworks over the more typical, dynamic libraries. However, one point to remember is: Frameworks always link with 'release' versions of libraries.
If you actually want to use a debug version of a Qt framework, you must ensure that your application actually loads that debug version. This is often done by using the DYLD_IMAGE_SUFFIX environment variables, but that way often doesn't work so well. Instead, you can temporarily swap your debug and release versions, which is documented in Apple's 'Debugging Magic' technical note.
If you don't want to use frameworks, simply configure Qt with
-no-framework
.Bundle-Based Libraries
If you want to use some dynamic libraries in your Mac OS X application bundle (the application directory), create a subdirectory named 'Frameworks' in the application bundle directory and place your dynamic libraries there. The application will find a dynamic library if it has the install name @executable_path/./Frameworks/libname.dylib.
If you use
qmake
and Makefiles, use the QMAKE_LFLAGS_SONAME
setting:Alternatively, you can modify the install name using the install_name_tool(1) on the command line. See its manpage for more information.
Note that the
DYLD_LIBRARY_PATH
environment variable will override these settings, and any other default paths, such as a lookup of dynamic libraries inside /usr/lib
and similar default locations.Combining Libraries
If you want to build a new dynamic library combining the Qt 4 dynamic libraries, you need to introduce the
ld -r
flag. Then relocation information is stored in the output file, so that this file could be the subject of another ld
run. This is done by setting the -r
flag in the .pro
file, and the LFLAGS
settings.Initialization Order
dyld(1) calls global static initializers in the order they are linked into your application. If a library links against Qt and references globals in Qt (from global initializers in your own library), be sure to link your application against Qt before linking it against the library. Otherwise the result will be undefined because Qt's global initializers have not been called yet.
Compile-Time Flags
Os x version for macbook pro 10 1. The follewing flags are helpful when you want to define Mac OS X specific code:
- Q_OS_DARWIN is defined when Qt detects you are on a Darwin-based system (including the Open Source version)
- Q_WS_MAC is defined when the Mac OS X GUI is present.
- QT_MAC_USE_COCOA is defined when Qt is built to use the Cocoa framework. If it is not present, then Qt is using Carbon.
A additional flag, Q_OS_MAC, is defined as a convenience whenever Q_OS_DARWIN is defined.
If you want to define code for specific versions of Mac OS X, use the availability macros defined in /usr/include/AvailabilityMacros.h.
See QSysInfo for information on runtime version checking.
Mac OS X Native API Access
Accessing the Bundle Path
The Mac OS X application is actually a directory (ending with
.app
). This directory contains sub-directories and files. It may be useful to place items (e.g. plugins, online-documentation, etc.) inside this bundle. You might then want to find out where the bundle resides on the disk. The following code returns the path of the application bundle:Note: When OS X is set to use Japanese, a bug causes this sequence to fail and return an empty string. Therefore, always test the returned string.
For more information about using the CFBundle API, see Apple's Developer Website.
Note: QCoreApplication::applicationDirPath() can be used to determine the path of the binary within the bundle.
Translating the Application Menu and Native Dialogs
The items in the Application Menu will be merged correctly for your localized application, but they will not show up translated until you add a localized resource folder to the application bundle. The main thing you need to do is create a file called locversion.plist. Here is an example for Norwegian:
Now when you run the application with your preferred language set to Norwegian, you should see menu items like 'Avslutt' instead of 'Quit'.
User Interface
Right-Mouse Clicks
If you want to provide right-mouse click support for Mac OS X, use the QContextMenuEvent class. This will map to a context menu event, i.e., a menu that will display a pop-up selection. This is the most common use of right-mouse clicks, and maps to a control-click with the Mac OS X one-button mouse support.
Menu Bar
Qt will automatically detect your menu bars for you and turn them into Mac native menu bars. Fitting this into your existing Qt application will normally be automatic. However, if you have special needs, the Qt implementation currently selects a menu bar by starting at the active window (i.e. QApplication::activeWindow()) and applying the following tests:
- If the window has a QMenuBar, then it is used.
- If the window is modal, then its menu bar is used. If no menu bar is specified, then a default menu bar is used (as documented below).
- If the window has no parent, then the default menu bar is used (as documented below).
These tests are followed all the way up the parent window chain until one of the above rules is satisifed. If all else fails, a default menu bar will be created. Note the default menu bar on Qt is an empty menu bar. However, you can create a different default menu bar by creating a parentless QMenuBar. The first one created will be designated the default menu bar and will be used whenever a default menu bar is needed.
Note that using native menu bars introduces certain limitations on Qt classes. See the list of limitations below for more information about these.
Special Keys
To provide the expected behavior for Qt applications on Mac OS X, the Qt::Meta, Qt::MetaModifier, and Qt::META enum values correspond to the Control keys on the standard Macintosh keyboard, and the Qt::Control, Qt::ControlModifier, and Qt::CTRL enum values correspond to the Command keys.
Limitations
Menu Actions
- Actions in a QMenu with accelerators that have more than one keystroke (QKeySequence) will not display correctly, when the QMenu is translated into a Mac native menu bar. The first key will be displayed. However, the shortcut will still be activated as on all other platforms.
- QMenu objects used in the native menu bar are not able to handle Qt events via the normal event handlers. For Carbon, you will have to install a Carbon event handler on the menu bar in order to receive Carbon events that are similar to showEvent(), hideEvent(), and mouseMoveEvent(). For Cocoa, you will have to install a delegate on the menu itself to be notified of these changes. Alternatively, consider using the QMenu::aboutToShow() and QMenu::aboutToHide() signals to keep track of menu visibility; these provide a solution that should work on all platforms supported by Qt.
Native Widgets
Qt has support for sheets and drawers, represented in the window flags by Qt::Sheet and Qt::Drawer respectiviely. Brushed metal windows can also be created by using the Qt::WA_MacMetalStyle window attribute.
Preparing a Qt application for Mac App Store submission
Changing the location of global Qt settings
By default, global Qt settings are stored in the file com.trolltech.plist, which does not conform with Mac App Store file system usage requirements. Instructions for changing the location can be found in the QSettings documentation.
Storage location paths
If you are using QDesktopServices::storageLocation() to find locations for data or cache files, you should ensure that the application and organization names used by Qt match the values in iTunes Connect. If the values do not match, the paths that storageLocation() returns will not conform with the Mac App Store file system usage requirements. You can set the application and organization names that Qt uses by calling QCoreApplication::setOrganizationName() and QCoreApplication::setApplicationName().
Info.plist and application icon
A custom Info.plist file instead of the qmake-generated one is needed, since the Mac App Store requires some specific keys to be set that are not present in the generated file. See QMAKE_INFO_PLIST for details.
Information about the required Info.plist contents can be found in Apple's Submitting to the Mac App Store document.
You'll also need to provide an icon for your application, as described in Setting the Application Icon on Mac OS X.
Debug symbols
To generate the debug symbol information needed for the Mac App Store submission in a release build, add these settings to your .pro file:
The debug symbols can be extracted with the dsymutil command as follows:
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
How to use Qt Creator for software development on macOS without having to install Xcode
Justification
Qt refuses to install on macOS unless Apple's Xcode is installed beforehand.This is unfortunate because:
- Xcode is huge!
- The full IDE is a 5 GB download, and can occupy 20 GB+ of space on disk.
- Qt doesn't actually need the full IDE.
- Only Xcode's command line utilities are required for macOS application development¹.
- Developers may never actually use Xcode.
- They can program in Qt Creator, like they do in Windows and Linux.
Downloading and installing the command line utilities without Xcode saves time and bandwidth,and means that valuable SSD storage space is kept for better uses.
¹ I believe the full Xcode IDE is required for developing iOS apps with Qt(i.e. apps for iPads and iPhones)but I'm not sure about this as I'm not an iOS developer.
Instructions
Summary
- Install Xcode's Command Line Tools (i.e. not Xcode itself).
- Run in Terminal:
xcode-select --install
- Install Qt using the Online Installer.
- Download links:
- Open Source: https://www.qt.io/download-open-source
- Commercial: https://www.qt.io/download
- The installer will complain that Xcode is not installed.
- Keep clicking 'OK' until the message goes away permanently (after 12 clicks).
- Remember where you installed Qt (default location is
~/Qt
).- If you used a different location then you will need to change subsequent commands accordingly.
- Make sure Qt Creator uses the correct C++ Compiler.
- Launch Qt Creator for the first time from the command line,with the location of the command line tools compilers in
${PATH}
:PATH='$(xcode-select -p)/usr/bin:${PATH}' ~/Qt/Qt Creator.app/Contents/MacOS/Qt Creator
- Go to Qt Creator > Preferences > Build & Run > Kits and select a build kit (e.g.
Desktop Qt 5..
). - Check that both the C compiler and the C++ compiler are:
clang
(notgcc
)- from the Command Line Tools (not the default compilers in
/usr/bin
)
- Close Qt Creator.
- You can launch Qt Creator the normal way in future (e.g. via Spotlight).
- If your Qt version is older than Qt 5.9.2 then you need to update some QMake files.
- Navigate to the directory
~/Qt/<version>/clang_64/mkspecs/features/mac
- Make a backup copy of the following files before replacing them with newer versions from this git commit:
- Replace
sdk.prf
with this newer version. - Replace
default_pre.prf
with this newer version. - Make this change to the file
default_post.prf
:- Find the line
cache(QMAKE_XCODE_VERSION, stash)
- Replace it with
!isEmpty(QMAKE_XCODE_VERSION): cache(QMAKE_XCODE_VERSION, stash)
- Find the line
- Replace
All done!
![Qt Could Not Resolve Sdk Path For Mac Os X Qt Could Not Resolve Sdk Path For Mac Os X](https://upload-images.jianshu.io/upload_images/1155481-d4eceb950ee11e06.png)
Step-by-step
Step 1 - Download & install Xcode's Command Line Tools
Open a Terminal (press Cmd+Space and type 'Terminal') and enter this command:
Press the Return key to execute the command.
Step 2 - Download & install Qt and Qt Creator
Packages are available for MacPorts and Homebrew,but it's usually best to get it straight from the source:
- Open Source: https://www.qt.io/download-open-source
- Commercial: https://www.qt.io/download
https://graphicsenergy689.weebly.com/keyboard-shortcut-for-force-quit-mac-os-x.html. The Online Installer is probably the best option for most people.
Tip: when you run the Online Installer it will prompt you to log in with Qt online credentials,but open-source users can skip this step without entering anything.
At a certain point during the install the following error message will appear:
You need to install Xcode version 5.0.0.Download Xcode from https://developer.apple.com/xcode
Press 'OK' or ESC to dismiss the dialog. It will come back again.Keep pressing 'OK' or ESC and the dialog will eventually go away for good!You have to dismiss the dialog a total of 12 times before you can continue.
![Qt could not resolve sdk path for mac os x 10 11 Qt could not resolve sdk path for mac os x 10 11](/uploads/1/2/6/6/126621513/784129548.png)
Hint: Once Qt is installed you can delete the installer as you won't need it again.If you want to update or remove Qt you have to use the MaintenanceTool in the Qt directory.
Step 3 - Make sure Qt Creator uses the correct C++ Compiler.
Qt Could Not Resolve Sdk Path For Mac Os X 10 13 Download
Run this command in a Terminal windows to find out where Xcode's Command Line Tools are installed:
The result will probably be
/Library/Developer/CommandLineTools
,unless Xcode is installed. Whatever the result,you need to append '/usr/bin' to get something along the lines of:Run Qt Creator once with this location stored in your
${PATH}
environment variable:Qt Could Not Resolve Sdk Path For Mac Os X High Sierra Download
Go to Qt Creator > Preferences > Build & Run > Kits and select a build kit (e.g.
Desktop Qt 5..
).Check that the C and C++ compilers are the ones from the command line tools,not the default compilers in
/usr/bin
.Also check that clang
is used for both compilers, not gcc
.Qt Could Not Resolve Sdk Path For Mac Os X El Capitan
Qt Creator will remember the locations of the compilers,so in future you can launch Qt Creator the normal way via Spotlight.
Step 4 - Update some QMake files (only necessary for Qt versions older than Qt 5.9.2)
The
xcrun
or xcodebuild
utilities can be used to show where Xcode's Command Line Tools are installed,but only xcrun
works when Xcode itself is not installed.Qt 5.9.2 and later
Recent Qt versions use
xcrun
already, so there's nothing left for you to do!Qt 5.9.1 and older
Older Qt versions try to use
xcodebuild
to find out where the utilities are installed.This fails with the following error message unless Xcode is installed:Project ERROR: Could not resolve SDK Path for 'macosx'Error while parsing file
<filename.pro>
. Giving up.You need to tell QMake to use
xcrun
instead.Open a Terminal and change directory to where the QMake files are stored.
Now copy and paste these new commands into the same Terminal windowto create backup copies of some files:
Press the Return key after the final command.
Qt Could Not Resolve Sdk Path For Mac Os X Update
If that all went OK then run these commands to update the files:
You can see the changes made here if you are interested.
Reusing this material
Referencing
Qt Could Not Resolve Sdk Path For Mac Os X Versions
Qt without Xcode how-to by Peter Jonas (shoogle) / CC BY 4.0
Qt Could Not Resolve Sdk Path For Mac Os X 10 12
License
Qt Could Not Resolve Sdk Path For Mac Os X 10 11
This work is licensed under a Creative Commons Attribution 4.0 International License.