Upgraded to IOS5 - App Won't Build - iphone

I've upgraded my IOS4.3 app to IOS5 and am getting compile errors. From what I can tell, the syntax looks fine, but the compiler is complaining of "Unexpected #" when I synthesize properties, but only in some classes.
I also have an "Undeclared identifier" in one ViewController's viewDidLoad method.
I've performed a clean build and I'm guessing that there's a default setting which has been changed somewhere, but from scouring around this doesn't seem to be a common issue. Is there a list of common breaking changes anywhere?
EDIT:
This screenshot is one of my ViewControllers, which is derived from UITableViewController

There is a missing # in the line self.title = NSLocalizedString(...). The second parameter doesn't have the leading #.

Coming from a .NET/PHP background, I have very little experience with compilers. The problem was that Apple seem to have changes the default compiler for IOS5 from GCC to LLVM, hence the difference in syntax. It would be nice to be able to use the newer compiler, but GCC's the only one which gets anywhere near close.

Related

Compiler issues: "Use of Undeclared Identifer" error with constants that still work

I am using a Constants.h file to declare a lot of strings for resources like URLs and the like. This has always worked fine in the past, and in fact continues to work when I compile and run.
However the issue navigator shows errors (the red bangs) despite labeling them as "semantic issues" (which sounds more like a warning) and the code editor windows show them as well for lines like this:
[app openBrowserWithUrl:[NSURL URLWithString: kRequestInformationURL]];
The line in Constants.h looks like this:
static NSString * const kRequestInformationURL = #"http://www.myserver.com"; // uses SSL!
It's throwing up warnings/errors for all of my declarations in Constants.h. But it still compiles and runs fine! I have no clue what's going on here, but it's very annoying because my project now shows that I have lots of warnings/errors.
I should also add that this happens in the latest version (4.5.1) of Xcode on one of my Macs
and not the other, opening the exact same project file.
Another thing I should note: you usually only see these error/warnings when you click on the file to edit it after compiling.
UPDATE EDITED: I thought that I got these to go away by adhering to more strict constants declarations, as explained in this post: https://stackoverflow.com/a/539039/326398 however all the warnings (which, as I said before, are marked with error icons in Xcode) came right back. So mystery is still very much intact.
Thats happening when you use "false" variables, your NSString is declared as *"const", you cannot do that because const is actually an own Declaration for something in Xcode, simply change NSStrings variable name.

refactoring to arc results in "synthesize of 'weak' property is only allowed in arc or gc mode"

