'Xcode cannot find protocol declaration of "UIViewControllerAnimatedTransitioning"' - delegates

I created a vanilla Xcode (v6.2) project (Project A) that throws the error:
'Xcode cannot find protocol declaration of
"UIViewControllerAnimatedTransitioning"'
Here's the code:
#import <Foundation/Foundation.h>
#interface WTF : NSObject <UIViewControllerAnimatedTransitioning>
#end
Weird thing is, I have a example project that I downloaded (Project B) that I can put the exact above code in and it will recognize UIViewControllerAnimatedTransitioning protocol without a problem:
#import <Foundation/Foundation.h>
#interface WTF : NSObject <UIViewControllerAnimatedTransitioning>
#end
The most obvious differences I notice between the two projects are that the second downloaded project has the frameworks listed in the explorer, but the project I created with Xcode 6.2 does not. Upon further reading I found that new versions of Xcode eliminate the need to manually hook up frameworks, so I'm not sure if it's relevant.
So with Project A throwing an error on something that Project B does not, I started a new project (Project C) in Xcode (Single View Application) and pasted in:
#import <Foundation/Foundation.h>
#interface WTF : NSObject <UIViewControllerAnimatedTransitioning>
#end
And get the same error:
'Xcode cannot find protocol declaration of
"UIViewControllerAnimatedTransitioning"'
Restarted Xcode and Mac and the error persists.
WTF is happening here?

Ugh. Needed to import
UIKit/UIKit.h
3 hours.

Related

Missing Prefix File in Xcode 6

When creating a new project in Xcode 6, the generated project is missing the Prefix.pch file. Is this intended? Should we continue making our own, or is there a new method we should be using instead?
I don't use it too much, but having a few key system frameworks like Foundation and UIKit available in every file is useful, along with a couple oft-used 3rd party frameworks. Is the preferred solution to just create our own prefix file manually and configure it in the build settings, or something else?
You can easily add the Prefix.pch file manually like this:
1) Add new .pch file to your project -> New file -> Other -> PCH file
2) Goto your project's build setting.
3) Search "prefix header". You should find that under Apple LLVM.
4) Paste this in the field $(SRCROOT)/yourPrefixHeaderFileName.pch
5) Clean and build the project
If you use Objective-C just like before xCode 6 you will also have to import UIKit and Foundation frameworks in the .pch file. Otherwise you will have to import these frameworks manually in each header file. You can add the following code anyway as it tests for the language used:
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

XCode Protocols

I am adding a new protocol to my project but XCode does not recognize the code. I already have other protocols in the same project without any problems but this time the funny thing is the color of the code is not the right one and the automatic text helper is not recognizing the language.
For example in a protocol the code appear like that:
#import <Foundation/Foundation.h>
#protocol URLGetDelegate <NSObject>
#required
#optional
- (void)setWeather:(NSArray*) data;
- (void)setChemists:(NSData*) data;
#end
Then NSObject appear in purple, however in the new protocol the NSObject appear in black and when I type code, NSO... XCode does not offer me the words NSObject automatically.
#import <Foundation/Foundation.h>
#protocol CompanyDelegate <NSObject>
#end
Any help?
Thanks
What the Laure_f_o is referring to is the lack of standard auto completion and text colorization that happens in XCode; essentially XCode refusing to recognize a newly added protocol as such. So when you try and add it to a class and declare that class as subscribing to that protocol, you get a build error.
I just had the exact same sort of problem: other protocols in my project that work fine, but when trying to add a new one XCode just would not recognize it at all. This is all for XCode 4.6.2
What finally solved it for me was the following (based on Javy's advice here: Xcode Not Immediately Recognizing New Classes (iOS)):
1.) Clean Project
2.) Close project (but not XCode)
3.) Open Organizer in Xcode (under the Window menu)
4.) Select "Projects" tab
5.) Delete "Derived Data" (if you have saved snapshots, you'll have to delete those first)
6.) Quit XCode and restart computer
7.) Reopen project and clean it again
8.) Import the problem protocol into a class and declare that class as subscribing to it
Then, and only then, did I finally get the protocol in question to start behaving as such and didn't get build errors trying to use it in classes.

Why are #end's not being seen by compiler?

