Adding reachability to iphone application gives linking errors - iphone

I keep getting these errors trying to run the Reachability.h

Go to Project build phases and add the following
Under Compile sources, press the "+" icon and add Reachability.m
Under Link Binary With Libraries press the "+" icon and add SystemConfiguration.framework
UPDATE:
If you are receiving ARC compilation errors
You will have to disable ARC on specific files
To do that please follow the steps in this answer
How can I disable ARC for a single file in a project?

Your class is referencing Reachability, but you are not adding it to your project. You should possibly add the Reachability.m file to the project.

Related

Automatic Reference Counting Issue - PhoneGap

I have tried creating my HelloWorld Application using PhoneGap + Xcode 4.2 by following some steps as explained on below link:
http://docs.phonegap.com/en/2.5.0/guide_getting-started_ios_index.md.html#Getting%20Started%20with%20iOS
But when i'm running my HelloWorld application on Simulator..its giving my Automatic Reference Counting Issue error.
This error is coming cause your project CordvaLib is ARC enabled. However, your class CDVAccelerometer isn't ARC enabled. To exclude the file from ARC, use the -fno-objc-arc flag
in build phases > compile sources
While creating the new project it asks "use Automatic Reference Counting" with check mark. If you are not using ARC then deselect the check mark.
If you don't want ARC for the only particular class then ProjectSettings -> Build Phases -> Complile Sources -> Compilerflag. click next to your class and set
-fno-objc-arc
Now only the selected class is ARC disabled.

having errors when import class non-Automatic Reference Counting to my project

Just create new project and checked Automatic Reference Counting and downloaded another project.
when I import the downloaded classes to my project, it gives too much errors, after searching I found that because the downloaded project is non-Automatic Reference Counting .
so, what is the solution for this problem please ?
This occurs because calls like "release" cause errors in ARC projects so that you don't use them because the compiler does this for you. To keep ARC enabled on your classes and disable it on the class you've imported go to your build phases and add the compiler flag "-fno-objc-arc" to the class that you want to use manual memory management.
Those files need to be flagged to the compiler so the compiler does not use ARC with them. Use the -fno-objc-arc flag. Click on your project file, click on your application's target, click on the "Build Phases" tab, expand on "Compile Sources", and double click on the files without ARC. Once a little window pops up, put the -fno-objc-arc flag on those files.

SDWebImage/UIImageView+WebCache.h file not found while archiving [duplicate]

I am fairly new to ios development - trying to use sdwebimage in my iphone project. I believe I completed all basic setups as required. But when I build, I get this error: No such file file or directory near this line:
#import "UIImageView+WebCache.h"
Yes I have added Target Dependencies
I have added libSDWebImage.a in Link Binary With Libraries
I have -all_load -ObjC in Other Linker Flags
I also tried the -force_load ${BUILT_PRODUCTS_DIR}/libSDWebImage.a (64bit mac)
My Use Header Search Paths is : $(BUILT_PRODUCTS_DIR)
I cleaned the project and rebuilt - but no use.
Build keeps failing. Again, XCode4 code completion "resolves" when I type #import "UI & hit "ctrl+space" which means the lib is visible to xcode. Any pointers will be super helpful. Thanks.
To add the needed header files to the build path do the following.
Select your project file
Select your target
Select Build settings
In the search box enter 'header search paths'
For the Release add "$(SOURCE_ROOT)/SDWebImage" (thats with quotes).
This will work when importing like this #import <SDWebImage/UIImageView+WebCache.h>
I also use SDWebImage.
In my experience I didn't do anything with the linker flags etc.
You only have to add the classes in your project and simply import the "UIImageView+WebCache.h" in your class' header like this:
#import "UIImageView+WebCache.h"
and if you want to use it on an UIImageView object, just use the method
setImageWithURL:placeholderImage:
you can refer to their github for more info
I just ran into this problem and have solved it.
The issue is that when you "drag" the SDWebImage xcode project to your project, Xcode only create a reference to point to those files needed. When you are in debug mode it's fine, it knows where to find those file. However, when you want to archive it (packing everything to be self-contained), it couldn't find it from your search path.
Although you have added $(BUILT_PRODUCTS_DIR) to your search path, but if the actual files that you downloaded are not physically located in your $(BUILT_PRODUCTS_DIR), then Xcode won't find them. This was the problem for me since my SDWebImage files were still sitting in my download folder.
What you want to do is:
1.Move the SDWebImage folders to a place where you won't accidentally delete it. Notice once you've done that, the SDWebImage project file will become red since it's physical location is moved. And it's wired that I could not delete that reference in Xcode, what I ended up doing is add that file again (choosing from the location where I just move it too). You will end up with a red SDWebImage.xcodeproj in your project navigator which you can not delete. It's very annoying but it won't affect anything.
2. If the location you move the SDWebImage stuff to is not in your $(BUILT_PRODUCTS_DIR), then you either move that inside $(BUILT_PRODUCTS_DIR) or as I do, add the path to Target -> Build Settings -> Search Paths -> User Header Search Paths.
Archive and it should work now.
I faced this same problem and was about to go crazy. Like Ravi, I followed the static installation instructions as closely as possible.
I saw the auto suggest for UIImageView+WebCache.h when I was typing #import, but it keeps throwing file not found.
In the end, it was this. In header search paths,
“$(BUILT_PRODUCTS_DIR)” - Wrong.
$(BUILT_PRODUCTS_DIR) - Right.
Embarrassed but now it's working right =)
I've been dealing with this problem for the past hour and noticed something that hasn't been mentioned: Make sure that when you up update header search paths that the "Recursive" option is selected! Otherwise the compiler will not check subfolders.
Worked for me...
I was dealing with the same problem, my two frameworks were not getting found. I tried all the suggested ways in order to resolve the error but it couldnt help. Atlast I deleted the frameworks from my project structure and reloaded them from the original project file and it worked!! Please try this if it helps, It worked for me...
I had a similar issue after pod update. If you are using CocoaPods version higher than 1.0.0 and more than one target in your project, you have to add all the targets into the Podfile.

How to add ARC for specific file?

I created a project without ARC. I want to use a third party SDK in my project. That SDK comes with ARC Support. So I want to add ARC for that third party files. I can disable ARC for all "MYProject" files by adding this flag into build phases like -fno-objc-arc.
But I may use large number of files. So it's better to add ARC for specific SDK only. So how to add ARC support for single or specific SDK files in XCode Project?
For Instance: I want to use Grid View. I'm adding GMGridView in my project and it comes with ARC support.
Add the flag -fobjc-arc to the files that you'd like to use ARC. It's just the opposite of the other.
You add compiler flags in Targets -> Build Phases -> Compile Sources
Compile source show all file that project contain.so please add -fobjc-arc to compiler flag by double clicking on it as show in below image.

XCode cannot find foundation.h or UIKit.h after MediaPlayer.framework is added

As soon as I add the MediaPlayer.framework into a new program, XCode absolutely shits its pants. Under supporting Files, PROJECTNAME-Prefix.phc starts red-flagging both #import and #import
Why is it doing this? I have tried to create a new project and re-adding the Framework, but even if that is all I have done, it gives 4 errors on the first failed build.
if you are using xcode4 don't slide the framework in the project: it edit the framework search path and do the error you describe.
Try deleting the framework search path in project "build setting" and for adding the framework use "target" "build phase" "link binary with library".
hope it help and sorry for my poor english.