ios qt开发要点

目前关于ios qt的开发资料比较少,这里整理了几个比较重要的开发要点,基于MacOS14 + Xcode15 + Qt5.15 + cmake + iphone真机。

  • cmake报错,报错信息如下

    CMake Error at /Users/user/Qt/5.15.5/ios/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:91 (message):
    Library not found: MobileCoreServices
    Call Stack (most recent call first):
    /Users/user/Qt/5.15.5/ios/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:263
    (_qt5_Core_process_prl_file)
    /Users/user/Qt/5.15.5/ios/lib/cmake/Qt5/Qt5Config.cmake:28 (find_package)
    CMakeLists.txt:28 (find_package)

解决方法:添加cmake参数

-DCMAKE_FIND_ROOT_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_SYSTEM_NAME=iOS
-DCMAKE_OSX_SYSROOT=iphoneos
-DCMAKE_OSX_ARCHITECTURES=arm64

并在CMakeLists.txt中添加

if(IOS)
    target_link_options(${user_project_target_name} PRIVATE "-Wl,-e,_qt_main_wrapper")
endif()

参考来源:https://bugreports.qt.io/browse/QTCREATORBUG-26121

  • 找不到openssl,报错如下

    Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
    system variable OPENSSL_ROOT_DIR (missing: OPENSSL_INCLUDE_DIR)
    

实测设置OPENSSL_ROOT_DIR无效,这里可以手动指定相应的cmake变量,在FindOpenSSL.cmake做相应的修改。

FIND_PATH(OPENSSL_INCLUDE_DIR
  NAMES
    openssl/ssl.h
  PATH_SUFFIXES
	"include"
  HINTS
    ${_OPENSSL_INCLUDEDIR}
  ${_OPENSSL_ROOT_HINTS_AND_PATHS}
  PATH_SUFFIXES
    include
)

# add for ios
IF(IOS AND NOT OPENSSL_INCLUDE_DIR)
    set (OPENSSL_INCLUDE_DIR "/usr/local/opt/opensslios@1.1/include")
    set (SSL_LIBRARY "/usr/local/opt/opensslios@1.1/lib/libssl.a")
    set (CRYPTO_LIBRARY "/usr/local/opt/opensslios@1.1/lib/libcrypto.a")
    list(APPEND OPENSSL_LIBRARIES ${CRYPTO_LIBRARY} ${SSL_LIBRARY})
ENDIF()
  • 打开.pro项目文件报错,无法展开项目文件树

    failed to parse default search paths from compiler output

解决方法:在qmake构建步骤添加额外参数

 -early QMAKE_DEFAULT_LIBDIRS=$(xcrun -show-sdk-path)/usr/lib

参考来源:https://bugreports.qt.io/browse/QTBUG-117225

  • 设置AppIcon无效,解决方法:1)在Xcode中将xcassets文件添加到Build Phases中的Copy Bundle Resources中;2)也可以在cmake如下添加:

    set_target_properties(${MODULE_NAME} PROPERTIES RESOURCE "xxx.xcassets")

相关推荐
DisonTangor30 分钟前
苹果发布iOS 18.2首个公测版:Siri接入ChatGPT、iPhone 16拍照按钮有用了
ios·chatgpt·iphone
- 羊羊不超越 -33 分钟前
App渠道来源追踪方案全面分析(iOS/Android/鸿蒙)
android·ios·harmonyos
2401_8658548817 小时前
iOS应用想要下载到手机上只能苹果签名吗?
后端·ios·iphone
HackerTom1 天前
iOS用rime且导入自制输入方案
ios·iphone·rime
良技漫谈1 天前
Rust移动开发:Rust在iOS端集成使用介绍
后端·程序人生·ios·rust·objective-c·swift
2401_852403551 天前
高效管理iPhone存储:苹果手机怎么删除相似照片
ios·智能手机·iphone
星际码仔2 天前
【动画图解】是怎样的方法,能被称作是 Flutter Widget 系统的核心?
android·flutter·ios
emperinter2 天前
WordCloudStudio:AI生成模版为您的文字云创意赋能 !
图像处理·人工智能·macos·ios·信息可视化·iphone
关键帧Keyframe2 天前
音视频面试题集锦第 8 期
ios·音视频开发·客户端
pb82 天前
引入最新fluwx2.5.4的时候报错
flutter·ios