4 Replies
      Latest reply on May 15, 2019 2:09 AM by eskimo
      furkanfromberlin Level 1 Level 1 (0 points)

        Hello friends,

         

        I installed over brew.sh libpcap (bundle of h.files). I tried to compile a simple c.file and after that I deleted libpcap over brew.sh again.

         

        My Problem is, after I compiled the c.file, Xcode included the library in his own system library. So even if I uninstalled libpcap over brew.sh it exists in Xcode.

         

        Do you know, how I could delete all the related .h files?

         

        Regards

        Furkan

        • Re: delete .h files
          jonprescott Level 2 Level 2 (70 points)

          There is a libpcap and header files in the standard system libraries (located in Xcode.app/Contents/Developer/...).  These are the pcap files being referenced in Xcode after you deleted the versions from brew. 

            • Re: delete .h files
              furkanfromberlin Level 1 Level 1 (0 points)

              Do you mean, that Xcode doas already have the pcap files. Even if I would not installed libpcap over brew.sh?

                • Re: delete .h files
                  jonprescott Level 2 Level 2 (70 points)

                  Yes

                  • Re: delete .h files
                    eskimo Apple Staff Apple Staff (11,325 points)

                    To expand on jonprescott’s response…

                    When you build a product with Xcode, it’s built against an SDK.  Each SDK is an amalgam of all the headers and libraries associated with a particular version of a platform.  This is a key part of Xcode’s ability to do cross-platform builds, for example:

                    • An app that uses macOS 10.14 features while running on macOS 10.13

                    • An iOS app even though it’s running on macOS.

                    In modern versions of Xcode these SDKs are built in to Xcode.  For example, Xcode 12.2 contains SDKs for macOS 10.14, iOS 12.2, watchOS 5.2, tvOS 12.2, and various simulator platforms.  If you installed Xcode in the usual place, you can see a list of these SDKs as follows:

                    $ ls -l /Applications/Xcode.app/Contents/Developer/Platforms/*.platform/Developer/SDKs/

                    libpcap is a supported API on macOS, so its headers and stub library are included in the macOS SDK:

                    $ find /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -name "*pcap*"
                    …
                    …/MacOSX.sdk/usr/include/pcap
                    …/MacOSX.sdk/usr/include/pcap/pcap-util.h
                    …/MacOSX.sdk/usr/include/pcap/pcap.h
                    …/MacOSX.sdk/usr/include/pcap-bpf.h
                    …/MacOSX.sdk/usr/include/pcap-namedb.h
                    …/MacOSX.sdk/usr/include/pcap.h
                    …/MacOSX.sdk/usr/lib/libpcap.tbd
                    …/MacOSX.sdk/usr/lib/libpcap.A.tbd

                    Note Each .tbd file is a stub library.  Xcode uses this at link time as a stand-in for the shared library that get used at runtime.

                    Unless you need specific features that aren’t supported by the built-in libpcap, I recommend that you avoid installing your own version and instead use the system’s.  This is as simple as:

                    1. Including the header:

                      #include <libpcap.h>

                      .

                    2. Adding libpcap.tbd to the Link Binary With Libraries build phase in your target.

                    Share and Enjoy

                    Quinn “The Eskimo!”
                    Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                    let myEmail = "eskimo" + "1" + "@apple.com"