Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mehdies

macrumors member
Original poster
Jun 10, 2012
41
0
Hi all

I have a source code with Three files:

1 - main.m
2 - methods.h
3 - methods.m

I declare methods in methods.h and put definitions of methods in methods.m.
and create an object in main.m for using methods of the Class.

But when i compiling my source in xcode got this error :

Code:
error: -fobjc-arc is not supported on platforms using the legacy runtime
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

and when methods.m in Build phases -> Compile sources is present got Duplicate symbol error too.

Could you help me?
 

Catfish_Man

macrumors 68030
Sep 13, 2001
2,579
2
Portland, OR
Hi all

I have a source code with Three files:

1 - main.m
2 - methods.h
3 - methods.m

I declare methods in methods.h and put definitions of methods in methods.m.
and create an object in main.m for using methods of the Class.

But when i compiling my source in xcode got this error :

Code:
error: -fobjc-arc is not supported on platforms using the legacy runtime
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

and when methods.m in Build phases -> Compile sources is present got Duplicate symbol error too.

Could you help me?

ARC isn't supported for 32 bit apps on OSX. You'll need to either only build 64 bit (which would be my suggestion), or not use ARC.
 

mehdies

macrumors member
Original poster
Jun 10, 2012
41
0
Source Information :

methods.h

Code:
#import <Foundation/Foundation.h>


NSString *string1 = @"test string1";
NSString *string2 = @"test string2";



@interface methods : NSObject

-(void) methodOne;

-(void) methodTwo;

-(void) methodThree;

@end

methods.m

Code:
#import "methods.h"


@implementation methods



-(void) methodOne
{
	NSLog(@"method 1");
}

-(void) methodTwo
{
	NSLog(@"method 2");
}

-(void) methodThree
{
	NSLog(@"method 3");
}

@end

main.m

Code:
#import <Foundation/Foundation.h>
#import "methods.h"



int main(int argc, const char * argv[])
{
    
    @autoreleasepool {
        
        
        methods *objectOfClass = [[methods alloc] init];
        
        
        [objectOfClass methodOne];
        [objectOfClass methodTwo];
        [objectOfClass methodThree];
            
            
      
        
        
    }
    
    return 0;
}

These source not my real code but exactly is like this.

** Duplicate was for string1 and string2.so i cut these strings and paste in methods.m and problem solved.

** Thanks to Catfish_Man - I not use ARC now and problem solved.




Thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.