ld: building for iOS Simulator, but linking against dylib? - ios

I'm having a issue compiling my app for Simulator. In the device runs perfectly but once I tried it to compile in simulator I get the following error:
ld: building for iOS Simulator, but linking against dylib built for MacOSX file '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest' for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I checked before posting this question, but the answers I found in stackoverflow, like to run this,
export PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xct‌oolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH
or
The problem was that Xcode 5 replaces gcc with clang and adds in a "-triple" option that specifies OSX as the target. If you pass "-miphoneos-version-min=7.0" on both gcc command lines it works. You can see the clang command line if you pass "--verbose" to gcc. It's also necessary to add to the PATH for Xcode 5 so that cmake can find the necessary tools: export PATH=/Applications/Xcode5-DP6.app/Contents/Developer/Toolchains/XcodeDefault.xct‌​oolchain/usr/bin:/Applications/Xcode5-DP6.app/Contents/Developer/usr/bin:$PATH None of this is official.. but works for me so far.
I dont really understand how to to do this. Any help, please?

Check Build Settings for your test target. This values should look similar:
If you have any escaped symbol, consider to fix it. I had here : \". I just removed them
Also notice: order is important!
P.S. from GraehamF It's always a good thing to Build -> Clean and restart Xcode, so the changes to take affect

When I faced this error with an XCode project, I open the file ???.xcodeproj (in a SubLime Text editor) and removed the below lines. The warning will no longer be there!
LIBRARY_SEARCH_PATHS = (
"\"${PROJECT_DIR}/../../../../../usr/lib\"/**",
"\"${PROJECT_DIR}/../../../../../usr/lib\"/**",
);

Related

Xcode 7 simulator error "duplicate symbols for architecture x86_64"

My development environment with Xcode 7.2.1, CocoaPods 1.0.0 and GoogleMaps 1.13.2
I can build code successful to generate a XXX.ipa file and install in my iPhone 6 Plus to work correctly.
But when I run Xcode simulator by item "iPhone 6" or "iPhone 6 Plus" always get the information as below
"xxxx duplicate symbols for architecture x86_64" "linker command
failed with exit code 1 (use -v to see invocation)"
I use the following solutions still can't fix it
Build Options -> Enable Bitcode -> set "No"
Remove -ObjC from Other Linker Flags
project Targer -> Build phases -> compile sources, ckeck no duplicate files
Make sure I haven't #imported a .m file
I am wondering if there are any other method to solve this, help would be appreciated thanks.
This error generally occurs when you have linked any library or file twice.
In the error desciption, the name of the duplicated file will be listed, you can search and and make sure you don't have duplicates.
If you find duplicates, remove reference to one of them to play safe
I have faced similar kind of issue.
In my application I have run my code and created ipa before two day. And today when I am trying to run same code without any changes I am getting:
ld: 102 duplicate symbols for architecture x86_64 clang: error: linker
command failed with exit code 1 (use -v to see invocation)
The solution for this duplication Linker error can be solved by Remove all of your classes from compile sources, then click the + button and search for the term '.m'. Highlight every class, then click add. Build and run again.
This problem can also be occurred in case you import ".m" file instead of ".h" by mistake. I know it may be seemed as a stupid advise but this is what I had done in my case.
I resolved this issue by removing the -all_load flag in the Build Settings-> Other Linker flags.

Error while compiling iOS app with openCV framework on real device

