FindLibraryInLibrarySearchPaths(
            XcodeBuilder.Target target,
            C.ICommonLinkerSettings settings,
            string libname)
        {
            foreach (var searchPath in settings.LibraryPaths)
            {
                var realSearchpath = searchPath.Parse();
                // some lib paths might not exist yet
                if (!System.IO.Directory.Exists(realSearchpath))
                {
                    continue;
                }

                var results = SearchForLibraryPath(realSearchpath, libname);
                if (null != results)
                {
                    return(CreateLinkableReferences(
                               target,
                               results.Item1,
                               results.Item2,
                               XcodeBuilder.FileReference.ESourceTree.Absolute));
                }
            }
            return(null);
        }
        CreateLinkableReferences(
            XcodeBuilder.Target target,
            string pathToLibrary,
            XcodeBuilder.FileReference.EFileType type,
            XcodeBuilder.FileReference.ESourceTree sourcetree)
        {
            var fileRef = target.Project.EnsureFileReferenceExists(
                Bam.Core.TokenizedString.CreateVerbatim(pathToLibrary),
                type,
                true,
                sourcetree);
            var buildFile = target.EnsureFrameworksBuildFileExists(
                fileRef.Path,
                type);

            target.Project.MainGroup.AddChild(fileRef);
            return(buildFile);
        }
        FindLibraryInSDKSearchPaths(
            XcodeBuilder.Target target,
            C.ICommonLinkerSettings settings,
            string libname)
        {
            var meta       = Bam.Core.Graph.Instance.PackageMetaData <Clang.MetaData>("Clang");
            var searchPath = System.String.Format("{0}/usr/lib", meta.SDKPath);
            var results    = SearchForLibraryPath(searchPath, libname);

            if (null != results)
            {
                return(CreateLinkableReferences(
                           target,
                           results.Item1.Replace(meta.SDKPath, string.Empty).TrimStart(new [] { '/' }),
                           results.Item2,
                           XcodeBuilder.FileReference.ESourceTree.SDKRoot));
            }
            return(null);
        }