Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

macOS: different behaviors between the app and the unix exec file



  • Environment:
    macOS 10.15.4
    Qt: 5.12.8
    Qt Creator: 4.11.2 (based on Qt 5.14.2 Clang 10.0.0)

    I'm developing a Qt Widget Application called surimage-tool under macOS, with the camera on the laptop. When I run the project in Qt Creator (cmd + R) or run the execuate build-surimage-tool-Desktop_Qt_5_12_8_clang_64bit-Debug/surimage-tool.app/Contents/MacOS/surimage-tool, it's totally fine, the camera turns on, the program runs good.

    But when I double click the bundle app build-surimage-tool-Desktop_Qt_5_12_8_clang_64bit-Debug/surimage-tool.app or debug inside Qt Creator, the camera fails to turn on. The debug console says:

    [] CMIO_DAL_PlugIn.cpp:269:StreamCopyBufferQueue Error: 1852797029, got an error from the plug-in routine
    

    I add the NSCameraUsageDescription key in the Info.plist as required by the debugger, here is the complete Info.plist content:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    	<key>CFBundleExecutable</key>
    	<string>surimage-tool</string>
    	<key>CFBundleGetInfoString</key>
    	<string>Created by Qt/QMake</string>
    	<key>CFBundleIconFile</key>
    	<string></string>
    	<key>CFBundleIdentifier</key>
    	<string>dongming.surimage-tool</string>
    	<key>CFBundlePackageType</key>
    	<string>APPL</string>
    	<key>CFBundleSignature</key>
    	<string>????</string>
    	<key>LSMinimumSystemVersion</key>
    	<string>10.12</string>
    	<key>NOTE</key>
    	<string>This file was generated by Qt/QMake.</string>
    	<key>NSPrincipalClass</key>
    	<string>NSApplication</string>
    	<key>NSSupportsAutomaticGraphicsSwitching</key>
    	<true/>
    	<key>NSCameraUsageDescription</key>
    	<string>I need it</string>
    </dict>
    </plist>
    

    My questions are :

    1. why are the behaviors different: open the app v.s. open the unix exec?
    2. when I debug in Qt Creator, is it debugging the APP or the unix exec? (I know RUN in the Creator invoke the unix exec as shown in the Qt console). I guess it is debugging the app as it reminds me to add NSCameraUsageDescription to the Info.plist.

    My guess to the solution:
    Is it a bug in macOS or is there sth I'm missing in the Info.plist?



  • Okay I've tackled this, the point is that macOS will ask you if you allow the app to use camera, but without the key CFBundleDisplayName, the ask dialog won't pop out, so here is the working Info.plist:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    	<key>BuildMachineOSBuild</key>
    	<string>18A391012</string>
    	<key>CFBundleDevelopmentRegion</key>
    	<string>English</string>
    	<key>CFBundleDocumentTypes</key>
    	<array>
    		<dict>
    			<key>CFBundleTypeExtensions</key>
    			<array>
    				<string>Photo Booth</string>
    			</array>
    			<key>CFBundleTypeIconFile</key>
    			<string>PhotoBoothLibrary.icns</string>
    			<key>CFBundleTypeName</key>
    			<string>Photo Booth Library</string>
    			<key>CFBundleTypeOSTypes</key>
    			<array>
    				<string>PBLb</string>
    			</array>
    			<key>CFBundleTypeRole</key>
    			<string>Viewer</string>
    			<key>LSTypeIsPackage</key>
    			<true/>
    			<key>NSDocumentClass</key>
    			<string>ArchiveDocument</string>
    		</dict>
    	</array>
    	<key>CFBundleExecutable</key>
    	<string>Photo Booth</string>
    	<key>CFBundleHelpBookFolder</key>
    	<string>PhotoBooth.help</string>
    	<key>CFBundleHelpBookName</key>
    	<string>com.apple.PhotoBooth.help</string>
    	<key>CFBundleIconFile</key>
    	<string>PhotoBoothIcon.icns</string>
    	<key>CFBundleIdentifier</key>
    	<string>com.apple.PhotoBooth</string>
    	<key>CFBundleInfoDictionaryVersion</key>
    	<string>11.0</string>
    	<key>CFBundleName</key>
    	<string>Photo Booth</string>
    	<key>CFBundlePackageType</key>
    	<string>APPL</string>
    	<key>CFBundleShortVersionString</key>
    	<string>11.0</string>
    	<key>CFBundleSignature</key>
    	<string>PhBo</string>
    	<key>CFBundleSupportedPlatforms</key>
    	<array>
    		<string>MacOSX</string>
    	</array>
    	<key>CFBundleVersion</key>
    	<string>1116</string>
    	<key>DTCompiler</key>
    	<string>com.apple.compilers.llvm.clang.1_0</string>
    	<key>DTPlatformBuild</key>
    	<string>11O62d</string>
    	<key>DTPlatformName</key>
    	<string>macosx</string>
    	<key>DTPlatformVersion</key>
    	<string>10.15.4</string>
    	<key>DTSDKBuild</key>
    	<string>19E250</string>
    	<key>DTSDKName</key>
    	<string>macosx10.15internal</string>
    	<key>DTXcode</key>
    	<string>1140</string>
    	<key>DTXcodeBuild</key>
    	<string>11O62d</string>
    	<key>GPUSelectionPolicy</key>
    	<string>automatic</string>
    	<key>HPDHelpProjectIdentifier</key>
    	<string>photo-booth</string>
    	<key>LSApplicationCategoryType</key>
    	<string>public.app-category.entertainment</string>
    	<key>LSMinimumSystemVersion</key>
    	<string>10.10.0</string>
    	<key>NSHumanReadableCopyright</key>
    	<string>Copyright © 2005–2018 Apple Inc. All rights reserved.</string>
    	<key>NSMainNibFile</key>
    	<string>MainMenu</string>
    	<key>NSPrincipalClass</key>
    	<string>PBApplication</string>
    	<key>NSSupportsAutomaticGraphicsSwitching</key>
    	<true/>
    	<key>NSSupportsSuddenTermination</key>
    	<string>YES</string>
    </dict>
    </plist>
    

    Have to reload the Info.plist according to how do I properly force osx to reload the info.plist file of an application

    And I also guess that Qt Creator debug my .app: surimage-tool.app, not the unix exec file surimage-tool.


Log in to reply