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

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.

Related

Cannot compile my app with few classes from the Google Mac Toolbox

UPDATE:
Here is more detailed compiler output:
So I am working on a simple app. I want to be able to do some encoding/decoding of strings, so I have added these three files from the Google Mac ToolBox to my project:
GTMDefines.h
GTMNSString+HTML.h
GTMNSString+HTML.m
Since my project uses ARC, I have added the files to the build phases and set the -fno-objc-arc flag so they don't compile with ARC. See the screenshot:
Now I go to my main view controller and add this line:
#import "GTMNSString+HTML.m"
And I try to compile my project. I get errors like these:
How can I solve this? I am new to iOS development so please explain well.
To get rid of the first two warnings (no rule to process file...) remove GTMDefines.h and GTMNSString+HTML.h from your "Compile sources". Only .m-files need to be there.
You never want to import .m files, even if it's technically possible! To get rid of your errors, change your import from
#import "GTMNSString+HTML.m"
to
#import "GTMNSString+HTML.h"

LibXML2.dylib and Xcode4

I just downloaded Xcode 4 and I cant seem to run my application as the MGTwitter... classes are complaining of a non inclusion error of LibXML2. I have imported it into the frameworks folder, and I have put the following in the header bit in the build settings
$(SDKROOT)/usr/include/libxml2
But I am still getting 65 errors.
Any ideas how to fix this?
Try this:
"$(SDK_DIR)"/usr/include/libxml2
LibXML2 library solved
Many confusion around this issue.
SOLUTION
if you have both Xcode 4.3.x & Xcode 4.5 in /Application folder
must add ONLY: /usr/include/libxml2 in Application TARGET > Header search path.
For this double click on the line, on little window click plus sign and write /usr/include/libxml2
nb - need also add libxml2.dylib to the framework. I use 2.2.7.3
hope help you
Always search user path mark it yes.
Then, remove all previous paths that you have defined manually.
Clean all target.
Analyze or build again.
This works for me.
If you click on "All" and "Combined" go down to the Search Paths section. Make sure you add $(SDK_DIR)/usr/include/libxml2 to the "Header Search Paths" section and not the "Library Search Paths" section.
You need to add also the framework libxml2.dylib
Make User Header Search paths empty and write
$(SDK_DIR)"/usr/include/libxml2
in Header Search paths which is above the Library Search Paths
I think the selected answer is better. However this one worked for me:
I just drag and drop.
I do not know why it works. It's how the old programmer do it. I suppose there should be a framework we can include and that should be fine?
Also other computers may not have file libxml2.dylib in that exact spot and things may go wrong.
Please try this one:
${SDK_DIR}/usr/include/libxml2
Get info on the target and go to the build tab
Add -lxml2 to the Other Linker Flags property
Add -I/usr/include/libxml2 to the Other C Flags property
I also faced this issue for xcode4.6 ,
i added libxml2.dylib
in header search path added :: "/usr/include/libxml2"
and added "AdSupport.framework" and its work for me.
You need to add "$(SDK_DIR)/usr/include/libxml2" in "Release" Category rather then in "Debug" Category under "Header Search Path" if you are putting it into a device.

gcc-4.2 failed with exit code 1 iphone

I've seen this error with different variations on discussion forums but being a non programmer I'm not sure how to progress this.
Basically I have code which I found to help me with changing the background colors of cells on a grouped uitableview. The code introduced a line as such:
CGContextAddArcToPoint(c, minx, miny, midx, miny, ROUND_SIZE);
This gave an error indicated that it wasn't declared, so I added to my .h file the following under import uikit:
#import <UIKit/UIKit.h>
#define ROUND_SIZE 10
Now it shows that I have an error:
Command/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1 iphone
Some discussions talk about libraries but because I don't have a programming background I don't understand what to do. I also see that some people show a log output but I'm not sure where that comes from as I don't get any debug windows because I'm guessing it doesn't get that far. I simply click 'Build and Go' and I get this error in the Message window.
Any thoughts?
As you can see from the many different responses this error is caused by many different problems. Luckily, I have found the Meta Solution!
In xcode, right click the error line and choose "Open These Latest Results as Transcript Text File". This will open the real xcode output log, which should contain a better description of the error then was previously seen.
-Evan
I have gone through that same problem. There may be some file which has no refference . You can see that type of file in red letter. Remove that file.
You probably don't have the CoreGraphics.framework added to your frameworks list.
To make sure, click the "Frameworks" folder on Xcode. If the framework isn't listed on the table to the right, you'll need to add it by right-clicking the Frameworks folder, chooseing "Add Existing Framework..." and then choosing it from the list.
I've found the problem after seeing the Build Results window that Dave mentioned (thank you!!!). I had a different version of the same .h and .m file because I was testing with different code. I deleted the unnecessary files as it was seeing something in there as a duplicate.
The build was successful.
Thank you!
You can see the error message output from GCC by selecting "Build Results" from the "Build" menu or by pressing ⇧⌘B.
you have defined the same static constants!!!!
static NSString *kSectionTitleKey = #"sectionTitleKey";
static NSString *kSectionTitleKey = #"sectionTitleKey";
the problem is
nothing about the CoreGraphics.framework
Evans answer is the best thing you can do to find the exact reason of why you are having that error. In most cases, in my experience, is that there have been files that have been deleted but haven't been removed from the project.
This type of exit code error occures due to Any of your framework or Library overlap. so solve this problem check your error log and find out duplicate object symbols waring in log than you got actual file which is overlap in code.
Another fix to this problem that was the answer to my fix was that I had two classes with the same name. A webservices helper had created an Invoice class, and when I tried to add a file with that same name it didn't have any problems until I tried to compile.
So make sure all your classes have unique names :)
xcode build errors:
Unsupported compiler ‘GCC 4.2′ selected for architecture ‘i386′
Solution:
This can be caused by importing a project for a pre- iOS 5 SDK into a copy of xcode with iOS 5 SDK only.
To fix,
click your Project -> Build Settings. Then under Build Options, there is an entry for Compiler for C/C++/Objective-C. Choose Apple LLVM compiler 3.0.
When u create a file , u have to disable [uncheck] cocos2d libraries & then add the file. so that gcc-4.2 error will be rectified :) checkout!!!
This problem also arises when you rename the XIB file. You have to replace the old name with the new name in the xib files as well as in the navigation controller (if used).
For me, I found the solution above helpful....
"Open These Latest Results as Transcript Text File" which explained it couldn't find libGDataTouchStaticLib.a. I then had to build the static library for Gdata.xcodeproj (changing the active target > GdataTouchStaticLib) then had to manually add this file by dragging it to the targets > MYAPPNAME > Link Binary With Libraries. Build & Run.. All Good.
This issue could be because some libraries might be missing. Right click on the error line and click on "Open these results as transcript text files" and check the missing library.
I had the same problem, noticed that it was looking for a file in the wrong folder, essentially, don't store projects in folders with apostrophes in their name!
I had the same problem. The reason was, I had two int main(int argc, char *argv[]) functions.
I've gotten the same error and solved in a very strange way. Cleaning and rebuilding the project doesn't solve it but simply adding an empty line in ApplicationViewController.mm has forced the compiler to rebuild "something" and the error has gone by itself.
I just add that the same project compiles without error on iMac and failed on macBook.
I was getting this error on building a cocos2d project using xcode 4.3 on Lion. To fix this error, I followed the instructions here: http://www.mac.ph/cocos2d-templates-and-xcode-43
Here is one of the possible solutions:
Remove the .m(implementation) file import statement from the viewController class if it is included along with related .h(header) file.
Instead of including (by mistake)
#include "myClass.h"
#include "myClass.m"
Include only the required header file as:
#include "myClass.h"
Thanks,
Prodeveloper

Rename a class in Xcode: Refactor... is grayed out (disabled). Why?

