Compile error on OSX 10.10 and Xcode 7.2 when Command Line Tools are installed

Issue #163 resolved
Ronald Oussoren
repo owner created an issue

pyobjc-framework-Cocoa fails to build on OSX 10.10 when the Command Line Tools for Xcode package is installed.

yosemite:pyobjc-framework-Cocoa-3.1.1 ronald$ python3.5 setup.py build_ext
running build_ext
building 'Foundation._Foundation' extension
/usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -Ibuild/temp.macosx-10.6-intel-3.5/pyobjc-include -I/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c Modules/_Foundation.m -o build/temp.macosx-10.6-intel-3.5/Modules/_Foundation.o -DPyObjC_BUILD_RELEASE=1010
In file included from Modules/_Foundation.m:15:
Modules/_Foundation_protocols.m:14:28: error: cannot find protocol declaration
      for 'NSProgressReporting'
    p = PyObjC_IdToPython(@protocol(NSProgressReporting)); Py_XDECREF(p);
                           ^
Modules/_Foundation_protocols.m:15:28: error: cannot find protocol declaration
      for 'NSURLSessionStreamDelegate'
    p = PyObjC_IdToPython(@protocol(NSURLSessionStreamDelegate)); Py_XDECREF(p);
                           ^
2 errors generated.
error: command '/usr/bin/clang' failed with exit status 1

Reported by Diez B. Roggisch on the pyobjc-dev mailing list.

Comments (5)

  1. Ronald Oussoren reporter

    The inline patch below fixes the issue for me, but is not tested beyond this particular setup.

    yosemite:pyobjc-framework-Cocoa-3.1.1 ronald$ diff -u pyobjc_setup.py.orig pyobjc_setup.py
    --- pyobjc_setup.py.orig    2016-08-07 04:03:55.000000000 -0700
    +++ pyobjc_setup.py 2016-08-07 04:13:22.000000000 -0700
    @@ -284,6 +284,9 @@
         except (ImportError, NameError):
             pass
    
    +
    +
    +
         cc = oldcc = get_config_var('CC').split()[0]
         cc = _find_executable(cc)
         if cc is not None and os.path.basename(cc).startswith('gcc'):
    @@ -377,6 +380,16 @@
         if 'clang' in get_config_var('CC'):
             cflags.append('-Wno-deprecated-declarations')
    
    +    CFLAGS = get_config_var('CFLAGS')
    +    if '-isysroot' not in CFLAGS and os.path.exists('/usr/include/stdio.h'):
    +        # We're likely on a system with de Xcode Command Line Tools.
    +        # Explicitly use an SDK
    +        data = os.popen('xcodebuild -version -sdk macosx Path').read()
    +        data = data.strip()
    +        if data:
    +            cflags.append('-isysroot')
    +            cflags.append(data)
    +
         #if os_level != '10.4':
         #    if os.path.exists('/usr/include/stdio.h'):
         #        # only tweak the SDK when using the command-line tools
    
  2. Log in to comment