Search code examples
xcodebuildenvironment-variablesanacondald

Anaconda breaks command line Xcode builds


When Anaconda is installed on a Mac, it sets environment variable LD=/anaconda3/bin/x86_64-apple-darwin13.4.0-ld.

When running an Xcode build from command line (like building a Carthage dependency), the value of LD gets inserted into the linker command:

Ld /Users/maxim/Library/Caches/org.carthage.CarthageKit/DerivedData/10.1_10B61/GeoJSONMap/0.0.8/Build/Intermediates.noindex/ArchiveIntermediates/GeoJSONMap/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GeoJSONMap.framework/GeoJSONMap normal arm64 (in target: GeoJSONMap)
    cd /Users/maxim/Carthage/Checkouts/GeoJSONMap
    export IPHONEOS_DEPLOYMENT_TARGET=11.0
    /anaconda3/bin/x86_64-apple-darwin13.4.0-ld -arch arm64 -dynamiclib <... skipped for brevity ...>

...which results in ld: unknown option: -dynamiclib.

So, the question is: how to avoid this interference in a proper way? Is it possible to get the variable LD out of Xcode build process? Is it possible to configure Anaconda to use some other variable instead? Is there a way to unset Anaconda setting temporarily when running Xcode builds? What is the intended value of LD that Xcode expects?


Solution

  • With conda versions greater than or equal to 4.5 (I think), it should be sufficient to run

    conda deactivate
    

    to remove conda-specific environment variable settings from your shell. You may need to run conda deactivate several times if you have environments other than the base one activated.