This application failed to start because it could not find or load the Qt platform plugin “cocoa”

后端 未结 4 620
北荒
北荒 2020-12-17 07:30

I think I did everything I could in the last 20 hours, but nothing seems to work. My app is running and working -- just as it should -- the only problem I have is that I can

4条回答
  •  感动是毒
    2020-12-17 08:33

    This is in addition to @mfitzp's answer.

    This QT Plugins Document came in handy.

    To look for default locations that your QT app is trying to search you can use following command:

    $sudo dtruss MacOS/ncher 
      getattrlist("/ncher.app\0", 0x7FFF954B51A4, 0x7FFF5C8FDD20)              = 0 0
      getattrlist("/ncher.app/Contents\0", 0x7FFF954B51A4, 0x7FFF5C8FDD20)             = 0 0
      getattrlist("/ncher.app/Contents/MacOS\0", 0x7FFF954B51A4, 0x7FFF5C8FDD20)               = 0 0
      stat64("/ncher.app/Contents/MacOS\0", 0x7FFF5C8FDED8, 0x7FFF5C8FDD20)            = 0 0
      stat64("/ncher.app/Contents/MacOS/platforms/.\0", 0x7FFF5C8FDF58, 0x7FFF5C8FDD20)                = -1 Err#2
      open("/dev/tty\0", 0x1000000, 0x1FF)             = 5 0
      fcntl(0x5, 0x2, 0x1)             = 0 0
      close(0x5)               = 0 0
      write_nocancel(0x2, "This application failed to start because it could not find or load the Qt platform plugin \"cocoa\".\n\nReinstalling the application may fix this problem.\n\0", 0x97)              = 151 0
      sigprocmask(0x3, 0x7FFF5C8FE6B4, 0x0)            = 0x0 0
      __pthread_sigmask(0x3, 0x7FFF5C8FE6C0, 0x0)              = 0 0
      __pthread_kill(0x603, 0x6, 0x0)          = 0 0
      kevent64(0x4, 0x0, 0x0)          = -1 Err#4
    

    You can see this QT app trying to look into MacOS/platforms, once i copied my libqcocoa.dylib plugin (its path were modified by install_name_tool command as per @mfitzp's answer) there, my application worked like charm.

    BTW it is advisable by MAC codesigning guide to have this directory structure correctly setup,

    DONT put Frameworks, plugins in ncher.app/Contents/MacOS directory

提交回复
热议问题