私は簡単なプログラムを書きましたが、シンボルリンカーエラーが重複しています (以下のエラー) @interface Fraction を除いて、.h ファイルには何も追加されていません: NSObject @end
私はxcodeにかなり慣れていません。
//SAMPLE CODE
#import "JTViewController.h"
@interface Fraction ()
-(void) print;
-(void) setNumerator: (int) n;
-(void) setDenominator: (int) d;
@end
@implementation Fraction
{
int numerator;
int denominator;
}
-(void) print
{
NSLog (@"%i/%i", numerator, denominator);
}
-(void) setNumerator:(int)n
{
numerator = n;
}
-(void) setDenominator:(int)d
{
denominator = d;
}
@end
int main (int argc, char * argv[])
{
@autoreleasepool {
// Create an instance of Fraction and initialise it
Fraction *myFraction = [[Fraction alloc] init];
//Set Fraction to 1/3
[myFraction setNumerator: 1];
[myFraction setDenominator: 3];
//Display the fraction using the print method
[myFraction print];
}
return 0;
}
これがエラーです
Ld /Users/jamesmurray/Library/Developer/Xcode/DerivedData/BrandNew-akqlirretjwoeuaqkrwlbqmlqxlc/Build/Products/Debug-iphonesimulator/BrandNew.app/BrandNew normal i386
cd /Users/jamesmurray/AppsDev/BrandNew
setenv IPHONEOS_DEPLOYMENT_TARGET 6.1
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk -L/Users/jamesmurray/Library/Developer/Xcode/DerivedData/BrandNew-akqlirretjwoeuaqkrwlbqmlqxlc/Build/Products/Debug-iphonesimulator -F/Users/jamesmurray/Library/Developer/Xcode/DerivedData/BrandNew-akqlirretjwoeuaqkrwlbqmlqxlc/Build/Products/Debug-iphonesimulator -filelist /Users/jamesmurray/Library/Developer/Xcode/DerivedData/BrandNew-akqlirretjwoeuaqkrwlbqmlqxlc/Build/Intermediates/BrandNew.build/Debug-iphonesimulator/BrandNew.build/Objects-normal/i386/BrandNew.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=6.1 -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/jamesmurray/Library/Developer/Xcode/DerivedData/BrandNew-akqlirretjwoeuaqkrwlbqmlqxlc/Build/Products/Debug-iphonesimulator/BrandNew.app/BrandNew
duplicate symbol _main in:
/Users/jamesmurray/Library/Developer/Xcode/DerivedData/BrandNew-akqlirretjwoeuaqkrwlbqmlqxlc/Build/Intermediates/BrandNew.build/Debug-iphonesimulator/BrandNew.build/Objects-normal/i386/main.o
/Users/jamesmurray/Library/Developer/Xcode/DerivedData/BrandNew-akqlirretjwoeuaqkrwlbqmlqxlc/Build/Intermediates/BrandNew.build/Debug-iphonesimulator/BrandNew.build/Objects-normal/i386/JTViewController.o
ld: 1 duplicate symbol for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
どこから来たのかわかりません。任意の支援をいただければ幸いです。