Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error codesigning frameworks on Xcode
QtWS25 Last Chance

Error codesigning frameworks on Xcode

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 5 Posters 2.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DarioA
    wrote on last edited by
    #6

    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?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DarioA
      wrote on last edited by
      #7

      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 the CONFIGURATION environment variable is DEBUG. Note that I am not code signing here because macdeployqt 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's OTHER_CODE_SIGN_FLAGS to tell Xcode's codesign build step to codesign the Qt frameworks and plugins.
      hpasaH 1 Reply Last reply
      1
      • D Offline
        D Offline
        DarioA
        wrote on last edited by DarioA
        #8

        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 by macdeployqt:

        	@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.

        1 Reply Last reply
        0
        • SGaistS SGaist

          What parameters are you passing to macdeployqt ?

          D Offline
          D Offline
          DarioA
          wrote on last edited by
          #9

          @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)
          
          1 Reply Last reply
          0
          • D Offline
            D Offline
            DarioA
            wrote on last edited by
            #10

            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.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #11

              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.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • D DarioA

                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 the CONFIGURATION environment variable is DEBUG. Note that I am not code signing here because macdeployqt 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's OTHER_CODE_SIGN_FLAGS to tell Xcode's codesign build step to codesign the Qt frameworks and plugins.
                hpasaH Offline
                hpasaH Offline
                hpasa
                wrote on last edited by
                #12

                @DarioA I just ran into the same issue. To me it looks like a bug somewhere, possibly in the way that Qt frameworks are setup, that the Version/A is referenced. I'm using XCode 11.1, and I would expect "Embed & Sign" to work for Qt frameworks as well.

                1 Reply Last reply
                1
                • E Offline
                  E Offline
                  Emma55
                  wrote on last edited by Emma55
                  #13

                  Same issue here. The only workaround I've found is to use static library instead of framework. dgcustomerfirst

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    DarioA
                    wrote on last edited by
                    #14

                    @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

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      Kerndog73
                      wrote on last edited by
                      #15

                      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 what macdeployqt does (or is meant to do).

                      D 1 Reply Last reply
                      0
                      • K Kerndog73

                        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 what macdeployqt does (or is meant to do).

                        D Offline
                        D Offline
                        DarioA
                        wrote on last edited by
                        #16

                        @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.

                        1 Reply Last reply
                        2

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved