cassert file not found but i use Box2d template - iphone

i am using cocos2d template with Box2d but when i import Box2d.h in my project it gives me error
cassert fiel not found
i have cocos2d version 2.0
please help me

Make sure all your project's source code files have the file extension .mm and not .m. Or set each .m file's type to Objective-C++.

change your file extension .mm thats it

Changing extension in xcode 4 will not work. Instead go to build settings (tab) and change C++ standard library setting to libc++ (LLVM...) from compiler default.
If you build it now you will get an error saying app is not compatible with iOS 5 or later. So go to summary (tab) and change deployment target to 5.0. It should now build successfully.

Here is how I fixed the issue. Cleaning up and recreating the project didn't seem to be a good idea for me.
There are a couple of answers on the web for this issue but they in each didn't help me solve the problem. One is on SO at
cassert file not found but i use Box2d template and the other is on cocos2d-iphone forum,
http://www.cocos2d-iphone.org/forums/topic/cannot-include-box2d-cassert-file-not-found-despite-every-file-being-mm/
Combining the two suggestions kind of worked for me -
Rename all YOUR (not cocos2d or box2d files, just your project files) from .m to .mm
Make sure that on each of the files, on the right pane, “Type” option is set to “Default – Objective C++ Source”
There was another issue for me specifically, may not be an issue for you, I was using the following signature for CCLabelTTF
CCLabelTTF *title = [CCLabelTTF labelWithString:#"Hello" dimensions:CGSizeMake(720.0f, 880.0f) alignment:UITextAlignmentLeft fontName:#"Arial" fontSize:34];
This is deprecated and caused errors all over the place. I am now using the following slightly modified version and the errors fixed -
CCLabelTTF *title = [CCLabelTTF labelWithString:#"Hello" dimensions:CGSizeMake(720.0f, 880.0f) hAlignment:kCCTextAlignmentRight fontName:#"Arial" fontSize:34];
My most recent writeup of this fix can be found at - http://indiangamer.com/how-i-fixed-the-cocos2d-box2d-include-file-not-found-error/

For those like me : I just tried to reopen a very old xcode project and got this error with cassert files.
Just setting the target to a new one (iOS 13 in my case) made it automatically select the correct version of the c++ stdlib and everything worked just fine.

Related

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.

Adding cocos2d files to xcode project?

I am doing collision based game.So i added Cocos2d files such as Box2d,FontLabel,cocoslive etc.But while running the project am getting two errors in following code... What is the reason for this.Any changes want to be done in info.plist and build settings.Please help to find.
sweepA.Normalize();
sweepB.Normalize();
this code is in b2TimeOfImpact.cpp(Box2d,collision)class.
am getting the error "No member named "Normalize" in 'b2Sweep'".
do you see coco2ds template in your xcode
http://www.cocos2d-iphone.org/archives/1412
try creating project from scratch through template .

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"

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.