I have 2 classes, an NSObject and an NSView. No AppDelegate.
I was getting a hard error "method definition not in #implementation context" even though the methods were between #implementation and #end. Moving a #import ahead of #implementation eliminated that but then variables from the other file were not known. To get rid of it, I wound up // commenting out all the code lines in both .h and .m files. There's no code left except #interfaces, #implementations, and #ends.
I still get a warning "#end must appear in implementation context." One of them appears immediately after the #end!
I have not attempted to use IB in this program.
Other programs compile correctly, and I think the code is correct in his one and it should work.
Is there some way the compiler gets stuck? OSX 10.6.8, Xcode 3.2.6.
I gave up on that project, created a new project, and copied and pasted the text from the bad one. The new project works fine with the same old text.
Then I ran memtest repeatedly and Applejack to clean up. The hardware is ok.
Probably the compiler is flaky; I've had to do this a couple times this year. Last time an error message said that the compiler had a partition problem; Google links said to upgrade and maybe the new version would fix the problem. So I installed Xcode 3.2.6, which produced the same error, unfortunately. Copy and paste to a new project was necessary, again.

Automatic #property synthesize not working on NSManagedObject subclass

After updating to the newest Version of Xcode 4.5 for iOS6 last night, i get Warnings and Errors like this
Property 'mapAnnotation' requires method 'mapAnnotation' to be defined
- use #synthesize, #dynamic or provide a method implementation in this class implementation
because of missing #synthesize Statements, and even Errors about unknown iVars if i use them.
The thing is, i thought it was not necessary to write these #synthesize statements since the last Xcode Update to 4.5 that came out with Mountain Lion, AND all my projects worked without them before i've updated Xcode last night (i've deleted a whole bunch of #synthesize statements from my files back then)
It's even still in the Release-Notes:
• Objective-C #synthesize command is generated by default when using properties.
So i'm confused, am i missing a new Project-Setting that turns automatic #synthesize generation on?
But it's not even working when i create a new Project and try it
I faced the same problem and found the reason and the solution.
If you look at the header file of NSManagedObject in iOS 6 SDK, you'll see "NS_REQUIRES_PROPERTY_DEFINITIONS" which forces classes to specify #dynamic or #synthesize for properties.
(You can see the NS_REQUIRES_PROPERTY_DEFINITIONS in the API diff between iOS 5.1 and iOS 6.0.)
This is because the compiler has to know if you want a property to be dynamic or synthesized especially in the implementation of a subclass of NSManagedObject class.
I could solve this problem simply by adding the #synthesize lines explicitly for the properties other than #dynamic in NSManagedObject subclasses.

Why can't I set a referencing outlet for my NSTextView in XCode 4?

I'm making a simple dialog in XCode 4 using the Interface Builder. I have three NSButtons, all of which are hooked up to their relevant IBOutlets. However I have an NSTextView, which I'd also like to hook up. I have the declaration for it in MyDialog.h:
#interface MyDialog : NibLoaderOC {
#public
IBOutlet NSTextView* tv;
IBOutlet NSButton* acceptButton;
IBOutlet NSButton* editButton;
IBOutlet NSButton* rejectButton;
}
#end
But when I drag the 'New Referencing Outlet' line over tv, it won't highlight. If I try and make a new outlet, it says:
Could not insert new outlet connection: Could not find any information for the class named MyDialog
I have tried restarting XCode, this does nothing. What am I doing wrong?
I noticed that .m file was moved inside en.lproj folder.
Just delete (reference only) the .m file from the Xcode and moved .m out of the en.lproj.
Add it again.It will fix the issue.
Don't worry, you will get all your connections back.
Although I'd still be interested in a proper solution, I fixed this by just manually editing the xib code to create the link.
This has the unfortunate side-effect of Interface Editor refusing to play nicely with the file (although all my manual edits were correct, and the code compiles and runs perfectly).
i got this bug in xcode 4.6.0. restarting xcode didn't fix it for me. deleting the derived data for the project, then restarting xcode did fix it.
delete /Users/myusername/Library/Developer/Xcode/DerivedData/MyProject
Another thing to check for is to make sure that if you have a custom class that you specify it under "Custom class" in the Identity inspector of Interface Builder.
So for instance if you have the following declaration
#interface MyViewController : UIViewController {
#public
IBOutlet MyCustomView* aCustomView;
}
#end
Make sure you add that into the inspector as pictured. Otherwise I've found that you won't be able to hook it up.

Resources