I am trying to import <Social/Social.h>
in my project, but when I try to run, I get the error Objective-C declarations may only appear in global scope
in the two files SLRequest.h
and SLComposeViewController.h
. A thing to be mentioned is that the Social.framework
remains in Frameworks group in the project navigator even though I've deleted it which I think is the cause of the problem. I tried to remove and re-add it from Link Binary With Libraries, but I had no luck. I tried to use it in another project and it runs with successfully.
Update: #import
is above @implementation
. This is exactly my code:
#import "flatGreenColor.h"
#import <MessageUI/MessageUI.h>
#import <Social/Social.h>
@end
@interface SettingsController1 ()
@property (nonatomic, strong) NSArray* settingTitles;
@property (nonatomic, strong) NSArray* settingsElements;
@property (nonatomic, strong) NSString* boldFontName;
@property (nonatomic, strong) UIColor* onColor;
@property (nonatomic, strong) UIColor* offColor;
@property (nonatomic, strong) UIColor* dividerColor;
@end
This error was caused as I was adding an
@end
after#import <Social/Social.h>
. I forgot to add it in anotherheader
which I was importing to my.m
. The answer was provided in the comments by @Tommy