OlivierLDff / QtIosCMake

📱 Deploy Qt Application for iOS with a single macro when using CMake.
BSD 3-Clause "New" or "Revised" License
58 stars 15 forks source link

removing bluetooth support? #9

Closed Dushistov closed 4 years ago

Dushistov commented 4 years ago

If build this project https://github.com/OlivierLDff/QQuickStaticHelloWorld without any bluetooth dependencies but the resulted binary depend on CoreBluetooth.framework:

$ grep CoreBluetooth.framework build_ios/Debug-iphoneos/QQuickStaticHelloWorld.app/QQuickStaticHelloWorld
Binary file build_ios/Debug-iphoneos/QQuickStaticHelloWorld.app/QQuickStaticHelloWorld matches

The problem is that if upload such application to Apple Store, then Apple ask to explain why you need bluetooth. I see only one user of CoreBluetooth.framework in Qt installation:

$ grep CoreBluetooth.framework ~/Qt/5.15.0/ios/lib/*.a
Binary file ~/Qt/5.15.0/ios/lib/libQt5Bluetooth_debug.a matches

and clearly QQuickStaticHelloWorld don't depend on Qt5Bluetooth but for some reason it pulls it's dependencies.

I build project in such way:

cmake -DCMAKE_PREFIX_PATH=~/Qt/5.15.0/ios -DDEPLOYMENT_TARGET=12.0 \
-DCMAKE_TOOLCHAIN_FILE=./IosCMakeToolchain/ios.toolchain.cmake -DPLATFORM=OS64 \
-G "Xcode" -DENABLE_BITCODE=FALSE -DENABLE_VISIBILITY=TRUE \
-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/ ..
xcodebuild clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
Dushistov commented 4 years ago

I removed CoreBluetooth from QT_EXTRA_LIBS and that made Apple Store happy. May be some option to remove it?

OlivierLDff commented 4 years ago

QT_EXTRA_LIBS is the ugly part of the script. Just putting everything in there to have something that work. Thanks for the feedback. Maybe it should only be appended if user is linking with Qt5 Bluetooth.

get_target_property(TARGET_DEPENDENCIES ${QT_IOS_TARGET} LINK_LIBRARIES)
foreach(TARGET_DEPENDENCY ${TARGET_DEPENDENCIES})
    if(${TARGET_DEPENDENCY} STREQUALS "Qt5::Bluetooth")
        set(QT_EXTRA_LIBS "${QT_EXTRA_LIBS} -framework CoreBluetooth")
    endif()
endforeach()
Dushistov commented 4 years ago

@OlivierLDff

But why QT_EXTRA_LIBS exists at the first place?

For example

~/Qt/5.15.0/ios/lib/cmake/Qt5Bluetooth/Qt5BluetoothConfig.cmake contains code:

 if(NOT Qt5_EXCLUDE_STATIC_DEPENDENCIES)
        _qt5_Bluetooth_process_prl_file(
            "${_qt5Bluetooth_install_prefix}/lib/libQt5Bluetooth_debug.prl" DEBUG
            _Qt5Bluetooth_STATIC_DEBUG_LIB_DEPENDENCIES
            _Qt5Bluetooth_STATIC_DEBUG_LINK_FLAGS
        )

        _qt5_Bluetooth_process_prl_file(
            "${_qt5Bluetooth_install_prefix}/lib/libQt5Bluetooth.prl" RELEASE
            _Qt5Bluetooth_STATIC_RELEASE_LIB_DEPENDENCIES
            _Qt5Bluetooth_STATIC_RELEASE_LINK_FLAGS
        )
    endif()

where libQt5Bluetooth.prl contains:

QMAKE_PRL_LIBS = $$[QT_INSTALL_LIBS]/libQt5Core.a -framework MobileCoreServices -lm -framework UIKit -framework CoreFoundation -framework Foundation -lz $$[QT_INSTALL_LIBS]/libqtpcre2.a -framework Foundation -framework CoreBluetooth

So actually all information about what to link should be somewhere inside cmake?

OlivierLDff commented 4 years ago

CMake support greatly improve since couple of version. When i wrote this script there were almost no CMake support in Qt for Ios. I think it can be a good idea to support build against qt 5.12 at while it's still LTS.