Unsolved Problem with Camera component on macOS 10.14.2
-
Hello,
QT v 5.12.1
I have a project with a "Camera" component.
I have updated my os to the latest MacOS 10.14.2.Since then, my app crashes at startup time. If I comment out the Camera definition line in my qml code:
Camera { id: camera; deviceId: "nocamera"; }
Then the app does NOT crash at startup time...
Do you have any idea what might be going wrong here?
Thanks,
Cyrille -
question, did you add the camera permission to your info.plist ?
Do you get any feedback from QtCreator/ the console?
-
Hello,
Nope, I have not added anything anywhere (besides multimedia in my QT line).
I am not getting any warnings or anything from QT creator/console.I am more of a windows programmer and have no idea what an info.plist is :-)
Where/how do I do this?
Thanks
Cyrille -
@Cyrille-de-Brebisson said in Problem with Camera component on macOS 10.14.2:
Hello,
Nope, I have not added anything anywhere (besides multimedia in my QT line).
I am not getting any warnings or anything from QT creator/console.I am more of a windows programmer and have no idea what an info.plist is :-)
My condolences ;-)
Take a look here more or less mandatory read from apple for MacOS/iOS developer
When creating a Mac-app and qmake is run, an Info.plist file is generated with appropriate default values
If permission for camera is not set inside that, your application may crash.
Take a look at this part of the docu:
http://doc.qt.io/qt-5/ios-platform-notes.htmlThose are notes for iOS but they should be more or less identical for MacOS development/management of Info.plist
-
@J.Hilk said in
My condolences ;-)
For being a windows programmer, or for having to work on mac :)I will be reading the documentation....
It would be great if things like that could be automated in QT creator in the future!
Have a good day,
Cyrille -
@Cyrille-de-Brebisson said in Problem with Camera component on macOS 10.14.2:
@J.Hilk said in
My condolences ;-)
For being a windows programmer, or for having to work on mac :)
I would say for being a Windows programmer, but that would be hypocrisy, most of my work is done from a windows PC as well.
But the change from Windows to Mac can be rought, but very few want to go back to Windows, once they have roughly the same understandung on how to handle the OS's.
:-)It would be great if things like that could be automated in QT creator in the future!
most of it is done in the automatic generated Info.plist file, but stuff changes and QtCreator may not always up to the challenge right away.
-
Hi,
Are you by any chance running Mojave ?
Apple does introduce new rules / security features from time to time which requires some manual work that might not always be easily manipulated. For example, using QtMultimedia doesn't mean you will be using the microphone nor the camera so you can't automatically add the permission requirements for that.
-
Hello,
I understand...
I was more thinking of easy, GUI driven permission list editor that would be in QT creator and allow easy editing of such things without having to "undersand" plists...
This same editor would take the info and be able to use them to generate the equivalent files for other OS as well if/as appropriate...
That would be cool
This is just a QT creator feature suggestion. I am fully aware of how hard/problematic, how much work it is following with ever changing software vendors...
Cyrille -
@Cyrille-de-Brebisson said in Problem with Camera component on macOS 10.14.2:
I was more thinking of easy, GUI driven permission list editor that would be in QT creator and allow easy editing of such things without having to "undersand" plists...
It's called Xcode ;-)
If you have it installed use that to modify the info.plist it's the easiest way.
-
Hello,
Well, I have Xcode... There is no choice as QT will not install without it....
Anyhow, back to the problem, here is what I have done and found.
I have copied the auto generated Info.plist file in my project folder. Added QMAKE_INFO_PLIST= Info.plist in my .pro file and added the following 2 lines in said file:
<key>NSCameraUsageDescription</key> <string>Needs camera for display of mirror option</string>
I have run qmake and build and here is the behavior that I am seeing:
- Run the app from QT creator still does not work (crash).
- Run the app in debug mode (click on debug, not on run) and the application DOES work.
- Run the app by double clicking on the app bundle generated by QT DOES work. However!
- The application starts and the OS asks for camera permission (which I gave).
- The application can NOT access the camera (it does not work).
- When I close and restart the application (double click on the app). The application is NOW able to access the camera
Any clue why a simple click on run causes the app to still crash?
Thanks,
Cyrille -
@Cyrille-de-Brebisson said in Problem with Camera component on macOS 10.14.2:
Hello,
Well, I have Xcode... There is no choice as QT will not install without it....
technically you only need the command line tools, you can get those without the whole Xcode program.
Any clue why a simple click on run causes the app to still crash?
after adding QMAKE_INFO_PLIST= Info.plist did you rerun qmake ? that the the new modified info.plist is copied into the app bundle?
-
I'm facing the same problem.
Here is what I did to edit my
Info.plist
file:QMAKE_POST_LINK += plutil -replace NSCameraUsageDescription -string \"My usage description.\" $${TARGET}.app/Contents/Info.plist
Unfortunately I always have a crash.
Strangely, if I start a debug session, I have a macOS dialog asking if my app can have the camera access and it work then.
-
Hello,
Very nice solution!
Cyrille