I just updated to Xcode 8, and I can no longer build xml2-based applications. If I build a simple file and try to build it as follows:
c++ myapp.cc `xml2-config
One "fix" that I've used, which avoids any use of sudo, is simply to filter out the -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/lib flag. In a GNU makefile, this can be done with the filter-out command. So if I build a LINK_LIBS variable, which includes $(shell xml2-config --libs), then I can filter LINK_LIBS with the following command:
LINK_LIBS := $(filter-out -L$(shell xcrun --show-sdk-path)/usr/lib, $(LINK_LIBS))
If I'm just using xml2-config, I can also just add a "--exec-prefix=/usr" argument when calling it:
c++ myapp.cc `xml2-config --cflags` `xml2-config --exec-prefix=/usr --libs`
I don't know what potential side effects of removing the SDK path from the library search string might be, but for now, these solutions seem to work for all of my applications.