Search code examples
xcode9.1

Xcode 9.1 export fails with "The /usr/bin/xattr tool may be damaged"


Xcode 9.0.1 crash when export ipa or upload to App Store in MacOS 10.13.1.

After upgraded to Xcode 9.1 (9B55), it shows error as below when export.

Stripping extended attributes failed.
"/usr/bin/xattr -crs /var/folders/mm/h01jykrs7gv9w7jjb0yt609w0000gp/T/XcodeDistPipeline.Uay/Root/Payload/GitSmartHome.app" exited with a non-zero status. The /usr/bin/xattr tool may be damaged.

It seems xattr was damaged, and when run xattr in Terminal, it prompts below error.

xattr
Traceback (most recent call last):
  File "/usr/bin/xattr-2.7", line 7, in <module>
    from pkg_resources import load_entry_point
  File "build/bdist.macosx-10.13-intel/egg/pkg_resources/__init__.py", line 3019, in <module>
  File "build/bdist.macosx-10.13-intel/egg/pkg_resources/__init__.py", line 3003, in _call_aside
  File "build/bdist.macosx-10.13-intel/egg/pkg_resources/__init__.py", line 3032, in _initialize_master_working_set
  File "build/bdist.macosx-10.13-intel/egg/pkg_resources/__init__.py", line 655, in _build_master
  File "build/bdist.macosx-10.13-intel/egg/pkg_resources/__init__.py", line 963, in require
  File "build/bdist.macosx-10.13-intel/egg/pkg_resources/__init__.py", line 849, in resolve
pkg_resources.DistributionNotFound: The 'xattr==0.6.4' distribution was not found and is required by the application

How to fix it or re-install xattr?


Solution

  • Xcode always looks at /usr/bin/xattr, regardless of your paths (as you might have a working xattr installed elsewhere).

    Typing in /usr/bin/xattr gave this output:

    /usr/bin/xattr
    Traceback (most recent call last):
      File "/usr/bin/xattr-2.7", line 7, in <module>
        from pkg_resources import load_entry_point
      File "build/bdist.macosx-10.12-intel/egg/pkg_resources/__init__.py", line 72, in <module>
      File "build/bdist.macosx-10.12-intel/egg/packaging/requirements.py", line 59, in <module>
    TypeError: __call__() takes exactly 2 arguments (1 given)
    

    You need to get your system's python happy again. I seem to have broken mine at some point. Not sure how.

    I ran the following and got a screen full of errors.

    /usr/bin/python -m pip install -U setuptools
    

    Afterwards, I ran /usr/bin/xattr again it it was silent. This seems to be the test for whether it's healthy.

    My XCode exports now without the error.

    The crux is that your /usr/bin/xattr will give you some kind of error, whether it's permissions or some other python/setup issue. You need to fix that to have your builds working again.

    Edit: For those with permission issues, run this:

    sudo chown -R $USER:$(id -g) /Users/$USER/Library/Python