"$(SRCROOT)" recursive in XCode Library Search Path - xcode

Is it a bad or a good idea to set XCode Library Search Path to "$(SRCROOT)" recursive instead of few concert paths? Why?

Specifying the path (e.g., */Users/username/MyProject/Frameworks*) will work only if you are sure that it will stay the same no matter what. But if you change the location of your dependency, you'll have to manually update the path each time. It can happen if you e. g., want to build a project on another machine (build machine, teammate's machine, etc.)—most probably the dependency will have another path.
In order to have a dynamic path relative to the target's path, we use SRCROOT. As stated in XCode Help:
SRCROOT
Identifies the directory containing the target’s source files.
This means that by placing the dependency relative to the target's path (e. g., *$(SRCROOT)/Frameworks*), we won't need to update the path all the time.
Responding directly to your question: I'd say that if the dependency's path is relative to the target's then it's beneficial to have such dynamic path identification.
As for recursive: This just means that subfolders will be checked recursively for the path you specified; you can actually set recursive or non-recursive for any path.

Related

Where does the Go runtime look for plugins?

I want to use the Go plugin facility, and if I call plugin.Open("…") with an absolute path, this works fine. Still, the original docs give the example plugin.Open("plugin_name.so"), thus, it should also work with the simple filename.
However, the docs fail to say what is the search path for these plugins. Do the same rules apply as for any shared library? FWIW, copying my plugin to /usr/lib and calling ldconfig was not sufficient.
If an absolute path is not provided in the plugin path, it is treated as a relative path and as such is always resolved against the current, working directory. So if you pass "plugin_name.so", it must be in the working directory. Normally it is the same folder where the executable binary is, unless the binary was launched from another folder, or the working directory was changed after that.

Add linked libraries relative to a custom location in Xcode

I am using Xcode 9 to build a project that requires linking against a large number of standalone libraries (.a and .dylib files), which are all located in an arbitrary directory outside of my project.
I can build if I manually add all these libraries to Linked Frameworks and Libraries, but then I am hardcoding a relative path to this arbitrary directory.
Is there a way to add libraries to Linked Frameworks and Libraries list, but add them as paths relative to a user-defined location, perhaps a location specified as a User-Defined Build Setting?
To be specific, I have an environmental variable G3D which specifies a path. All these libraries are off of $G3D/build/libraries. But after adding the libraries to my project by dragging and dropping them, the File Inspector only lets me specify their location as being Relative to Group, Relative to Workspace, etc..
It’s possible to specify libraries relative to an arbitrary variable if I opt out of the Linked Frameworks list entirely, and specify all the link libraries using the Other Linked Flags Build Setting, but that introduces its own problems.
Well, in your Framework Search Paths in build settings, you are allowed to refer to your user-defined build setting... e.g. say you have a user-defined build setting REALM_PATH which specifies some portion of a path.
Then in your Framework Search Paths build setting, you can add some path and insert REALM_PATH by putting ${} around it. E.g.
${PROJECT_DIR}/../../External/ThirdParty/submodules/${REALM_PATH}

POEDIT : Impossible to set up the right path

I run under Max OSX.
I've installed Poedit in /Applications.
The website I have to translate is located in /Dropbox/Sites/mywebsite.
In Poedit preferences I've got to set up the base path and the path of the website. I tried many combinations and each time Poedit tells me something like "no code has been found"...
Do you know how to set up the right path ?
For the benefit of others that may stumble upon this question, the correct solution is to set it up as follows:
The "base path" should be a path relative to the PO file location, e.g. ".." or ".". If you must, and don't care about portability to other computers, use an absolute path there, but not elsewhere.
The other paths in PO file properties, must be relative to the base path and should be under the base path in the tree (i.e. the base path should be the "root").
For example, you could save PO files under languages/ and have basepath=".." and "src" and "includes" paths.
EDIT: In modern versions of Poedit (1.8 and up), you don’t have to worry about this. Just drag the paths you want to the source paths window and Poedit will generate correct settings automatically.
Ok, I found the solution.
Base path should be : "."
Website path should be : "/Users/USERNAME/Dropbox/Sites/mywebsite"
That's it! ;-)
Personally, I had a folder Catalogue->Properties->Sources Paths->Path, but this folder did not existed physically (was deleted).
It was the folder CRON/ in the picture. Simply removing the CRON/ folder in the Paths solved the issue (see picture).
Obviously, you can add back the CRON/ folder also.

Search Paths Confusion in Xcode 4.6

In Xcode I added MailCore as a subproject, and target dependency. It works great on my machine. Sadly when I share the project with another collaborator, he's unable to get the header file to show up.
Somehow his search paths have my folder names hardcoded in (as in andrewjl), is there a way to fix this in order to point to an analogous directory on his machine?
Instead of using an absolute search path, use a relative one.
"$(SRCROOT)" is where your projectfile is located.
"$(SRCROOT)/AnotherFolder" for AnotherFolder is a peer of your project file
once add this variable, to the search path (after double tapping on the searchpaths line), you can add "$(SRCROOT)/Products/MyReceipt.........." and once you dismiss the add/remove searchPath popover, you'll see where the search path is pointing to.
Your search paths are absolute paths. Write them as relative paths (relative to the project).

Xcode header inclusion conflict [duplicate]

