Introduction¶
PySide6 offers a convenient tool to create app bundles from a pyside script. However, on MacOS, app bundles created this way cannot be automated directly with Squish.
Squish expects the Qt libraries to be presentd as frameworks but the bundle contains them as flat libraries, which can not be used by Squish and also can not be changed during the build process.
Also refer Automating PySide Apps on MacOS as the symbolic link in the QtCore.framework will be missing and Squish will be unable to hook the application if this is not present.
This was verified with PySide 6.10.3 and Squish 9.2.2 on an Arm M2 mac machine.
Solution¶
To be able to automate the application we must make the app bundle use the frameworks already present in the PySide package instead of the current libraries.
Copy the frameworks¶
Create a
Frameworksfolder inAPP_BUNDLE/Contentsas this folder does not exist by default.Copy the required frameworks from your PySide6 installation into this folder. The location for the Qt in a Pyside6 package on MacOS is usually in
PYTHON_DIR/lib/pythonMAJOR.MINOR/site-packages/PySide6/Qt/lib.
For a basic widget application without any special dependencies the following were required
QtCore.frameworkQtGui.frameworkQtWidgets.frameworkQtNetwork.frameworkQtDBus.framework
Setup the redirect¶
Next, remove all Qt libraries from APP_BUNDLE/Contents/MacOS as these are the libraries we do not want the application to use. Run the following command inside the MacOS folder:
rm ./Qt*
Consider listing the files to be deleted first, if you are not sure about what will be affected :
ls ./Qt*
Then create symbolic links for QtCore, QtGui and QtWidgets as those are loaded by other libraries (for example, those in the PySide6 folder).
For this run the following commands
ln -s ../Frameworks/QtCore.framework/Versions/A/QtCore ./QtCore
ln -s ../Frameworks/QtGui.framework/Versions/A/QtGui ./QtGui
ln -s ../Frameworks/QtWidgets.framework/Versions/A/QtWidgets ./QtWidgets
Signature¶
Modyfying an app bundle invalidates its signature, so if you have signed the app bundle during the build process, you will need to renew the signature.
Update the registered framework¶
If a different QtCore framework is already registered, update this by running the binary SQUISHDIR/bin/squishconfig with --qt=PATH_TO_QTCORE_FRAMEWORK and replace PATH_TO_QTCORE_FRAMEWORK with the absolute path to the framework in the app bundle.