首页 > 解决方案 > 从 C++ 导入时找不到“UIKit/UIKit.h”文件

问题描述

这是我的 .pro 文件

QT += quick
CONFIG += c++11
DEFINES += QT_DEPRECATED_WARNINGS
TEMPLATE = app
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += main.cpp \
    bridgingfile.cpp
ios {
    OBJECTIVE_SOURCES +=  ViewController.m
}

RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

# Additional import path used to resolve QML modules just for Qt Quick Designer
#QML_DESIGNER_IMPORT_PATH =

## Default rules for deployment.
#qnx: target.path = /tmp/$${TARGET}/bin
#else: unix:!android: target.path = /opt/$${TARGET}/bin
#!isEmpty(target.path): INSTALLS += target

HEADERS += \
    bridgingfile.h \
    ViewController.h

DISTFILES += \
    ViewController.m

当我导入目标 c 文件时出现这样的错误

/Users/workspace/SimpleIOS/ViewController.h:9: error: 'UIKit/UIKit.h' file not found
   

我是 Qt 编程的新手,我怎么能做到这一点。请帮帮我。

提前致谢

标签: qt

解决方案


我认为您应该在 pro 文件中的 ios 范围内添加 UIKit 框架:

ios: {   LIBS += -framework UIKit   OBJECTIVE_SOURCES +=  ViewController.m }

推荐阅读