本文介绍: 目前关于ios qt开发资料比较少,这里整理了几个比较重要的开发要点基于MacOS14 + Xcode15 + Qt15.5 + cmake + iphone真机。实测设置OPENSSL_ROOT_DIR无效这里可以手动指定相应的cmake变量,在FindOpenSSL.cmake做相应的修改解决方法:在qmake构建步骤添加额外参数。并在CMakeLists.txt添加解决方法添加cmake参数

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

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

  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()
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

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

原文地址:https://blog.csdn.net/binzhongbi757/article/details/134565798

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_15395.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注