Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Build and deploy the Mac app bundle for QT AGI Studio
# Author: Chad Armstrong (
# Date: 17 October 2020 - 1 January 2021
# Note: Run this script in the same directory as the bundle
# Print out the current working directory
function cwd {
echo "Current working directory is: $PWD\n"
# macdeployqt does not properly create the Mac frameworks, so they do not code
# sign properly. Set up the QT framework so the anatomy is properly structured.
function setup_framework {
# $1 is the first parameter, the name of the QT framework (e.g. Qt3Support)
echo "Updating the framework $FRAMEWORK_NAME"
cd "./$FRAMEWORK_NAME.framework"
# Check that if the Resources is not a symlink
if [ ! -h "Resources" ]; then
# If there is an existing Resources folder, it needs to be moved into the Versions/4/ folder
mv -f Resources Versions/4/
# Create the Current soft link. Move into the Versions directory to properly
# set up the soft link
cd Versions
ln -s 4 Current
cd ..
# Create the Resources soft link
ln -s Versions/Current/Resources Resources
# Create a soft link for the framework executable (Qtwhatever) to
ln -s "Versions/Current/$FRAMEWORK_NAME" "$FRAMEWORK_NAME"
# Return to the parent working directory
# macdeployqt
echo "\nmacdeployqt"
# install_name_tool
echo "\ninstall_name_tool"
install_name_tool -change Qt3Support.framework/Versions/4/Qt3Support @executable_path/../Frameworks/Qt3Support.framework/Versions/4/Qt3Support ./agistudio
install_name_tool -change QtGui.framework/Versions/4/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui ./agistudio
install_name_tool -change QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore ./agistudio
# Verify that install_name_tool worked
# otool -L
# Return to the parent folder of
cd -
echo "\nCopy and update Info.plist into Qt Frameworks"
cp /Library/Frameworks/Qt3Support.framework/Contents/Info.plist ./
/usr/libexec/PlistBuddy -c "Add :CFBundleVersion string 4.8" ./
/usr/libexec/PlistBuddy -c "Add :CFBundleIdentifier string org.qt-project.Qt3Support" ./
setup_framework Qt3Support
cp /Library/Frameworks/QtCore.framework/Contents/Info.plist ./
/usr/libexec/PlistBuddy -c "Add :CFBundleVersion string 4.8" ./
/usr/libexec/PlistBuddy -c "Add :CFBundleIdentifier string org.qt-project.QtCore" ./
setup_framework QtCore
cp /Library/Frameworks/QtGui.framework/Contents/Info.plist ./
/usr/libexec/PlistBuddy -c "Add :CFBundleVersion string 4.8" ./
/usr/libexec/PlistBuddy -c "Add :CFBundleIdentifier string org.qt-project.QtGui" ./
setup_framework QtGui
cp /Library/Frameworks/QtNetwork.framework/Contents/Info.plist ./
/usr/libexec/PlistBuddy -c "Add :CFBundleVersion string 4.8" ./
/usr/libexec/PlistBuddy -c "Add :CFBundleIdentifier string org.qt-project.QtNetwork" ./
setup_framework QtNetwork
cp /Library/Frameworks/QtSql.framework/Contents/Info.plist ./
/usr/libexec/PlistBuddy -c "Add :CFBundleVersion string 4.8" ./
/usr/libexec/PlistBuddy -c "Add :CFBundleIdentifier string org.qt-project.QtSql" ./
setup_framework QtSql
cp /Library/Frameworks/QtXml.framework/Contents/Info.plist ./
/usr/libexec/PlistBuddy -c "Add :CFBundleVersion string 4.8" ./
/usr/libexec/PlistBuddy -c "Add :CFBundleIdentifier string org.qt-project.QtXml" ./
setup_framework QtXml
# Copy Info.plist into app bundle
echo "\nCopy Info.plist into app bundle"
cp -fv ../src/Info.plist
# Copy over Help files into the app bundle's Resource folder
echo "\nCopy help files"
cp -Rfv ../help\ Studio\ Help
# Copy over the template files into the app bundle's Resource folder
echo "\nCopy template files"
cp -Rfv ../template
# Rename app bundle
echo "\n\nRename app bundle"
rm -Rfv AGI\ # Delete the old app bundle
mv -f AGI\ # Rename agistudio to AGI Studio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment