我知道有很多類似的問題,我一點沒發現我的情況:獲得「爲i386硬件架構未定義的符號:」試圖讓常量
我:
#import <Foundation/Foundation.h>
@interface BSConstants : NSObject
extern NSString* const DB_COLUMN_NAME;
extern NSString* const DB_COLUMN_PRICE;
extern NSString* const DB_COLUMN_DESCRIPTION;
extern NSString* const DB_COLUMN_ICON;
extern NSString* const DB_COLUMN_IMAGE;
@end
#import "BSConstants.h"
@implementation BSConstants
NSString* const DB_COLUMN_NAME = @"name";
NSString* const DB_COLUMN_PRICE = @"price";
NSString* const DB_COLUMN_DESCRIPTION = @"description";
NSString* const DB_COLUMN_ICON = @"icon";
NSString* const DB_COLUMN_IMAGE = @"image";
@end
我當我嘗試建立我的項目 - 我得到:
Undefined symbols for architecture i386:
"_CONST_SHOPPING_CART_PURCHASE_MAX_SIZE", referenced from:
-[BSShoppingCartViewController onBuyButtonPressed:] in BSShoppingCartViewController.o
"_NAME_CREATED_FILE", referenced from:
-[BSImageSaver saveImageAsPng:] in BSImageSaver.o
"_NAME_DOWNLOADS_FOLDER", referenced from:
-[BSImageSaver saveImageAsPng:] in BSImageSaver.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
嘗試訪問:
#import "BSConstants.h"
... DB_COLUMN_NAME
你如何訪問這些常量? –
我發現了錯誤 - 我在.h和.m文件中有不同的常量名。感謝所有。 – pvllnspk
如果您發現問題,請將其作爲答案張貼並檢查。已經檢查的答案不正確。 –