简体   繁体   中英

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

I have an existing Objective C framework that is using the Carthage for building. 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.

swift package init

This command is initializing the Swift PM and creating the package.swift and I have configured it.

When I ran the Swift Package Manager in Xcode I got the error "framework/header1.h" file not found,

When I changed the import statement as @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".

Is there any way to import the header or framework, so that it will work fine for both Swift PM as well as Carthage ?

After burning head for more than two days found two solutions for the above problem.

  1. You can use the preprocessor definition SWIFT_PACKAGE
 #if SWIFT_PACKAGE #import "header1.h" #else #import <framework/header1.h> #endif

2. Add the public header files in

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM