I just installed the cocos2d templates in Xcode 4. When I create a new project from the template and run it, it shows around 30 compiler errors. Even without making any changes to the template. Do you have any idea what is wrong?
Please add some more information about errors, but it looks like you forgot to add to your project OpenGLES and QuartzCore frameworks. I could be wrong...
I just spent 10 or 15 minutes plus fixing a bunch of errors in this situation, so i will guess: moving to Xcode 4.X caused many problems for cocos2d projects (including Kobold2D) and most of them require putting "(unsigned int)" in front of an argument in a list of arguments to a 'string with format' type operation creating mostly debug type output. usually the argument in question is "self", but sometimes just other "types" that resolve to (or can) unsigned ints. in a few cases I had no arguments but a reference to the error string to %#; these required adding a ", self" between the end of string and the close paren. in about 5 to 10% of cases, "fixits" were provided to automate the correction (usually changing the format character to match the argument). Hope this helps! Happy to provide examples if this actually helps anyone.
Related
As I'm not allowed to add an answer to several duplicated questions, I will ask this question and give also one answer ;-)
The undefined symbol was a call to a self written swift function. This function sits in an swift file with only "global" functions (no class in that file). The function is called from several classes and all was good until this morning.
Suddenly I got this link-error message when producing the release product. The funny think was, it was only for ONE function call. All other calls got no errors, and when I commented out this particular function call, all was good. And this function is a very easy one. There is only one function parameter (Int64) and it returns a CLocationCoordinate2D.
I checked all possible solutions found here and at other places in the web. I even copied the function 1:1 as a local function inside the class.. nothing worked.
The final solution was the compiler flag for optimization. For release builds the flag in "Swift Compiler - Code Generation" is set to "Fast, Whole Module Optimization".
After changing that to "Fast, Single Module Optimization", everything worked ...
I think it is simply a bug in the optimization engine.
.. maybe that will help others in similar situations.
Has anyone converted an app from 1.2 to Swift 2? My app is small - about 1k LOC, and its been converting for >2 hours now. I'm stuck on the following screen:
How long should I expect this to take? Thanks...
The process is long, but it shouldn't take more than several minutes.
The Swift converter is probably having an issue (e.g.: some kind of infinite loop).
You should abort and try to find what happened or maybe migrate manually.
Swift compiler has an issue with arrays. I have commented out all the elements of the array (like 10x UIColor), left only one element and conversion went smoothly.
Here's how you can debug the issue in your project:
Got to the Report navigator (CMD + 8)
Build your app, select the latest build and watch log (select All Messages filter)
The problematic file will be stuck on the compile status.
Navigate to that file and figure out what can hang the compiler (probably arrays/dictionaries).
Why build not convert? Because it's verbose.
I have imported Reachable and followed the chosen anser on this thread: Reachability Guide for iOS 4 Everything looks good, apart from a yellow triangle saying "incomplete implementation". Then when I press run I get ten red errors coming from the Reachable.m file, saying things like "ARC forbids explicit message send of release', 'NSAutoReleasePool is unavailable in automatic counting reference mode' and 'Cast of C pointer of type 'void ': to objective-c pointer type 'Reachability' etc. and 'declaration of 'struct sockaddr_in' will not be visible outside of this function [3]' from the Reachable.h file. Any ideas? Maybe the Reachable files are out of date? I have no experience with using C data types etc. and whenever I have to import an extra implementation/header file things seem to go wrong :/.
Apple's Reachability sample code was last updated in 2010. It doesn't use ARC and contains code that is non-trivial to convert to ARC.
The solution is simple:
Set the -fno-objc-arc compiler flag for that file.
I am having a weird error message when i try to build my application for device:
{standard input}:3884:invalid offset, value too big (0x00000408)
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
the class that issued this error message contains a function that has a huge switch statement with contains other switch statements in its cases. It is almost 1200 lines long!!
When i commented this function out the compilations was complete. So i predict this is whats meant by " value too big" in the error message above, correct me if am wrong.
Now how do i get over this limitation? I am thinking of a way to break my function into different parts and implement them in categories of the class in different files. But am not sure it is gonna be that easy as the function only contains switch statements within a huge statement. I will look at this further but does any one else have any other suggestion?
Cheers
AF
Firstly, if you're using xcodebuild directly try building via the IDE as some reports seem to suggest this can help, unlikely though that may sound.
Secondly, if this is a compiler bug (it sounds like it is and there are quite a few similar reports on the hyperinternetweb), you could also try switching to using LLVM (via your projects "Compiler version" settings) and see if that makes a difference.
Finally, you could simply avoid the issue by using an if/else construct instead, painful though that will be.
UPDATE
To try out LLVM (instead of gcc), select your project's build target from the "Targets" section in the Groups & Files area, alt-click and select "Get info". In the window that appears then select the Build tab (if it's not already selected) and scroll down to the "C/C++ Compiler Version" setting within the Compiler Version category. You then then choose to use "LLVM compiler" instead of gcc.
When I run my code through the version 252 checker binary, there are no analysis errors. However, when I change to use the latest 253 checker, it returns a slew of errors, all of which do not make any sense. For example, here is an image of an error that it shows in my Safari browser after the scan-build script is complete:
This is a pretty common error that shows up in the error listing. As you can see, the method name has Copy at the end of it, but it is still reporting as incorrectly named.
Here is the breakdown of errors that I am now getting with checker version 253:
Bug Summary
Results in this analysis run are based on analyzer build checker-253.
Bug Type Quantity
All Bugs 83
Dead code
Unreachable code 17
Memory (Core Foundation/Objective-C)
Bad release 19
Leak of returned object 23
Object sent -autorelease too many times 24
The autorelease errors seem to be related to the fact that the analyzer is unable to see that the Copy methods are actually correctly named, and I tried to look for an example of unreachable code, but I could not really find any patterns or explanations of those errors, as the errors were all lines of code inside simple if statements. Here is one for example:
I suppose that this could be some bugs that were introduced in the latest version of checker that is causing these to show up as errors. Is there something else (some kind of build setting or issue with the scan-build script) that I could be missing here?
First, method names should start with lower case letters, not uppercase (save for abbreviations like URL). It may be that the static analyzer is tripping over the uppercase "Get".
Next, even with a lowercase "get", the method does not follow convention.
To quote the documentation:
Use “get” only for methods that return
objects and values indirectly. You
should use this form for methods only
when multiple items need to be
returned.
Thus, the analyzer is correctly identifying an issue.
I would suggest following the guidelines and using something like:
+ (NSArray *) modifiedOrNewPeople: (FMDatabase *) aDatabase;
Which would release an autoreleased array. If there is some reason you can't return an autoreleased object, please comment.