Xcode warning with non-standard Framework ld: warn

2019-05-28 21:57发布

问题:

Cleaning up warnings, I could see the following:

ld: warning: directory not found for option '-F/myPath/etc/myframework'

This was happening with non-standard iOS frameworks. How to eliminate the warning?

回答1:

Checking the man page of the linker ld shows the following detail for the -Fdir option:

Add dir to the list of directories in which to search for frameworks. Directories specified with -F are searched in the order they appear on the command line and before the default search path. In Xcode4 and later, there can be a space between the -F and directory.

Sure enough, checking the project.pbxproj showed the missing folder:

FRAMEWORK_SEARCH_PATHS = (
                    "\"$(SDKROOT)/Developer/Library/Frameworks\"",
                    "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
                    "\"myPath/etc/myframework\"",
                );

So, I thought the whole deal with frameworks was that they avoided all this hassle. Well, that's true for standard frameworks, i.e. the SDK ones. For anything else, more tweakery is required. From Framework Programming Guide:

Locating Frameworks in Non-Standard Directories

If your project links to frameworks that are not included in any of the standard locations, you must explicitly specify the location of that framework before Xcode can locate its header files. To specify the location of such a framework, add the directory containing the framework to the “Framework Search Paths” option of your Xcode project. Xcode passes this list of directories to the compiler and linker, which both use the list to search for the framework resources.

Note: The standard locations for frameworks are the /System/Library/Frameworks directory and the /Library/Frameworks directory on the local system.

Turns out in Xcode's Build Settings, there is a specific entry for Framework Search Paths.

Adding the generic catch-all entry of $(SRCROOT) as per the answer to this question did the business and eliminated the warnings. Oh, and don't forget to set the drop down to "Recursive".