这太荒谬了,我试图创建一个声音布尔来打开应用程序声音。我不断得到
Undefined symbols for architecture i386:
"_kPlaySoundPrefsKey", referenced from:
-[AppDelegate application:didFinishLaunchingWithOptions:] in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我已经检查了我的所有文件是否都在构建阶段链接,我已经删除了 appdelegate .m,在我什至在我的任何视图控制器中调用 bool 之前我得到了错误,并在构建阶段重新导入它。检查我有相关的框架。我什至检查了我使用相同代码制作的以前的应用程序,它的代码似乎完全相同,没有错误(使用以前版本的 xcode 构建)。回到基础,只要将以下代码添加到我的 App Delegate,我就会收到错误消息,
。H
#import <UIKit/UIKit.h>
extern NSString *kPlaySoundPrefsKey;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
.m
#import "AppDelegate.h"
#import <AudioToolbox/AudioToolbox.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
NSDictionary *defaultDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]
forKey:kPlaySoundPrefsKey];
return YES;
}
如果我改变extern NSString *kPlaySoundPrefsKey;
它 NSString *kPlaySoundPrefsKey;
构建然后崩溃......我现在没有想法