I am trying to add many Objective-C files to my Swift project with folder reference mode that means when I drag and drop my files into project I am selecting "Create Folder Reference".
This is because all of my obj-c files use #include "/folder/folder/folder/" for example. These files are generated with j2objc project.
Now my problem is when I want to #import or #include some .h of these files in myproject-Bridging-Header.h Xcode can't find the header files.
I use #import "/folder/folder/folder/" like generated files but no chance.
I add $(PROJECT_DIR)/ in build settings - search header paths but it does need to write path completely like $(PROJECT_DIR)/folder/folder/folder/.
Is there any way to set main folder and Xcode find subfolders ? Or do I need to write every path separately ?
I found the answer after many days by myself!
When I drag and drop my files to my project in Xcode in mode "Create Folder Reference", just a reference to the files is added to Xcode and the files were in their folder where in my Mac.
I resolve this problem by add files to project's folder manually and then drag and drop from that location to Xcode. After that, I could access my file by its address in myproject-Bridging-Header.h like #import "/folder/folder/folder/file.h"
Related
I am facing build fail error after moving Bridging-Header
objective-c swift on xcode6.
Before I moved header file, it had been working fine.
The error shows header file not exist. The header file path remains still old path in error log. I tried build clean, but still old path remains.
How can clean the objc-header-path?
You need to update the path in your project's Build Settings to point to the new bridging header location.
Click your target and then click 'Build Settings' then search for Objective-C Bridging Header
You'll find the path to the bridging header in your target's Build Settings, under "Swift Compiler - Code Generation"/"Objective C Bridging Header".
I tried with Xcode6.1-Beta, as well.
But still impossible to update the objective-c header path.
I don't know where the configuration file is. I gave up to figure out.
Finally, I deleted the target xcode project and recreated new project.
Now it is working.
Yes it's possible.
Delete the .h file
Clear the path at Objective-C Bridging Header
Create new Objective-C File
Name your header file to the same name as before (popup will ask you to create new header file)
Goto File > Project Settings > Data Location
Make sure your path is correct and press "Done"
Your app should run again pointing to the right location of the header file and delete the files ModuleCache
Happens to me many times when i move app folder around.
I had a workspace that I was using when I had the same thing happen. I moved my project to a different folder. Despite having a relative path on my bridge headers, it was still referencing the old location when building and threw an error.
Here's what I did to fix this:
Close the workspace
Open the .xcworkspace file using TextWrangler. TextWrangler allowed me to navigate the package to /xcuserdata/[username].xcuserdatad/UserInterfaceState.xcuserstate. I did a search for the old path and found it. Make the change to the new location of the header file.
This by itself didn't fix it. After cleaning and building, the old value showed back up! Then I deleted the Build folder. It has a ModuleCache that I think was holding on to the old value as well.
After doing this, my project picked up my new value and I was able to build the project. I'm not certain step 2 is necessary. But it did store the old value in there.
In my case, I changed the path from relative path to absolute path and solved.
like
From:
project_name/project_name-Bridging-Header.h
To:
$(SRCROOT)/project_name/project_name-Bridging-Header.h
I have a project, which has a static library with references to header files like this:
#import <libetpan/libetpan.h>
I can't change this import line. What should I do, to make Xcode find those header files? I have a folder with header files, that I can import to the project. Thanks.
At the moment the error is following:
'libetpan/libetpan.h' file not found
You may have added the libetpan folder to your project (if not, do so)
right click on that folder and see the path (get info after right click)
if its not a sibling of your project file in the folder structure (check in finder), thats where its going wrong
alternately, you could add header search paths: header search path in XCode 4
I'm new in iOS development, and met this library linking problem in last few days.
I was trying to use GMGridView in a project, but cannot make it working.
This project is shipped as static library, so I just drag the xcodeproj file in my project. Then I added libGMGridView.a in Link Binary With Libraries, GMGridView in Target Dependencies. I also added the path in Header Search Paths.
However, Xcode still report .h file not found error when I tried to import GMGridView.h.
Could anyone give me a hand on this? Thanks in advance!
Had the same issue!!! Made it work!!!!
soooooooo:
copy GMGridView folder from https://github.com/gmoledina/GMGridView to your project dir
in xcode right click on any file group and choose add files
find GMGridView folder in your folder dir and choose GMGridView.xcodeproj - (dont copy, create groups not folders, add targets)
go to your project targets - search - HEADER_SEARCH_PATHS add- GMGridView/**
select Building phases in settings - choose target dependencies and add GMGridView
select Building phases in settings - link binary libraries and add libGMGridView.a
import should be:
#import "GMGridView.h"
#import <QuartzCore/QuartzCore.h>
Say I have a static library that was created with the following file structure:
Folder1
File1.h
Folder2
File2.h
Now inside of File1.h, it refers to File2.h without a path (e.g. #import File2.h). The library builds successfully. (It doesn't require the full path (i.e. #import Folder2/File2.h) because both files are part of the same project.)
Now when I include this library in another project, that #import File2.h statement no longer compiles, and I have to change it to #import Folder2/File2.h (or something similar). This means that I have to modify the original library, which is not good.
The specific error message I get is:
File2.h: No such file or directory
There doesn't seem to be a way to let it know that both files should be a part of this new project, since the only two files I see after I included the library are MyLib.xcodeproj and lixMyLib.a.
The way I included the static library in my new project is by doing the following:
Drag MyLib.xcodeproj into my new project.
Add the libMyLib.a file to my new project's target.
Add to the Header Search Paths a relative path to the home directory of my library (the folder that contains Folder1 and Folder2).
Is there any way I can have it automatically know where to find these files just as it was able to do in the library itself? I realize that I can probably add the paths Folder1 and Folder2 to the Header Search Paths of my new project, but I'm looking for a better way, since these two folders are just an example, and it could just as easily be 50 folders I would need to include. I'm looking for a solution which doesn't require me to type the paths to all 50 of those folders, if possible.
Try checking the "Recursive" checkbox next to the path to the parent folder of all those headers.
How do I add c library to Xcode Cocoa project?
Or what is the best option, I don't want to copy them into Cocoa project directory.
I have a C project called a which compiles into library a.dylib and header file a.h, the project is located in it's own directory.
I want to use this library from my objective-c application in Xcode.
How do I add the header file and library to my Xcode project?
I can drag the a.dylib into other frameworks but what do I do with a.h?
I figured it out.
I point to location of project a deployment directory (headers) to Search Path in project settings either:
as Header Search Paths, if used as <a/a.h>
or into User Header Search Paths, if used as "a/a.h"
As for library I just drag it to Xcode project and set it to refer to library instead of copy.
Here are the steps before adding a header file test.h in your project. Here is the files location root -> Library -> include -> test.h
click on build settings
Find User Header Search path. add your header file location here. add following value to Debug, Release and Any Architecture field. $(SRCROOT)/Library/include. Your project Root is the folder that contains your project, it conatins .xcodeproj file.
After adding path you will be able to add header in like this
# include "test.h"
You can drag them both the .a and .h files to Xcode, but make sure to not check the "Copy items to project folder". As for referencing the header file, you'll need to put it in a place where you can add a path to it in your #include/#import statements. Is there a reason you don't want to copy the header to your project file?