[英]'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 PM和Carthage都能正常工作?
After burning head for more than two days found two solutions for the above problem.经过两天多的烧头,针对上述问题找到了两种解决方法。
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.