QupZilla / qupzilla

Cross-platform Qt web browser
http://www.qupzilla.com
GNU General Public License v3.0
1.11k stars 349 forks source link

Build failure on OS X ≤ 10.11: property 'allowsAutomaticWindowTabbing' not found on object of type 'NSWindow' #2473

Closed ryandesign closed 6 years ago

ryandesign commented 6 years ago

Hi, I'm the maintainer of QupZilla in MacPorts. I just updated MacPorts to QupZilla 2.2.0, and noticed it fails to build on OS X 10.11 (with Xcode 7.3.1) and on earlier Mac system versions. Here's the error:

tools/disablewindowtabbbing.mm:26:18: error: property 'allowsAutomaticWindowTabbing' not found on object of type 'NSWindow'
        NSWindow.allowsAutomaticWindowTabbing = NO;
                 ^

Here's the full build log.

Apple documentation shows this property was introduced in macOS 10.12.

Is there a way that you could still allow earlier Mac systems to build the latest QupZilla?

Martii commented 6 years ago

Is there a way that you could still allow earlier Mac systems to build the latest QupZilla?

If I were to interpret the way OS X has been handled, in this project, the last version of Qt that would be supported with OS X 10.11 is at http://doc.qt.io/qt-5/supported-platforms-and-configurations.html#qt-5-7 . I realize that 5.9 also includes this OS X version further down towards the middle of the range.

It is interesting that the source says:

https://github.com/QupZilla/qupzilla/blob/db26f2407f63d2cbc9bb0d768905ed84bbbdf6f7/src/lib/tools/disablewindowtabbbing.mm#L22

Perhaps a preprocessor directive similar to: https://github.com/QupZilla/qupzilla/blob/db26f2407f63d2cbc9bb0d768905ed84bbbdf6f7/src/lib/webengine/webview.cpp#L1257-L1259

... would work but modified with Qt 5.7 and the code isolation wanted to keep it building?

There is also this minimum requirement: https://github.com/QupZilla/qupzilla/blob/db26f2407f63d2cbc9bb0d768905ed84bbbdf6f7/QupZilla.pro#L9-L11

Period wise for your Xcode 7.3.1 the release that was done is https://github.com/Martii/qupzilla/releases/tag/v2.0.1%2B521d058 which was Qt 5.6.1.

Are you providing backports for those users not willing to update OS X and Xcode to the current?

nowrep commented 6 years ago

As long as you have Qt 5.8, it should work. I will fix that particular build error.

ryandesign commented 6 years ago

Just a reminder, this problem still exists in 2.2.1.

nowrep commented 6 years ago

@ryandesign Can you please test this?

diff --git a/src/lib/tools/disablewindowtabbbing.mm b/src/lib/tools/disablewindowtabbbing.mm
index a5218117..e24443a2 100644
--- a/src/lib/tools/disablewindowtabbbing.mm
+++ b/src/lib/tools/disablewindowtabbbing.mm
@@ -17,12 +17,15 @@
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * ============================================================ */
 #import <AppKit/AppKit.h>
+#import <Availability.h>

 // code taken from: https://www.mail-archive.com/interest@qt-project.org/msg23593.html
 // Disables auto window tabbing where supported, otherwise a no-op.
 void disableWindowTabbing()
 {
+#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
     if ([NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)]) {
         NSWindow.allowsAutomaticWindowTabbing = NO;
     }
+#endif
 }
nowrep commented 6 years ago

Also, do you have by any change enabled treating warnings as errors? I think ObjC should allow to build this code even with calling undefined method only with warning and not error.

ryandesign commented 6 years ago

Thanks, it builds on 10.11 and 10.10 now using that patch.

I'm not doing anything special to build, just qmake followed by make all. I use some additional flags, but nothing that would turn warnings into errors. I imagine this would build and run without a patch on older OS versions if built using the 10.12 SDK, but older Xcode versions don't contain the 10.12 SDK.