diff options
author | Jake Petroules <jake.petroules@qt.io> | 2017-01-27 11:34:17 -0800 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2017-01-27 22:10:01 +0000 |
commit | 944110089d4cb1c229dba422989e154db65a67fd (patch) | |
tree | ecce07d29d0fb768700b5b6cb1d9c49040983584 | |
parent | af7cefd2725a4afb41700cb5568bd99710ebad5d (diff) |
Build Qt libraries with -fapplication-extension
This ensures at compile-time that Qt libraries do not use any APIs that
are not safe for use in application extensions, and fixes warning
messages that appear when linking to Qt libraries that are not built
with this flag, when used in an application extension.
This is especially important on watchOS where *all* "applications" are
actually application extensions, and on other Apple platforms if
application extensions are developed using Qt.
Task-number: QTBUG-40101
Change-Id: I022046f2584e0222253d33052b0abc221d7c93d6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r-- | mkspecs/features/mac/default_post.prf | 7 | ||||
-rw-r--r-- | mkspecs/features/qml_plugin.prf | 3 | ||||
-rw-r--r-- | mkspecs/features/qt_module.prf | 3 | ||||
-rw-r--r-- | mkspecs/features/qt_plugin.prf | 3 | ||||
-rw-r--r-- | qmake/generators/mac/pbuilder_pbx.cpp | 1 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_cf.mm | 3 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/cocoa.pro | 2 | ||||
-rw-r--r-- | src/plugins/platforms/ios/kernel.pro | 2 |
8 files changed, 23 insertions, 1 deletions
diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index 1b2e5d5db4..4a30a8a652 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -38,6 +38,13 @@ qt { !bitcode: QMAKE_LFLAGS += $$QMAKE_LFLAGS_HEADERPAD +app_extension_api_only { + QMAKE_CFLAGS += -fapplication-extension + QMAKE_CXXFLAGS += -fapplication-extension + QMAKE_CXXFLAGS_PRECOMPILE += -fapplication-extension + QMAKE_LFLAGS += -fapplication-extension +} + macx-xcode { !isEmpty(QMAKE_XCODE_DEBUG_INFORMATION_FORMAT) { debug_information_format.name = DEBUG_INFORMATION_FORMAT diff --git a/mkspecs/features/qml_plugin.prf b/mkspecs/features/qml_plugin.prf index 7e12626db3..de036c129e 100644 --- a/mkspecs/features/qml_plugin.prf +++ b/mkspecs/features/qml_plugin.prf @@ -21,6 +21,9 @@ if(win32|mac):!macx-xcode { CONFIG += relative_qt_rpath # Qt's QML plugins should be relocatable +# Qt libraries should only use Application Extension safe APIs +darwin:!no_app_extension_api_only: CONFIG += app_extension_api_only + !no_cxx_module:isEmpty(CXX_MODULE) { CXX_MODULE = $$TARGET TARGET = declarative_$${TARGET} diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf index 23d75182d0..7ba81c93b1 100644 --- a/mkspecs/features/qt_module.prf +++ b/mkspecs/features/qt_module.prf @@ -46,6 +46,9 @@ CONFIG(shared, static|shared):qtConfig(framework): \ CONFIG += relative_qt_rpath # Qt libraries should be relocatable +# Qt libraries should only use Application Extension safe APIs +darwin:!no_app_extension_api_only: CONFIG += app_extension_api_only + ucmodule = $$upper($$MODULE) isEmpty(MODULE_INCNAME): MODULE_INCNAME = $$TARGET diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf index 265b4ea8a2..31079f1e12 100644 --- a/mkspecs/features/qt_plugin.prf +++ b/mkspecs/features/qt_plugin.prf @@ -32,6 +32,9 @@ tool_plugin { CONFIG += relative_qt_rpath # Qt's plugins should be relocatable +# Qt libraries should only use Application Extension safe APIs +darwin:!no_app_extension_api_only: CONFIG += app_extension_api_only + CONFIG(static, static|shared)|prefix_build { isEmpty(MODULE): MODULE = $$basename(TARGET) diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index f42b3021f1..728e654be8 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -1485,6 +1485,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) } } settings.insert("COPY_PHASE_STRIP", (as_release ? "YES" : "NO")); + settings.insert("APPLICATION_EXTENSION_API_ONLY", project->isActiveConfig("app_extension_api_only") ? "YES" : "NO"); // required for tvOS (and watchos), optional on iOS (deployment target >= iOS 6.0) settings.insert("ENABLE_BITCODE", project->isActiveConfig("bitcode") ? "YES" : "NO"); settings.insert("GCC_GENERATE_DEBUGGING_SYMBOLS", as_release ? "NO" : "YES"); diff --git a/src/corelib/kernel/qeventdispatcher_cf.mm b/src/corelib/kernel/qeventdispatcher_cf.mm index 9ac48f144d..27eb3d0337 100644 --- a/src/corelib/kernel/qeventdispatcher_cf.mm +++ b/src/corelib/kernel/qeventdispatcher_cf.mm @@ -80,7 +80,8 @@ QT_USE_NAMESPACE #elif defined(Q_OS_WATCHOS) object:[WKExtension sharedExtension]]; #else - object:[UIApplication sharedApplication]]; + // Use performSelector so this can work in an App Extension + object:[[UIApplication class] performSelector:@selector(sharedApplication)]]; #endif } diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 0664841c2d..62935210be 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -86,6 +86,8 @@ QT += \ accessibility_support-private clipboard_support-private theme_support-private \ fontdatabase_support-private graphics_support-private cgl_support-private +CONFIG += no_app_extension_api_only + qtHaveModule(widgets) { OBJECTIVE_SOURCES += \ qpaintengine_mac.mm \ diff --git a/src/plugins/platforms/ios/kernel.pro b/src/plugins/platforms/ios/kernel.pro index 71257d09f7..6eb9f2c534 100644 --- a/src/plugins/platforms/ios/kernel.pro +++ b/src/plugins/platforms/ios/kernel.pro @@ -5,6 +5,8 @@ TARGET = qios # application's main() when the plugin is a shared library. qtConfig(shared): CONFIG += static +CONFIG += no_app_extension_api_only + QT += \ core-private gui-private \ clipboard_support-private fontdatabase_support-private graphics_support-private |