30

All of a sudden today I get an unexpected problem with Xcode (5).

This is how I normally add an external framework:

Drag-n-drop the file (xxx.framework etc) (or the folder which contains the file) into the project manager. In "Choose options for adding files" I check "Copy items into destination (if needed)" only if needed (if the files are already in the project's folder I don't do this) In "Folders" I select Create groups for any added folders And I add it to my app target.

Normally this would also add the relative path(s) to the framework in Build Settings/Framework Search Paths and Library Search Paths.

However today the path that shows up there is direct (aka absolute). This breaks stuff down the line because the paths should be relative. How come Xcode does this all of a sudden? I suspect it might have to do with this one project only (it comes from a 3rd part dev) and something about their project setup could be causing this.

Jonny
  • 15,955
  • 18
  • 111
  • 232
  • 1
    What I have to do now is to manually go into the build settings and replace the direct paths with relative paths. I've also seen that if using quotes around the paths, that might be broken later as Xcode sometimes adds backslashes before those quotes. When that happens the paths will become invalid, and builds will fail because it can't find those libraries/frameworks. Why do these kinds of errors pop up all of a sudden...... sigh – Jonny Oct 01 '13 at 06:20
  • 20140325 update: As of just now when adding a static library (drag n dropping) into a project, it seems that a *relative* path is finally added to Library Search Paths. So it seems that this issue is fixed in Xcode. – Jonny Mar 25 '14 at 02:21

2 Answers2

49

I faced the same issue. There is a simple fix. Go to framework search paths. Remove everything from there. Add ./ and make it recursive. That's it.

Gautam Jain
  • 2,913
  • 30
  • 25
  • This isn't too bad really. If troubles turn up you could make one folder for complete recursion contents, and one folder without that - maybe parts of your code would need different versions of one and the same library. Still Xcode adds absolute paths when adding frameworks/libraries and to keep things clean I still always have to manually remove those. – Jonny Dec 11 '13 at 02:14
  • 1
    @jonny - Exactly. The problem is that Xcode is adding absolute paths when adding libraries. So if you share your code with someone, they get unnecessary errors. To avoid those, we add ./ , making it recursive – Gautam Jain Dec 11 '13 at 14:03
  • 2
    Also note that, if using Cocoapods, the $(inherited) entry shouldn't be removed. – LazarusX Dec 13 '13 at 17:48
  • 13
    ./ Only works if you develop alone. In a git repository environment I prefer $(SRCROOT), which can change per user. – Peteee24 Mar 10 '14 at 11:31
  • @Peteee24 Aye, you are right there! I found a discussion thread [here](http://www.politepix.com/forums/topic/project-can-find-the-openears-framework-headers-but-not-slt/#post-1018634) which is kinda helping! – Ajith Renjala Mar 20 '14 at 11:12
2

I am having the same problem on XCode 5, so far the best solution is to modify the path of your framework search.

Go to your project

Build settings->Framework search path

Add the relative path to your framework.

If it was correctly copied now you can modify the path, to something like this:

./MyProject/Libraries/ACoolLibrary

Supposing a file structure like this:

-MyProject.xcodeproj

-MyProject

--Libraries

-----ACoolLibrary

-------- TheCoolLibrary.framework

Community
  • 1
  • 1
EhTd
  • 3,260
  • 4
  • 19
  • 18
  • 2
    Well that is what I suddenly have to do manually for this one project. The point is I'd like it to add the relative paths on its own like it always did. I never really had to bother about this so I'm not sure but I have it look like this: `$(SRCROOT)/ads/AID`. No quotes or anything (no spaces in the path) because I noticed that Xcode5 breaks quotes after a while, adding some backslashes which really messed up things even more. – Jonny Oct 10 '13 at 01:14
  • 1
    Same problem here - it added six extra slashes to each end of the path. In another project, I added a couple of frameworks to "Link Binary With Libraries" Build Phase and it added an extra slash to each path. Makes me think I am going crazy - everything working, and suddenly not working! I end up going into the pbxproj file itself to correct the paths. – GTAE86 Oct 11 '13 at 16:20