i am using xcode 4.4.1 for iOS target 5.1
i've started my project using ARC, and in the middle of the project I've added some non-arc thirdparty source to my project.
at this point, i've decided to try refactoring in xcode and an error occurs.
it comes from one of my original source code.
i have a property of (nonatomic, weak) and i've synthesized it ==> synthesize of 'weak' property is only allowed in ARC or GC mode.
I am puzzeled - i am using arc and it complains that it is only allowed in arc??
At the moment, i've refactored the thirdparty app from other project and copied it for my project to work, but the above is a question I'd still like to understand why .
Thanks!
(by the way, when i do convert to arc, it says that the target currently uses ARC)
It sounds like the issue is you've already set it up as an ARC project and your are for some reason trying to convert it again. I can only assume that the process doesn't expect therefore weak references at this stage. If you set them to Assign then convert to ARC you will see that it then suggests you change them to weak.
I had the same symptom using Xcode 4.6.3 targeting iOS 6.1. I brought in a non-ARC class from another project and converted it via the Refactor menu only to have subsequent builds fail on a pre-existing class with the error you saw (“synthesize of 'weak' property is only allowed in arc or gc mode”).
The project properties clearly said it was still an ARC project but the compiler seemed to have forgotten this was the case for the class in question.
I got around the issue by setting the property to 'strong' and converting that class to ARC via the Refactor menu. Unsurprisingly it told me no changes were necessary but did offer a Save button which I clicked. I was then able to change the property back to 'weak' and compile the project. (I'm presuming some metadata got out of synch somewhere along the way.)
EDIT: I eventually had to 'Refactor' other ARC-compliant classes to ARC as although they compiled they generated warnings and caused crashes in my app. I think the moral of the story is that including your whole project in the refactoring might be safer...
instead use:
#property(nonatomic,assign)
*note - This is not the same as weak, but very similar. Weak also sets the object to nil, assign does not.

Using Accessorizer it doesn't generate any dealloc code for NSString properties

I'm using the Accessorizer code helper for xCode. I seem to have it configured correctly and it is generating property statements and synthesize statements fine.
It is not generating the release statements however when I choose the dealloc action.
If I choose dealloc against an NSTimer, it does generate the [myTimer invalidate] statement, but not the release statements, so it seems to be triggering the dealloc action, but the action isn't configured properly? and so no release code generated.
Has anyone come across an issue like this using accessorizer?
Amazing how you find an answer just after asking a question.
For anyone else that has this issue, turn off ARC Aware in the Accessor Style TAB of the Accessorizer application. (yes seems bleedingly obvious in hindsight, was stupidly thinking it might be aware of the xcode project settings and ARC isn't on for this project, but its really just a 'dumb' editing tool that operates only on the input text i.e. not integrated to xCode).
The things we have to go through to do something that anyone who codes objective C for more than half an hour would have made the first feature of a new IDE. (automatic generation of property/synthesize etc.)

UITableViewCell Style Causes Illegal Configuration Error

I have a UITableViewCell, and if I set its style to anything other than Custom, it gives me the following design-time error:
Illegal Configuration
Only the "Custom" style is supported in versions prior to Xcode 4.2
It will still compile and run fine though.
I'm using Xcode 4.2 (build 4D199), so I don't understand why it is saying this. Furthermore, I can't find anything on the web about this, which makes me suspicious that it's something particular to my setup.
I can duplicate it by creating a new Xcode project and just dropping a UITableViewCell on the designer and setting its style to something other than Basic. If somebody could do this real quick to see if it happens to them, even that might help because then I'd at least know if it's just my setup.
Any ideas are appreciated.
No biggie. This warning is thrown just in case you'll want to open your project in <4.2 interface builder versions. Open your cell's xib and see the development versioning settings (pic bellow)
From the deployment/development drop-downs select the latest Xcode version and warning should go away.

Xcode, no debug symbols for certain subclass

I'm using Xcode 3.2.3 and iPhone SDK
So I'm trying to debug a UIView subclass, I hit a breakpoint in an overridden method and I can't see any symbols in either the GUI or gdb, just globals and registers.
This is what I see:
(gdb) po self
No symbol "self" in current context.
Yet when I set a breakpoint in a UIViewController subclass, all the symbols are there:
(gdb) po self
<MyViewController: 0x5c18ae0>
Current language: auto; currently objective-c
Some things I've tried:
clean all/rebuild
restart Xcode
change between debug and release
config these options in Project
settings:
GCC_DEBUGGING_SYMBOLS = All
Symbols DEBUG_INFORMATION_FORMAT = DWARF, DWARF w/ dSYM File
BUILD_VARIANTS = normal, debug
threatening Xcode by swearing at it and typing
rm -rf /Developer into a root bash prompt
Please help, my fingers are bleeding from debugging with NSLog
I experience this bug often. My workaround is typing the bt command on the gdb console, it then automagically sorts itself out and starts recognizing symbols in the current context.
So changing from Debug to Release did the trick and I have all my debug symbols.
I think it's just a bug in the 4.0 SDK.
Hmmm, tried to repro this in 3.2.3 and SDK4 Final with no success -- able to debug UIView subclass as expected. Is this occurring using one of the beta releases?
Happening to me, on a non-beta release. I just noticed that it only occurs when calling a class-defined method, ie (+) not (-)
I wouldn't mind not having a "self" pointer, but it also seems to wipe out all local variable displays in the debugger, and that is just wrong.
MTS' method worked for me. Changing from debug to release fixes this issue. How strange. I can disprove software evolved's theory, as I experience the error inside an instance method.
in gdb type bt.
If you see self=<value temporarily unavailable, due to optimizations> anywhere it's because xcode has been set to be optimized.
Go to the build settings and type optimization.
If optimization level for either debug or release is set to Fastest that's causing your issue.
Release should be left at fastest so your code run well when building for distribution. It's better to change your Build Configuration in Scheme.
opt+click the Run button. On the left click Run YourAppsName.app, then Info and select debug.