1

I get the next two errors while trying to run the project on simulator:

  1. Expected selector for Objective-C method
  2. Expected method body

on #import <Foundation/Foundation.h> in the AppDelegate.h file

I tried cleaning the project, closed and open Xcode,restarted the PC, tried to find a type-o, but I couldn't find any, I must add that I didn't made any changes to the app delegate file, everything happened when I changed from testing on my device to testing on the simulator.

Here is my exact code with no modifies:

//
//  AppDelegate.h
//  ChannerApp
//
//  Created by Laurentiu on 20/02/15.
//  Copyright (c) 2015 Laurentiu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GroupsViewController.h"
#import <FacebookSDK/FacebookSDK.h>
#import <UIKit/UIKit.h>
#import "XMPP.h"
#import <CoreData/CoreData.h>
#import "XMPPStream.h"
#import "XMPPReconnect.h"
#import "XMPPRoster.h"
#import "XMPPRosterCoreDataStorage.h"
#import "XMPPvCardCoreDataStorage.h"
#import "XMPPvCardAvatarModule.h"
#import "XMPPCapabilities.h"
#import "XMPPCapabilitiesCoreDataStorage.h"
#import "ConractsViewController.h"
#import "StartViewController.h"
#import "DDLog.h"
#import "Reachability.h"
#import "XMPPvCardTemp.h"


@class StartViewController, GroupsViewController;

@interface AppDelegate : UIResponder <UIApplicationDelegate, XMPPStreamDelegate, XMPPRosterDelegate, XMPPvCardTempModuleDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (nonatomic, strong) StartViewController *notSignedInView;
@property (nonatomic, strong) GroupsViewController *signedInView;
///////////////////////////////////////////////
@property (nonatomic, strong, readonly) XMPPStream *xmppStream;
@property (nonatomic, strong, readonly) XMPPReconnect *xmppReconnect;
@property (nonatomic, strong, readonly) XMPPRoster *xmppRoster;
@property (nonatomic, strong, readonly) XMPPRosterCoreDataStorage *xmppRosterStorage;
@property (nonatomic, strong, readonly) XMPPvCardTempModule *xmppvCardTempModule;
@property (nonatomic, strong, readonly) XMPPvCardAvatarModule *xmppvCardAvatarModule;
@property (nonatomic, strong, readonly) XMPPCapabilities *xmppCapabilities;
@property (nonatomic, strong, readonly) XMPPvCardCoreDataStorage *xmppvCardStorage;
@property (nonatomic, strong, readonly) XMPPvCardTemp *storedvCard;
///////////////////////////////////////////////
//all user values that should be saved
@property (nonatomic, strong) NSString *userName;
@property (nonatomic, strong) NSString *nickName;
@property (strong, nonatomic) NSString *passwordText;
@property (nonatomic, strong) NSString *firstName;
@property (strong, nonatomic) NSString *lastName;
@property (nonatomic, strong) NSString *emailAddress;
@property (strong, nonatomic) NSString *avatarImage;
@property (strong, nonatomic) NSString *gender;
@property (nonatomic, strong) NSString *facebookInfo;
@property (strong, nonatomic) NSString *linkedInInfo;
@property (strong, nonatomic) NSString *birthdate;

- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;
- (void)signInWith: (NSString *)username andPassword: (NSString *) password;
- (void)teardownStream;
- (BOOL)checkForNetwork;
- (void)savevCardWithUsername:(NSString *)username andNickname:(NSString *)andNickname andPassword:(NSString *)andPassword andLastName:(NSString *)andLastName andBirthdate:(NSString *)andBirthdate andFirstName:(NSString *)andFirstName andEmailAddress:(NSString *)andEmailAddress andAvatarImage:(NSString *)andAvatarImage andGender:(NSString *)andGender andFBInfo:(NSString *)FBInfo andLinkedInInfo:(NSString *)LinkedInInfo;

- (void)uploadvCard;

@end
Laur Stefan
  • 1,519
  • 5
  • 23
  • 50
  • Likely you get this errors, when compiling. In which line? – Amin Negm-Awad May 07 '15 at 12:18
  • @AminNegm-Awad as I mentioned in the title I get the error on the `#import ` line – Laur Stefan May 07 '15 at 12:21
  • In the importing file itself? – Amin Negm-Awad May 07 '15 at 12:23
  • The above code is the code contained inside my AppDelegate.h and I get the double error on the `#import ` line – Laur Stefan May 07 '15 at 12:26
  • Would you please provide us with contents of your prefix file? – bteapot May 07 '15 at 13:06
  • @bteapot are you referring to the .pch file? – Laur Stefan May 07 '15 at 13:17
  • @bteapot I couldn't find it, so I checked with my previous versions and I sow that they didn't had it either but they work.. I searched SO and found the next answer on .pch file and how to recreate it: [link(http://stackoverflow.com/questions/24305211/pch-file-in-xcode-6)] – Laur Stefan May 07 '15 at 13:31
  • I tried the answer that has 190 up votes but now I get the next error: Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1, I most certainly made a mistake in step 2 YouProject and in step 5 I used YourProjectName and YourProject with the same name, the project name – Laur Stefan May 07 '15 at 13:36
  • I don't think you should create prefix file. Apparently, build should succeed without it. Try to comment out other import direcives and see what happens. Also, is there anything like CocoaPods in that project? – bteapot May 07 '15 at 13:47
  • @bteapot no I do not use CocoaPods, I followed the steps: Without the question if it is proper or not, you can add PCH file manually: Add new PCH file to the project: New file > Other > PCH file. At the Target's Build Settings option, set the value of Prefix Header to your PCH file name, with the project name as prefix (i.e. for project named TestProject and PCH file named MyPrefixHeaderFile, add the value TestProject/MyPrefixHeaderFile.pch to the plist). At the Target's Build Settings option, set the value of Precompile Prefix Header to YES. And now I get the error posted earlier – Laur Stefan May 07 '15 at 13:52
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/77207/discussion-between-bteapot-and-laur-stefan). – bteapot May 07 '15 at 13:53

1 Answers1

3

I found same error in my code. checked each file. There was extra + sign on top of other file. Removed that, it works fine. Check if there is any extra character on any file.