Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why additional #import in bridging header failed in swift?

Before I added a new dependency to my test project via CocoaPods, I have already added a C header file ('wahoo.h') and exposed it to the swift code via a bridging header file "wahoo-Bridging-Header.h". The test app could be compiled and run without any problem.

Then I added a new dependency 'STHTTPRequest' to my project. You can see the list of file here:

enter image description here

If I added this line:

#include <STHTTPRequest/STHTTPRequest.h>

It will fail to compile with this error message:

enter image description here

I have tried a few alternatives but they all failed:

#include "STHTTPRequest.h"

#import "STHTTPRequest.h"

Apparently I cannot have more than one bridging header file in a project. How can I fix this import problem?

EDIT I can get around the problem if I copy the header file from Pods into SO1 and add #include "SO1/STHTTPRequest.h" to the bridging header. It is not an ideal solution.

How can I automate the copying of header files? Or alternatively how can make header files in Pods accessible to SO1?

like image 809
Anthony Kong Avatar asked Sep 09 '14 08:09

Anthony Kong


People also ask

Why is additional math important?

Additional Mathematics is a highly valuable learning experience for students who are comfortable with lower secondary school mathematics. It develops deeper mathematical competency and helps open multiple doors in further education for you.

Is additional math hard?

Additional Mathematics is one of the most challenging subjects at the 'O' Levels.

What is additional maths equivalent to?

Instead Additional Maths provides a Level 3 enrichment of GCSE (9–1) Mathematics, whilst at the same time providing a taster of A Level Maths and Further Maths.


2 Answers

You need to tell Xcode where to look for the header files you’re listing in the bridging header. Find the Search Paths section, and change the project-level setting for Header Search Paths, adding a recursive entry for the Pods directory. It should be Pods/** now.

In the Bridging Header include with:

#include <STHTTPRequest/STHTTPRequest.h>

or because of recursive search path:

#include <STHTTPRequest.h>
like image 136
dreamlab Avatar answered Sep 30 '22 00:09

dreamlab


You should add the following header search path: "${PODS_ROOT}/Headers/STHTTPRequest"

like image 21
Edwin Vermeer Avatar answered Sep 30 '22 00:09

Edwin Vermeer