I have a project that was compiling ok within g++(I can't see the version right now) and now on xCode it is not.
I think that I got the problem now... I have a String.h file in my project and it seems tha the xCode compiler(that is gcc) is trying to add my own string file from the < cstring >... I am not sure of it, but take a look at this picture
http://www.jode.com.br/Joe/xCode1.png
from what it looks like, it is including my own instead of the system file, I was wondering... shouldn't #include < file > be a system include? because of the < > ? and shouldn't the system include a file within its own path and not the original path of my application?
As I said, I am not sure if this is what happening because I am just migrating to osx these past 2 days...
I was going to change my class and file name to not conflict, so it would work, if this is really the problem, but I was wondering, there should be another way to do this, because now my project isn't that big so I can do this in some time, but what if the project was bigger? it would be dificult to change all includes and class names...
Any help is appreciated
Thanks,
Jonathan
i had the same problem and it was hard to solve. took my hours to fix/find out.
the problem is the headermap of xcode. and the solution - besides avoiding those kind of reserved names, which is a good idea in general, but not always possible with third-party libs - is to add
USE_HEADERMAP = NO
to your user defined settings.
kudos to these guys:
http://meidell.dk/archives/2010/05/08/xcode-header-map-files/
http://www.cocoabuilder.com/archive/xcode/262586-header-file-problem-sorry-to-bug-this-list.html
Naming your headers with the same name as standard headers like string.h and including them simply with #include <String.h> is asking for trouble (the difference in casing makes no difference on some platforms).
As you said, however, it would be difficult to try to figure out what those are in advance when naming your headers. Thus, the easiest way to do this is to set to set your include path one directory level outside of a sub-directory in which your headers reside, ex:
#include <Jonathan/String.h>
Now you don't have to worry about whether the String.h file name conflicts with something in one the libraries you are using unless they happen to also be including <Jonathan/String.h> which is unlikely. All decent third-party libraries do this as well. We don't include <function.hpp> in boost, for instance, but instead include <boost/function.hpp>. Same with GL/GL.h instead of simply GL.h. This practice avoids conflicts for the most part and you don't have to work around problems by renaming String.h to something like Text.h.
Yes, if you use
#include "file"
the local directory is looked first and
#include <file>
only the system include folders are looked.
Notice the word first only in the first case. This means that every time is included your local version should never be reached (unless you have included your source path within the INCLUDE directive).
Said that, my dummy suggestion is to rename your local file with an unambiguous name...
On OSX the filesystem is case insensitive - so String.h you can wind up with conflicts like that. String.h == string.h
it worked by changing the name from String.h to Text.h
but that makes no sense, since the std library is including it's own string.h and not mine.
I mean, makes no sense for a developer to create his files thinking of what names he can't use, for an instance, lets say I change my String.h to Text.h(I already did, I need to work and this is not letting me) ad somehow I had to include another templated library that has a include called Text.h, would I have to change my text.h again or not use this new library? there should be an alternative.
Or shouldn't it?
thanks for the help so far,
Jonathan
Two things you're running into:
As noted above, the filesystem on Mac OS is case-insensitive unless you specifically set up your filesystem to be case-sensitive.
gcc does not distinguish all that much between local and system header include paths. When you specify a directory to be added to the path via -I, that directory will be used to locate both local and system includes. Only when you use -iquote or -I- does a directory get skipped for locating system includes. Further, the builtin "system include" directories on the compiler's search path are always searched for local includes.
Note that the current directory is used for local but not system includes. In this case, I believe it's picking up String.h because the project settings explicitly add the top-level project directory to the include path.
The workaround I would suggest, rather than renaming your includes, is to put your utilities into a directory whose name is unique for your project, and specify that directory in your include directive. For example:
#include "Josk/String.h"
and make sure Josk/ itself isn't in your include search path. This way you aren't stuck with an awkward rename, though you may have to shuffle some files around in your project. You may also need to edit your project settings to make sure the parent directory of that utility directory is in your include path.
Another possibility to try is, if you see the top-level project directory added to your project's include path, remove it. This ought to keep items in your top-level project directory from being searched for system includes.
Finally, you may also be able to avoid this problem in this specific case by changing the case sensitivity of your file system. This can break some Mac applications, though, so research the issue before you embark on this – or pick a volume that nothing else is using.
This question already has some very good answers, yet none of them summarizes in all detail how the compiler will search for header files in general; or more precisely, how Xcode will make the compiler search for them.
When you include a user header, those are header files between quotes ("..."), the following search order applies:
The directory of the file performing the include.
All header search paths in the order provided.
First match inside a header map file, if headers maps are enabled.
Note that the full include path is used. So if your include is in the file foo/bar/file.c and you do a #include "subdir/header.h", then the first lookup will be foo/bar/subdir/header.h.
If that file doesn't exist, the compiler iterates the user header search paths. Those are provided by the build setting User Header Search Path (within config files or on command line it's named USER_HEADER_SEARCH_PATHS). Multiple such path can exist and again, the full include path is attached to each of them until there's a match.
If provides no match either and the build setting Use Header Maps (USE_HEADERMAP) is enabled, Xcode generates a map file of all your header files in the project and searches this map file for an entry that matches the name of the included file. In that case the path is irrelevant, as it would also match just the name of the file.
For system headers, those between spiky braces (<...>), only the search paths from the build setting System Header Search Paths (SYSTEM_HEADER_SEARCH_PATHS) are searched.
However if the build setting Always Search User Paths (ALWAYS_SEARCH_USER_PATHS) is enabled, the user search paths are also searched for system header includes. This allows you to override a system header with your own user header of the same name. Note however, that this is deprecated by Xcode and shouldn't be done anymore.
If your file system is case-insensitive, default on macOS, then case will play no role during all searches.
If you want maximum control over which file is being included, disable header maps and always include with a path relative to the file performing the include (you may use ".." as well). This avoids any ambiguity.

Resources