Why is Refactor... grayed out (disabled) in Xcode?
I'd like to rename a class.
Select the class's symbol in its header file - i.e. the bit just after #interface. Then the refactoring stuff should be enabled.
If you are using Objective-C++ (i.e. mix Objective-C with C++ code) then refactoring is disabled in xcode since it does not support refactoring of C++ code.
Refactor might also be disabled if affected files (most likely the file with your class in it) are not saved.
I've been using Xcode for 5 years now, and refactoring has never worked correctly (even xcode 4.6 has major bugs where it WILL corrupt your source code!).
The workaround has always been (still works 100%, even in cases where Apple's code fails)
use shift-command-f to find all uses of the file
select "replace" in the search settings
"replace-all"
do the following for the .h file, and REPEAT IT FOR THE .m FILE (if you have one):
right click the original file, and select "show in finder"
delete the file from xcode (select "delete references only" when asked)
rename the .h (and .m if you have one) in Finder
in Xcode, select "Product -> (hold down Alt) -> Clean Build Folder"
quit xcode (you can usually get away with not doing this - but NOTE: there are some other MAJOR bugs in Xcode where it crashes itself if you don't do this)
re-open xcode
drag/drop the .h and .m back into Xcode
wait a few seconds (some of Xcode's core methods are asynchronous - allowing it to corrupt your project)
finally, when it seems to be doing nothing (and your hard disk isn't making any noise any more): cmd-b to re-build
I have a 100% success rate with this method. I just tried refactoring with Apple's "Refactor -> Rename" in latest xcode and it failed - again!
(this time with the incorrect error: "Unable to determine the language of", one of those error messages where Apple put the wrong text in place)
I'm going to my project at finder, then change files name by get info.
After that, at xcode -> Project Navigator I delete the files.
At end, I click right on the class and Add files to ..., and add these files again.
It worked for me.
For me I realized Refactor was disabled because the Xcode project I had opened was referencing a Base SDK that was missing. Edit Project Settings and in the Build tab set the Base SDK to one that you have (like for me this was iOS 4.2). This enabled Refactor for me.
Also, it could happen that you renamed the filename for the class, either outside xcode or by ctrl-clicking the filename and then renaming it.
xcode refuses to refactor if filename does not match with the class name.
Go to your class' header file and find the line that looks similar to this:
#interface YourClassName
Right click on the class symbol (e.g. YourClassName) and you should be able to select Refactor -> Rename...
I just tried this and it works in Xcode 5.
This may be a bit late, but I stumbled across this post because I was unable to refactor my "ViewController.swift" file to "WhateverViewController.swift". I tried selecting the file in the Project Navigator and then selecting "Editor -> Refactor" from the top menu, but 'rename' is always greyed out.
Instead, what worked was selecting the ViewController name from the editor. So if you have:
class ViewController: UIViewController {
// Code here...
}
Highlight the "ViewController" word and then select Refactor from the menu or right-click and select Refactor -> rename.
Hopefully that helps...
Had this problem as well. I ran through trying to find missing SDKs, saving files, and looking for Objective-C++ code as mentioned above, and all it took to fix my machine was rebooting XCode.
Seems a little buggy still.
BTW, this was for XCode 4.0.1
Refactoring works If you first change the file name in the project navigator.

How do I make Xcode refresh its local copies of my project's image files?

I'm having some weird issues with Xcode, and this is pretty much impossible to find answers by simply googling around.
I have a few icon image files (just PNGs) in my Xcode project, and when I modify some of them in Photoshop, they don't get updated when I do another build in Xcode. In order to fix this I have to re-add the file again to the project, and then remove the old version of the file that is already in there in Xcode.
What am I doing wrong here? I'm updating/replacing the image file that is stored in my project's directory directly from Photoshop, so I assumed that it would just get reloaded and the new version would show up.
UPDATE: Looks like what happened was that when I first imported the image files into my project, they got added to my "Classes/" sub-directory. So when I was updating them, it was just adding them to the root of my project.
I had the exact same problem.
The following fixed it for me:
In Xcode, go to Project --> Clean
This will purge the old images from xcode cache and will show your new image
That's pretty weird. I'd suggest two things:
Check that you're not saving your
photoshop files into the wrong
directory. I know this seems
straightforward but its worth a
check. Make sure you're not saving
them into the build/ directory or
anything like that.
Before running again in the simulator, try cleaning all build targets first to ensure that your project actually builds again before launching the simulator.