File not found on Xcode9.3

1k Views Asked by At

I'm currently working on a project (single view application) in Swift on Xcode using a precompiled sdk (Parrot SDK3: http://developer.parrot.com/docs/SDK3/#ios).

My issue is that I have a "file not found" error whereas the file exist:

enter image description here

The headers I try to import are written in Objective-C (but I want to import these headers in a ObjC file). I took care to write correctly the path to the header files and to avoid cyclic import. After a lot of clean/build and a lot of methods attempted I don't know what to do.

1

There are 1 best solutions below

0
On BEST ANSWER

Xcode tries to find header files (.h) with a help of "search paths" list. You can have multiple search paths in this list, for example if you have #import <a.h> in the program, and you have paths "/asd" and "/qwe" in your search path list, it will try to find the header as "/asd/a.h" or "/qwe/a.h" (it tries both).

You can add custom paths in Xcode project build settings. There's a section "Search Paths" and there you have "Header Search Paths". If your library is inside your project, then it is useful to use $(SRCPATH) variable in the path, which expands to your project root folder like so:

enter image description here

Note that if you import as <somelib/somefile.h>, and your path in "Header Search Paths" has something that ends with "include" like "/some_path/include", then the header must be at "/some_path/include/somelib/somefile.h", which is sometimes not true, because often people place header files right inside "include/", not inside "include/somelib/".

One way to solve this would be to make a symlink that points to the library "include" folder, with your custom name, and then add a parent directory of that symlink to your header paths.

For example, if you create an empty directory "libs/include/", and you have put your library files at "libs/dist/libARDiscovery/.../include", then you can create a symlink "libs/include/libARDiscovery" that points to "lib/dist/libARDiscovery/.../include", and then add "$(SRCROOT)/libs/include" to the header search paths.