简体   繁体   English

在 Swift 包管理器中找不到“framework/header1.h”文件

[英]'framework/header1.h' file not found in Swift Package Manager

I have an existing Objective C framework that is using the Carthage for building.我有一个使用Carthage进行构建的现有 Objective C 框架。 I am supporting the Swift PM for the existing Objective C framework and implemented the Swift PM using the below command in the current project.我支持现有 Objective C 框架的 Swift PM,并在当前项目中使用以下命令实现了 Swift PM。

swift package init

This command is initializing the Swift PM and creating the package.swift and I have configured it.这个命令正在初始化 Swift PM 并创建 package.swift 并且我已经配置了它。

When I ran the Swift Package Manager in Xcode I got the error "framework/header1.h" file not found,当我在 Xcode 中运行 Swift Package Manager 时,我收到错误“framework/header1.h”文件未找到,

When I changed the import statement as @import framework;当我将导入语句更改为@import framework;

it's working fine for Swift Package Manager , but when I opened the .xcproject file of the framework in Xcode, its give me an error "Module framework not found".它对Swift Package Manager工作正常,但是当我在 Xcode 中打开框架的 .xcproject 文件时,它给了我一个错误“找不到模块框架”。

Is there any way to import the header or framework, so that it will work fine for both Swift PM as well as Carthage ?有什么方法可以导入头文件或框架,以便它对Swift PMCarthage都能正常工作?

After burning head for more than two days found two solutions for the above problem.经过两天多的烧头,针对上述问题找到了两种解决方法。

  1. You can use the preprocessor definition SWIFT_PACKAGE您可以使用预处理器定义SWIFT_PACKAGE
 #if SWIFT_PACKAGE #import "header1.h" #else #import <framework/header1.h> #endif

2. Add the public header files in 2.添加公共头文件

Project setting > Build Phases > Headers > Public

Add publicHeadersPath in the Target section and make sure that Swift Package Library name in Package.swift must be the same as per the project framework .在 Target 部分添加publicHeadersPath并确保 Package.swift 中的Swift Package Library名称必须与项目框架相同。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift Package 管理器 - 桥接 Header,找不到文件 - Swift Package Manager - Bridging Header, File Not Found Swift 框架:Umbrella header '[...].h' 未找到 - Swift Framework: Umbrella header '[...].h' not found 将 Firebase 与 Swift-Package-Manager 集成时找不到“openssl/arm_arch.h”文件 - 'openssl/arm_arch.h' file not found when integrating Firebase with Swift-Package-Manager Swift Package Manager-自定义框架 - Swift Package Manager - Custom Framework 致命错误:找不到“clipboard_manager/clipboard_manager-Swift.h”文件 - fatal error: 'clipboard_manager/clipboard_manager-Swift.h' file not found 在“框架”-Swift.h 文件中找不到模块 - Module not found inside 'Framework' -Swift.h file 未找到swift 3 xcode 8&#39;MBProgressHUD.h&#39;文件无法导入桥接头&#39;/myPath/myProj/myProj/myProj-Bridging-Header.h&#39; - swift 3 xcode 8 'MBProgressHUD.h' file not found failed to import bridging header '/myPath/myProj/myProj/myProj-Bridging-Header.h' Swift 包管理器中的 SWIFT_OBJC_BRIDGING_HEADER - SWIFT_OBJC_BRIDGING_HEADER in Swift Package Manager iOS - “&#39;Foundation/Foundation.h&#39; 文件未找到” Swift 项目内部自定义框架中的错误 - iOS - “'Foundation/Foundation.h' file not found” Error Inside Custom Framework Inside Swift Project 包含非模块化标头和在带有AWS开发工具包的Swift中找不到sqlite3.h的文件 - Include of Non Modular Header and file not found for sqlite3.h in Swift with AWS SDK
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM