Eejin
Eejin

Reputation: 840

Qt cannot load cocoa plugin

I'm trying to compile and run an application on a MacBook using Qt Creator. There are no issues compiling the project, but when I try and run it, it seems to be unable to load a plugin.

Could not load the Qt platform plugin "cocoa" in "" even though it was found.
The application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

This error occurs both when trying to run the application from Qt Creator or via Finder. It seems to only happen when I use the CMake build system (no issues when using QMake), but my existing project that I need to deploy on MacOS uses CMake.

My steps to reproduce are:

I am using:
Qt 5.13.1
macOS Catalina 10.15
Apple Clang 11

I recognize that for final user deployment I will need to use the macqtdeploy tool to copy the Qt libraries to the executable folder, but I should be able to run my app from QtCreator without doing this? Especially as it works fine when using QMake.

Upvotes: 0

Views: 605

Answers (1)

Eejin
Eejin

Reputation: 840

So it ended up being some kind of name resolution thing where Qt Creator couldn't decide whether to use the debug or release versions of the framework. Supplying DYLD_IMAGE_SUFFIX=_debug fixed this (add this to the environment section under Kits).

Upvotes: 1

Related Questions