-fobjc-arc is not supported error and duplicate symbol error in compiling

Discussion in 'Mac Programming' started by mehdies, Sep 23, 2013.

  1. mehdies
    Expand Collapse
    macrumors member

    Joined:
    Jun 10, 2012
    #1
    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?
     
  2. Catfish_Man
    Expand Collapse
    macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #2
    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.
     
  3. chown33
    Expand Collapse
    macrumors 604

    Joined:
    Aug 9, 2009
    #3
    Post the complete text of the Duplicate symbol error.

    Also post your complete code, so we know what the error is referring to.
     
  4. mehdies
    Expand Collapse
    thread starter macrumors member

    Joined:
    Jun 10, 2012
    #4
    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
     

Share This Page