title: xcodebuild -- iOS -- Linking wrong dylib
body: <p>I'm trying to use xcodebuild to compile an iOS project.  The project builds fine via XCode GUI; however, the builds fails with xcodebuild.</p>
  
  <p>The problem seems to be that the project requires libiconv.dylib and xcodebuild links it against the wrong library location. Like its looking for the library at /sw/lib/ which contains the x86 versions, and not linking against the armv7/6 versions contained inside XCode.</p>
  
  <p>My question is how do I tell Ld to look into the SDK directory and not /sw/lib/?????</p>
  
  <p>Here's the build command:</p>
  
  <pre><code>xcodebuild -project MyProject.xcodeproj -target "release_iphone" -configuration Release -sdk "iphoneos7.0" PROVISIONING_PROFILE="${PROJ_PROF_UUID}"
  </code></pre>
  
  <p>And here's the error I receive:</p>
  
  <pre><code>ld: warning: ignoring file /sw/lib//libiconv.dylib, file was built for x86_64 which is not the architecture being linked (armv7s): /sw/lib//libiconv.dylib
  Undefined symbols for architecture armv7s:
    "_iconv_open", referenced from:
        l2451 in libscanditsdk-iphone-3.1.1.a(mirasense.o)
    "_iconv", referenced from:
        l2451 in libscanditsdk-iphone-3.1.1.a(mirasense.o)
    "_iconv_close", referenced from:
        l2451 in libscanditsdk-iphone-3.1.1.a(mirasense.o)
  ld: symbol(s) not found for architecture armv7s
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <p>Things I've tried:</p>
  
  <ul>
  <li>workspace/scheme vs project/target</li>
  <li>re-adding libiconv.dylib to "Link Binary with Libraries"</li>
  <li>adding the SDK directory to "Library Search Paths"</li>
  <li>adding "-isysroot $SDKROOT" to the "Other Linker Flags"</li>
  </ul>