From aaaa1e251ea43e4094e79b7161327c07db60d351 Mon Sep 17 00:00:00 2001 From: Maximilian Blochberger Date: Mon, 17 Oct 2022 13:50:22 +0200 Subject: Ensure proper format of Info.plist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Information Property List (Info.plist) is a property list that contains information about macOS and iOS application and framework bundles. There are multiple supported formats, those property lists can be stored in, most notably XML and binary. Problem If the Info.plist file is edited with an external editor, such as Xcode, it is possible that it is stored in binary format. A Makefile generated by the qmake tool contains a call to sed, which works on text but not binary files. Consequently, this call would fail. Solution Since Mac OS X 10.2, the plutil tool is available. It can be used to convert the property lists into a specific format. The plutil tool is now used to convert the plist to XML, so that the sed invocation succeeds. [ChangeLog][qmake] Fixed handling binary Info.plist files in generated Makefiles by always converting them to XML before substituting placeholders. Fixes: QTBUG-45357 Change-Id: I066039301c391a5034710458500a096f09e5ca24 Reviewed-by: Jörg Bornemann Reviewed-by: Tor Arne Vestbø (cherry picked from commit bbad6440aecdba29d8808c4fa6e3e6353b39c887) Reviewed-by: Maximilian Blochberger Reviewed-by: Alexandru Croitor --- qmake/generators/unix/unixmake2.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index 5557f99fda..3cc9f67949 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -803,7 +803,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) QString icon = fileFixify(var("ICON")); t << "@$(DEL_FILE) " << info_plist_out << "\n\t" - << "@sed "; + << "@plutil -convert xml1 -o - " << info_plist << " | " + << "sed "; for (const ProString &arg : std::as_const(commonSedArgs)) t << arg; const QString iconName = icon.section(Option::dir_sep, -1); @@ -814,7 +815,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) << "-e \"s,\\$${EXECUTABLE_NAME}," << (app_bundle_name.isEmpty() ? app_bundle_name : plugin_bundle_name) << ",g\" " << "-e \"s,@TYPEINFO@,"<< typeInfo << ",g\" " << "-e \"s,\\$${QMAKE_PKGINFO_TYPEINFO},"<< typeInfo << ",g\" " - << "" << info_plist << " >" << info_plist_out << Qt::endl; + << ">" << info_plist_out << Qt::endl; //copy the icon if (!project->isEmpty("ICON")) { QString dir = bundle_dir + "Contents/Resources/"; @@ -835,14 +836,15 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) if (!isShallowBundle) symlinks[bundle_dir + "Resources"] = "Versions/Current/Resources"; t << "@$(DEL_FILE) " << info_plist_out << "\n\t" - << "@sed "; + << "@plutil -convert xml1 -o - " << info_plist << " | " + << "sed "; for (const ProString &arg : std::as_const(commonSedArgs)) t << arg; t << "-e \"s,@LIBRARY@," << lib_bundle_name << ",g\" " << "-e \"s,\\$${EXECUTABLE_NAME}," << lib_bundle_name << ",g\" " << "-e \"s,@TYPEINFO@," << typeInfo << ",g\" " << "-e \"s,\\$${QMAKE_PKGINFO_TYPEINFO}," << typeInfo << ",g\" " - << "" << info_plist << " >" << info_plist_out << Qt::endl; + << ">" << info_plist_out << Qt::endl; } break; } // project->isActiveConfig("no_plist") -- cgit v1.2.3