With latest open cv framework i am unable to compile code on IOS device. i am facing following error.
Undefined symbols for architecture arm64:
"_png_init_filter_functions_neon", referenced from:
_png_read_filter_row in opencv2(pngrutil.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Same app is able to compile for simulator but not for ios devices. Can any one tell me why i am facing this problem. Thanks in advance.
I had fixed this problem.The core of this problem is that we recompile some content in libpng,maybe it exits in other ios framework.Then it makes a conflict.Opncv 3.1 has 3rdparty in it's code.What you should do is find the lines 117-121 in libpng's pngpriv.h.Then just follow Iphone - device - linker error.
It appears that this commit fixes the issue, while still keeping NEON support for iOS devices:
https://github.com/opencv/opencv/commit/262a52f3063c50fbb1236e2cba2bd3c68f9979bb
Essentially, the clause that appends -DENABLE_NEON=ON to the cmake line was only applying to architectures beginning with "armv" (note the "v"); the above commit changes opencv/platforms/ios/build_framework.py to allow the cmake command to work with "arm64" as well.
Before:
if arch.startswith("armv"):
cmakecmd.append("-DENABLE_NEON=ON")
After:
if arch.startswith("armv") or arch.startswith("arm64"):
cmakecmd.append("-DENABLE_NEON=ON")
Diagnostic process, since it might be useful:
Found this by starting a script build.log before invoking python ../opencv/platforms/ios/build_framework.py ios and digging through output; arm_init.c was not built for arm64 (which is where png_init_filter_functions_neon was defined) but was for armv7 and armv7s. From there, looking through 3rdparty/libpng/CMakeLists.txt pointed at ENABLE_NEON not being set.
I faced the same problem as #shahzaib described. In simulator it works but in iPhone its not working and showing the same error.
Previously I manually added OpenCV 3.1 in my iOS project. Later I changed it and install the OpenCV library via cocoapod https://cocoapods.org/pods/OpenCV
And in cocoapod there is 3.1.0.1 version which fixed the issue.
pod 'OpenCV', '~> 3.1.0.1'

Having issue with AR on iOS 7 and Xcode 5

I developed a project with ninevehGL engine and vuforia sdk , every thing worked fine on xcode 4 , and iOS 6 , but today I compile my project and got two different strange errors :
ld: warning: directory not found for option '-L/Users/MK/Documents/Xcode project /CarShowcase/Qualcomm'
ld: library not found for -lQCAR
clang: error: linker command failed with exit code 1 (use -v to see invocation)
or
Lexical or preprocessor issue 'QCAR/Tool.h' file not found
I checked header path and everything is OK ! but is there any solution to fix these issues ?
Lover,
Go to-> Target-> Build Phases -> Link Binary with Libraries,
Here you will see, your missing libraries in red colour, indicating the libraries not found, just remove these. & add gain using "+" button -> Add Other, and then locate the libraries. Hope this will help.

Cannot Archive when a library is included in my own iOS custom framework

I created my own iOS framework by following this tutorial, https://code.google.com/p/ios-static-framework/, which uses a static library template and aggregate target with a custom run script to create a framework.
At first it works fine. After including another library in the framework project creates the error when archive or build for device. I think the problem is with some wrong settings for that library. But I just don't know what to try. I have tried setting some sensible Other Linker Flags from https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/ld.1.html , but no luck. Can anyone help please ;(
What steps will reproduce the problem?
Follow the tutorial, but change the Aggregate script architecture from armv6 armv7 to armv7 armv7s. Here is the part of the aggregate target script I changed. Everything else is the same.
if [[ "$SF_SDK_PLATFORM" = "iphoneos" ]]
then
SF_OTHER_PLATFORM=iphonesimulator
SF_ARCHS=i386
else
SF_OTHER_PLATFORM=iphoneos
SF_ARCHS="armv7 armv7s"
fi
Add an external library to the project, here I use libBlocksKit.a.
Build the framework, success.
In another child project. Include my built framework.
Add -ObjC in the app Target > Build Settings > Other Linker Flags
Archive and get error. Building for device (iPhone5) gives error too. But building for simulator seems to work.
What is the error?
This error, basically "ld: warning: directory not found for option ... ld: lto: could not merge in ... symbol multiply defined!".
ld: warning: directory not found for option '-L/Users/hlung/Dropbox/- Notes/stackoverflow/RealFrameworkApp/RealFrameworkApp/External/BlocksKit'
ld: lto: could not merge in /Users/hlung/Library/Developer/Xcode/DerivedData/RealFrameworkTest-evagqzwzyyolhjenkkjbvzibxppf/Build/Products/Debug-iphonesimulator/RealFrameworkTest.framework/RealFrameworkTest(NSObject+BlockObservation.o) because 'Linking globals named 'OBJC_CLASS_$_BKObserver': symbol multiply defined!', using libLTO version 'LLVM version 3.2svn, from Apple Clang 4.2 (build 425.0.28)' for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If I archive my child project with only one architecture (like armv7), it works. It shows this error with armv7 armv7s architectures ( $(ARCHS_STANDARD_32_BIT) ).
What version of the product are you using? On what operating system?
OS X 10.8.5, XCode 4.6.3
== Update 1 ==
Posted an issue at the tutorial's code.google.com page Update: 2 weeks no answer.
I found a set of useful suggestions from this answer. Update: Doesn't work
I have created a project so you can run and see for yourself here
Linking against a static library from within a framework can create some interesting challenges... It sounds like you may be linking to BlocksKit from both your framework and your application projects.
You should link in only one of those places. Try removing libBlocksKit.a from the Link Libraries build phase of your framework, but leave it in the other project.
You can do like this:
Click on your project (targets)
Click on Build Settings
Under Library Search Paths, delete the paths
I hope it can help you.

Library not found for lgcov

I'm using Xcode 4.6 and I've been writing some Unit Tests for an iOS app. I've tried to do some code coverage following from this tutorial: http://supermegaultragroovy.com/2005/11/03/unit-testing-and-code-coverage-with-xcode/ .
I've followed the 3 steps for my AppTests Target:
Check “Generate Test Coverage Files”
Check “Instrument Program Flow”
Add “-lgcov” to “Other Linker Flags”
The problem is that if I hit "Test" I get this error:
ld: library not found for -lgcov
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How can I fix this?
I think it's caused by your xcode version. Apple remove the library code-coverage needed after xcode 4.3. You need to add one file to your project manually. You can see check this blog for more details: http://www.gerardcondon.com/blog/2012/02/21/code-coverage-updates-for-xcode-4-dot-3/
You can try this. I tried but failed since my project include C++ code. I think that's because xcode 4.6 has not supported this feature...

Resources