TARGET_OS_MAC section generates a compile error on an iPhone project?
TARGET_OS_MAC section generates a compile error on an iPhone project?
- Subject: TARGET_OS_MAC section generates a compile error on an iPhone project?
- From: Tito Ciuro <email@hidden>
- Date: Fri, 27 Aug 2010 13:47:28 -0400
Hello,
I have code that's part of a framework and I'd like to port it to iOS. I tried isolating the code like so:
//
// RootViewController.m
// iPhoneTest
#import "RootViewController.h"
@implementation RootViewController
#pragma mark -
#pragma mark View lifecycle
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
- (NSUInteger)systemPageSize
{
static NSUInteger __sSystemPageSize = NSNotFound;
#if TARGET_OS_MAC
if (NSNotFound == __sSystemPageSize) {
NSTask *task = [[NSTask alloc] init];
// <do something here...>
[task release];
}
#elif TARGET_OS_IPHONE
// <do something here...>
#endif
return __sSystemPageSize;
}
When I compile the standard iPhone boilerplate app from Xcode I get the following error:
> /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m: In function '-[RootViewController systemPageSize]':
> /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m:23: error: 'NSTask' undeclared (first use in this function)
> /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m:23: error: (Each undeclared identifier is reported only once
> /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m:23: error: for each function it appears in.)
> /Users/tciuro/Desktop/iPhoneTest/Classes/RootViewController.m:23: error: 'task' undeclared (first use in this function)
> {standard input}:59:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_0" minus "L00000000001$pb"
> {standard input}:59:symbol: "L_OBJC_SELECTOR_REFERENCES_0" can't be undefined in a subtraction expression
> {standard input}:54:non-relocatable subtraction expression, "L_OBJC_CLASSLIST_SUP_REFS_$_0" minus "L00000000001$pb"
> {standard input}:54:symbol: "L_OBJC_CLASSLIST_SUP_REFS_$_0" can't be undefined in a subtraction expression
> {standard input}:unknown:Undefined local symbol L_OBJC_CLASSLIST_SUP_REFS_$_0
> {standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_0
I know NSTask doesn't exist on iOS, so I was hoping to implement the method that would work for both Mac and iOS by specifying TARGET_OS_MAC and TARGET_OS_IPHONE. What am I missing?
Thanks,
-- Tito
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden