When call setImageWithURL, it fails with following,
[UIImageView setImageWithURL:placeholderImage:]: unrecognized selector sent to instance 0x149a20 2011-12-14 18:11:38.060 [781:707]
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[UIImageView
setImageWithURL:placeholderImage:]: unrecognized selector sent to
instance 0x149a20'
I can confirm I have included SDWebImage project and required headers correctly as I can use the SDWebImageManager successfully.
Following is the code where I called the UIImageView category method setImageWithURL
NSURL* url = [NSURL URLWithString:#"www.abc.com/abc.png"];
[cell.imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:#"abc.png"]];
As per:
linking objective-c categories in a static library
Due to a linker bug in XCode, you need to set the 'Other Linker Flags' setting your build target. Setting the flag as follows should eliminate this error.
-force_load ${BUILT_PRODUCTS_DIR}/libSDWebImage.a
This will solve the problem: Open the "Build Settings" tab, in the "Linking" section, locate the "Other Linker Flags" setting and add the "-ObjC" flag:
If anyone, like me, still has problems after seeing all the other answers here (e.g. force_load or load_all) even after following all the proper installation instructions, here is what I have learnt after doing some search online:
This problem only happens when you use iPhone 5S or the 64-bit simulator
This is a problem with libwebp
The solution to this problem:
Only do this if you don't need the 64-bit processor for your app (too new to iOS programming to know if this sentence is valid)
Go to build settings > Architecture
Under Architecture, select Standard architectures (armv7,armv7s)
Under Build Active Architecture Only, make sure it is Yes for both Debug and Release
My source: https://github.com/rs/SDWebImage/issues/494
I hope this helps those who, like me, found this while trying to solve your problem =)
I ended up inserting all the .h and .m files into my project and then it worked fine. I got the same error when I only included the .a and .h files.
In the SDWebImage docs, it says that you have to set "Other Linker Flags" to -ObjC. This did not work for me. Instead, I set it to -all_load. I also had to remove -ObjC. The explanation for what is going on can be found here:
http://developer.apple.com/library/mac/#qa/qa1490/_index.html
It also explains why -ObjC fails: "Important: For 64-bit and iPhone OS applications, there is a linker bug that prevents -ObjC from loading objects files from static libraries that contain only categories and no classes. The workaround is to use the f-all_load or -force_load flags"
Using -all_load increases the size of the executable. You can use -force_load to mitigate this somewhat. For SDWebImage 2.7.3, I did this by setting the following in "Other Linker Flags" in the Build Settings: "-load_all $(SRCROOT)/SDWebImage.framework/SDWebImage". Linking to libSDWebImage[ARC].a which is what some sources advise, didn't work for me.
Incidentally, in Xcode 4.4, it seems you have to do a slow double-click in order to change build settings properly. Doing a normal double-click shows the completely screwed up and non-working pop-up.
Solved the same problem adding the libSDWebImage.a to Build Phases > Link Binary with Libraries.
If you read the document here https://github.com/rs/SDWebImage at the bottom there is a download link with the CORRECT files to download. Following that example it works perfectly.
The mistake I made, and seemingly others to, is I downloaded the github project and tried using that.
Everything started to work for me once I linked "ImageIO.framework" to my main project.
You can also set 'Other Linker Flags' to -all_load. This solves the problem where an external framework (such as the filepicker framework) requires linking against SDWebImage.
-force_load is not fix fundamental problem (when achiveing problem happens)
to fix this linking problem..
edit scheme for SDWebImage,
run scheme set for release
run (with device)
libSDWebImage.a will be generated in release-iphoneos directory.
set target->BuildPhase->link Binarywithlibrary .. add this lib.
Done..
Make sure your compiled files have UIIMageView+AFNetworking.m in case you're using AFNetworking framework.
You need to add the libSDWebImage.a in your linked binaries, also check for other linker flags, it should be -ObjC
Checkout your choice when you pull files of SDWebimages into Xcode, do mark the "create groups" in added folders, and do not mark the "create folder references".
Mark exactly as the picture:
Related
Having problems with the Soundcloud API.
I'm getting multiple Warnings & issues and I don't know what can I do to fix that.
Have I to change header search paths & other link flags? I tried the Terminal version of Installation as well and I got warnings & compilation errors
Appreciate your helping, I'm stuck trying to run propertly the Soundcloud API without warnings and I'm not able to do that.
I attach some screenshots.
Thanks
This looks a lot like a duplicate of XCode - iOS: Can't resolve conflict between CocoaLibSpotify and Parse framework.
I'm making a guess here, but are you doing -all_load?
Remove -ObjC and -all_load
Add -force_load <SoundCloudAPI library path> to load only libSoundCloudAPI.
After reading the github page, you may not need -force_load at all.
You may also need to adjust your warning level because of all the deprecated APIs.
It's working!!! Thanks for your help!! I'm very happy :D I was forcing the loading of the libraries without the prefix libPods that is added installing the project through CocoaPods. The trick to hidden the Deprecated functions was really helpful. After one day trying different settings, its running.
These are the linker flags I put in "Other Linker Flags"
-force_load $(BUILT_PRODUCTS_DIR)/libPods-OHAttributedLabel.a
-force_load $(BUILT_PRODUCTS_DIR)/libPods-CocoaSoundCloudUI.a
-force_load $(BUILT_PRODUCTS_DIR)/libPods-CocoaSoundCloudAPI.a
-force_load $(BUILT_PRODUCTS_DIR)/libPods-NXOAuth2Client.a
In "Header Search Paths" I put "./**"
I want to use core plot in my project to display bar&scatter plots.Before that I made a prototype project where I was successful in plotting those two. But when I tried to include it into my project faced some problems.
1) My project has a static library so according to the https://code.google.com/p/core-plot/wiki/UsingCorePlotInApplications, I added coreplot-cocoatouch.xcodeproj added too as a static library to my project and i set linker flags -ObjC as well for my app project then compiler throws a Mac linker error "Command /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1"
2) If I did not include -ObjC it throws error "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString sizeWithTextStyle:]: unrecognized selector sent to instance "
I am not able to find where am I doing wrong.Is it the problem with ARC because my project doesnt use ARC but as per some forums, I found we can use non ARC and ARC libraries in a single workspace.
I tried with CorePlot versions 1.3 and 1.4 & using Xcode 4.5, are these two arc or not.
Any help is appreciated.
Thanks in Advance.
1 Possible reason may be that there are 2 different versions (duplicate) of Core-Plot Exists in your build directory.. or you have #import .m class instead of .h in your code.. sometimes same thing happens if you have 2 different classes with same name exists in your code.. Also do try cleaning your build directory and check again.
Use the Core Plot dependent project or the pre-built static library, not both.
The -ObjC linker flag is required. You also need the -all_load linker flag. That error message means that one of the category methods added by Core Plot did not load at runtime; the -all_load flag tells the linker to make sure the app knows to load those methods, too.
I was trying out google maps sdk integration with iOS 6.1. I am successfully able to populate gmap on iOS simulator by using instructions given on
GMaps for iOS starting guide
Then what the issue with it:
It works great when I use it as a separate project. But when I club the above project code with my existing application, then it behaves weird, and all the errors generates due to inclusion of -ObjC value in Other Linker Flags in Build Settings.
Error
duplicate symbols for architecture i386
When I skip step 7 (GMaps iOS), it doesn't give errors. Due to exclusion of -ObjC value, it doesn't able to identify a specific GMaps library class and its method:
[GMSCameraPosition cameraWithLatitude:longitude:zoom:]: unrecognized selector sent
My iOS application background:
Using a third party library SUP (Sybase Unwired Platform). Connecting SAP to iOS application. I guess there is something ambiguous with SUP environment enablement (Build settings) when I am trying to add GMaps library.
Seeking for your advices.
Thanks!
There many posts on SO about the duplicate symbols for architecture i386 error. Usually it means that you defined the same symbol twice in the one namespace. The last time I got this error was because I accidentally included a .m file instead of .h header file.
Have you checked the Build Architecture?
Try setting Build Active Architecture Only to Yes.
I was facing the same issue Today! -ObjC linker flag - When trying to add it to "Other Linker Flags" I get an error
I solved my problem, Here is what I'd suggest. Take your original project (without Gmaps and with SUP) and add the -ObjC flag to it. Are you still getting an error? If so, take Gmaps out of the equation. If you are still getting an error check in the warnings about which files it is warning you about. My problem was that I had two files libGoogleAnalytics.a and libGoogleAnalytics_debug.a and for some reason they could not coexist with the -ObjC.
Long story short, you need to find what libraries Gmaps is using that you already have in your project and remove one of them.
Please try this…
step 1: Add '-ObjC' to other linker flags in 'Build Settings' of your 'target' only not to the 'project'
I have an iOS app on Xcode 4.6 and when I recently tried to build and run in the iPhone 6.1 simulator I got a "Mach-O Linker Error." It continued to say:
ld: 17 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does anyone know how to solve this?
Thanks so much!
Just go to "Build Phases" -> "Compile Sources" and look for duplicate of classes.
Check if you have "*.m" files in your #import ! It appears that was my mistake...
Quit Xcode
Restart the System
Select Xcode -> Preferences -> Locations
In Locations, you will see 'Derived Data'. Click on the arrow icon right next to the path.
This will open a folder containing 'Derived Data', delete it.
Clean the Product and Run
if still not works then
Build Settings > Enable Bitcode > No
In my example, I declared
extern NSString const *keyString
in two different files. I renamed one of them and it solved my problem.
In my case it was constants.
NSString *const cellID = #"cellID";
This line was written in two .m files. After appending static keyword at the start the problem was resolved.
This issue can be recreated in a new project too. You would think that defining constants in the different .m files won't have any effect as they are private. But I don't know how the compiler is handling stuffs behind the scene. On top of that when you tap the issue from issue navigator it doesn't open up a page in the editor like it does for any other issue. Really frustrating.
I am not sure I can give you a solution but I will share an answer since the same happened to me on xCode 4.6 as well. I added a C class header and implementation file and included them in main. I then decided to delete that new C Class header and implementation. When I ended up adding a new c class/header again with the same name and function calls, I ended up with your error.
Frankly, this might be a bug. The only and fastest way I fixed it was to start a new project and pull all the classes in.
Make sure you don't have non-instant methods with the same name in multiple classes (So for example if I have two viewcontrollers that are pretty similar so to move quickly I copy and paste the code from one viewcontroller to the second and they both have methods called the same thing like: NSMutableString *filteredStringFromStringWithFilter(NSString *string, NSString *filter)) then the app gets confused which of those methods to use since they are both available, RENAME IT on the second class and change any calls to that method on that class and you've removed the confusion. Don't we all want things to be more clear!
If you want to change a value both in tow different class. Do remember to mark with static keywords.
or the clang will throw such error below without any value interpretation。
Apple Mach-O Linker Error
clang: error: linker command failed with exit code 1
When you refactor a class func you will also sometimes get this error. Just go to Product-> Clean and rebuild.
Build Phases" -> "Compile Sources" click the button "Validate Settings"
it's will fix your project
I'm adding adMob provide by google to my iOS app and I'm stuck on this part of the installation:
Add -all_load under Other Linker Flags in the project build info
If I add that flag, then another third party library breaks giving me the error message:
ld: duplicate symbol _vw_chartype_table_p in /Users/josh/ Projects/app/libs/libvt_universal.a(vw_ctype-3279EF26D0C25F3A.o) and / Users/josh/Projects/app/libs/ libvt_universal.a(vw_ctype-34AB9EC0B46D954C.o) for architecture i386
Is there any way to use the adMob library without using -all_load? For example, I've tried -force_load $(SOURCE_ROOT)/adMob/libGoogleAdMobAds.a
but
ld: file not found: /Users/USERNAME/Desktop/latest/bbbb/APPNAME/adMob/libGoogleAdMobAds.a
The reason Google suggests using -all_load is that they are using categories in their code, and Objective-C libraries with categories are not properly loaded by the llvm linker (well that was the case in 4.3 xcode, not sure about 4.4 with the newer clang).
So, I guess if you are brave you can try to just remove the all_load flag. It should build fine. If the bug is NOT fixed, what will happen is when you run your code, it will crash, since none of the categories the library uses will have been loaded. This might be a good thing to do in any case, as your project should build, and if it does not you can fix those problems first.
What I do suggest you do is use -force_load, which has llvm load the categories in the adMob library (among other things). To use it you MUST have a fully qualified path (ie starts at '/') to the library. Obviously if you use Terminal and run:
ls -l /Users/USERNAME/Desktop/latest/bbbb/APPNAME/adMob/libGoogleAdMobAds.a
its going to fail. So enter the proper path - hard coded - for now to just see if you can get the project to first build, then run. If it does you can later figure out what is the appropriate $(VAR) to use to find it inside your project.