0

I'm relatively new to mac and now trying to setup a dev. environment for Cordova based iOS app. I'm using Yosemite 10.10.3

I've installed xcode 6.3.1 and the commandlinetools for 6.3.1, under /Applications/Xcode.app/Contents/Developer/ I can see usr/bin and usr/lib, also xcode-select -p is pointing to this path, so I think the command line tool is fine.

However, when I run xcodebuild I got command not found. I've manually added the path above into the PATH environment variable to make xcodebuild visible, but not sure why this is needed, I thought the installation should have taken care of this.

Then when xcrun was executed in certain script ( npm install -g ios-deploy ), I got the following error:

dyld: Library not loaded: @rpath/libxcrun.dylib referenced from /usr/bin/xcrun, reason: image not found.

I see xcrun is available in /usr/bin as well as in the usr/bin under command line tool installation path. But the libxcrun.dylib is only available in the installation path.

I manually copied this dynamic library to /usr/lib and xcrun worked.

Though it seemed working but I got suspicious, such manual actions shouldn't be the normal post-installation procedure, should they?

Is there something I forgot to do after the command line installation? What if there's more such little files I need to copy/move around? Can I simply specify the installation path somewhere?

BTW, I added the install path/usr/lib into PATH, but didn't work with xcrun, had to copy the .dylib.

There's other mac which the Xcode and CLT were upgraded from previous version, and there no such issue.

Hunter
  • 1
  • 3
  • I've tried removing and reinstalling of Xcode, or the CLT, neither worked. I've removed macports to make sure there's no conflicts. I've also removed what was added into PATH to reproduce the issue. Upon typing gcc in terminal, I get the same error as in title, since xcrun was called. I've also tried otool -l libxcrun.dylib, where in the load commands I couldn't find LC_RPATH ....... so this means @rpath was empty? – Hunter May 08 '15 at 08:46
  • Using otool -l I've found xcrun is using @executable_path, therefore when I copy xcrun into the CLT usr/bin folder and execute in terminal it works fine. But somehow gcc is only calling /usr/bin/xcrun ....... even when I used the one in CLT usr/bin ...... otool shows it's using /usr/lib/libSystem.B.dylib. How can I have gcc calling CLT usr/bin/xcrun? – Hunter May 08 '15 at 11:45
  • Now I'm pretty stuck. gcc is calling /usr/bin/xcrun and I don't know why the location is using absolute path, the gcc comes with CLT 6.3.1 ........ – Hunter May 08 '15 at 15:24
  • I added environment variable DEVELOPER_DIR and set to the active developer path ( xcode.app/contents/developer ), somehow xcrun is checking this instead of xcode-select. Now execute xcrun seems working. Then I added environment variable DYLD_LIBRARY_PATH to CLT/usr/lib, in terminal gcc also works. But, when I run npm install -g ios-deploy, the library not loaded error comes up again! still referenced from /usr/bin/xcrun. – Hunter May 09 '15 at 15:22

1 Answers1

0

Well, after some try-out I've got ios-deploy installed by npm. I'm not sure if what I did is preferred resolution, to me it's more like a workaround.

First of all, as far as I see, if it was upgraded from previous version of CLT or Xcode, such issue doesn't exist, though all the executable behaviour are the same.

e.g. /usr/bin/xcrun will be used, and /usr/lib doesn't have libxcrun.dylib, while @executable_path=../lib, meaning xcrun is looking for library in the ../lib location.

Normally the library not loaded error is expected, but somehow with the upgraded case some hidden setting told xcrun to search for library in the correct path.

I've tried DYLD_LIBRARY_PATH, worked with gcc and xcrun but didn't work with npm install. I can only fix the error by copying the lib file to /usr/lib at the moment.

Well, I'm still getting "cannot infer developer directory from our own path (/usr/bin/xcrun)" warning, even though I've set DEVELOPER_DIR to the correct one, and xcode-select -p shows the same.

But this warning seems not doing harm to npm install -g ios-deploy ...... therefore I can live with it for now.

So the mystery persisted. I still don't know why /usr/bin/xcrun has to be used instead of CLT/usr/bin/xcrun, I still don't know how in the upgraded case /usr/bin/xcrun managed to locate the correct lib file and didn't throw any warning. What's the difference between the new installation and upgrade?

This answer is just providing a workaround to continue without recreating everything on the machine.

Additional information:

As shown in comments, afterwards I found ios-sim is not working, always crash with exception, thus I had to reinstall OS and started over. The issue disappeared. Now the only difference I can remember, is I installed mac ports in between of OS and xcode during last time. My recommendation would be, install Xcode right after the OS to avoid unexpected system changes.

Hunter
  • 1
  • 3
  • The next day I figured ios-sim couldn't start, always failed with "Launch path not accessible" exception. I guess something is still wrong with the local environment. I now have the OS reinstalled to start over, and now I can see /usr/bin/xcrun and /usr/bin/gcc come with OS. At this moment they cannot be executed, typing in terminal would have a pop-up asking for CLT/Xcode installation. Now I'm installing Xcode 6.3.1. – Hunter May 13 '15 at 06:55
  • Well, turned out everything works fine. I don't need to put any environment variable, no need to specify path. /usr/bin/xcrun can be executed smoothly , as well as /usr/bin/gcc. The library not loaded error is gone. Now looking back, I can only remember installing mac ports before xcode, and that's the only tool might change some system settings. – Hunter May 13 '15 at 10:35