Error codesigning frameworks on Xcode
-
Ah, I got it (I think)! So, Qt's frameworks are dynamic, which means that when you add them to your project in Xcode, Xcode adds them to an "Embed Frameworks" build phase, which copies the framework files into the app bundle at build time and codesigns them. However, macdeployqt seems to want to do that part of the job. So, if I just link with the frameworks but don't add the frameworks to the "Embed Frameworks", then run macdeployqt, the depploy tool will handle that part of the build process, and even code signing.
Does that sound right to you?
-
So, I was able to get this working. I had to:
- Make sure the Qt frameworks were getting linked with, but not copied in and signed in the "Embedded Binaries" Xcode section
- Add a ShellScriptBuildPhase which calls
macdeployqt
passing in the .app path and optionally-use-debug-libs
if theCONFIGURATION
environment variable isDEBUG
. Note that I am not code signing here becausemacdeployqt
wants an unambiguous code signing identity (e.g. "Mac Developer: Dario XXXXXXX") but that may change per developer and I don't want to hard code that in to the shell shell script. - I need to add
--deep
to the project'sOTHER_CODE_SIGN_FLAGS
to tell Xcode's codesign build step to codesign the Qt frameworks and plugins.
-
Hmmm, looks like the Debug builds are not quite working right. Building is successful but I'm getting a crash on launch. It appears the _debug binaries are pointing to release frameworks and not finding them since only the _debug binaries are in the frameworks. For instance, here is
otool -L
output run on the QtMultimediaWidgets_debug embedded into the app bymacdeployqt
:@rpath/QtMultimediaWidgets.framework/Versions/5/QtMultimediaWidgets_debug (compatibility version 5.13.0, current version 5.13.1) @rpath/QtMultimedia.framework/Versions/5/QtMultimedia (compatibility version 5.13.0, current version 5.13.1) @rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.13.0, current version 5.13.1) @rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.13.0, current version 5.13.1) @rpath/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.13.0, current version 5.13.1) @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.13.0, current version 5.13.1) /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0) @rpath/QtOpenGL.framework/Versions/5/QtOpenGL (compatibility version 5.13.0, current version 5.13.1) /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
That doesn't seem right.
-
@sgaist So, I the prebuilt _debug frameworks that are downloaded using the online installer, are they supposed to be referencing/loading debug or release versions of other libraries? I just freshly redownloaded 5.13.1 for macOS and running otool on one of the _debug binaries shows that they point to the release versions. Is that right?
$ otool -L /Users/dario/Qt/5.13.1/clang_64/lib/QtMultimediaWidgets.framework/Versions/5/QtMultimediaWidgets_debug /Users/dario/Qt/5.13.1/clang_64/lib/QtMultimediaWidgets.framework/Versions/5/QtMultimediaWidgets_debug: @rpath/QtMultimediaWidgets.framework/Versions/5/QtMultimediaWidgets_debug (compatibility version 5.13.0, current version 5.13.1) @rpath/QtMultimedia.framework/Versions/5/QtMultimedia (compatibility version 5.13.0, current version 5.13.1) @rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.13.0, current version 5.13.1) @rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.13.0, current version 5.13.1) @rpath/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.13.0, current version 5.13.1) @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.13.0, current version 5.13.1) /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0) @rpath/QtOpenGL.framework/Versions/5/QtOpenGL (compatibility version 5.13.0, current version 5.13.1) /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
-
OK, so according to this bug report https://bugreports.qt.io/browse/QTBUG-48800, I need to add the
DYLD_IMAGE_SUFFIX=_debug
environment variable when running in debug mode. Feels like it would be better for _debug binaries to reference other _debug binaries. If not that, then the need for this environment variable when using-use-debug-libs
should be documented. -
Sorry I misread your first line, I thought you were using Qt Creator to build your project.
I must I'm also surprised but I haven't been in a situation requiring to deploy a debug version of an application.
-
So, I was able to get this working. I had to:
- Make sure the Qt frameworks were getting linked with, but not copied in and signed in the "Embedded Binaries" Xcode section
- Add a ShellScriptBuildPhase which calls
macdeployqt
passing in the .app path and optionally-use-debug-libs
if theCONFIGURATION
environment variable isDEBUG
. Note that I am not code signing here becausemacdeployqt
wants an unambiguous code signing identity (e.g. "Mac Developer: Dario XXXXXXX") but that may change per developer and I don't want to hard code that in to the shell shell script. - I need to add
--deep
to the project'sOTHER_CODE_SIGN_FLAGS
to tell Xcode's codesign build step to codesign the Qt frameworks and plugins.
-
Same issue here. The only workaround I've found is to use static library instead of framework. dgcustomerfirst
-
@hpasa and @Emma55 see https://forum.qt.io/post/551916 for how I was able to get this to work with dynamic frameworks. This is the post build script I added:
/Path/To/Qt/bin/macdeployqt ${CODESIGNING_FOLDER_PATH}
Which will not link to debug binaries as that still appears to be an open issue.
Definitely feels like using Qt in Xcode is a second class citizen
-
I thought
macdeployqt
was supposed to be a helper for deploying to macOS using Qt Creator. I thought that it was just copying and code signing frameworks but that doesn't seem to be the case. It should be possible to do whatever the tool does in Xcode but I can't figure it out. Just telling Xcode to embed and sign the frameworks isn't enough. To me, this seems like there's something wrong with the way the frameworks are built. Or maybe I just don't understand whatmacdeployqt
does (or is meant to do). -
I thought
macdeployqt
was supposed to be a helper for deploying to macOS using Qt Creator. I thought that it was just copying and code signing frameworks but that doesn't seem to be the case. It should be possible to do whatever the tool does in Xcode but I can't figure it out. Just telling Xcode to embed and sign the frameworks isn't enough. To me, this seems like there's something wrong with the way the frameworks are built. Or maybe I just don't understand whatmacdeployqt
does (or is meant to do).@Kerndog73 I agree completely. The frameworks that Qt builds and distributes are non-standard and Xcode just can't deal with them. Modifying them doesn't work either, as you can see from my OP. I think they just need to be built differently. After much trial and error, I gave up and tried
macdeployqt
and it seemed to do what was necessary. Definitely would like to see Qt move towards using standard frameworks.