2017-04-01 77 views
2

我正在用swift製作一個xcode項目,它工作正常,但突然間它開始給我這個錯誤。無法建立目標c模塊

無法建立目標C模塊 '基金會'

/Users/admin/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk/系統/資源庫/框架/ Foundation.framework /頭/ NSNotification.h:17:4:前綴屬性必須遵循的接口或協議

,甚至當我創建一個新的項目,什麼也不做,但只是建立它,會顯示此錯誤。該項目未建成。當我在錯誤消息中單擊,它使我這個文件NSNotification.h

下面是這個文件的內容

/* NSNotification.h 
Copyright (c) 1994-2016, Apple Inc. All rights reserved. 
*/ 

#import <Foundation/NSObject.h> 

typedef NSString *NSNotificationName NS_EXTENSIBLE_STRING_ENUM; 

@class NSString, NSDictionary, NSOperationQueue; 

NS_ASSUME_NONNULL_BEGIN 

/**************** Notifications ****************/ 

@interface NSNotification : NSObject <NSCopying, NSCoding> 

[email protected] (nullable, readonly, retain) id object; 
@property (nullable, readonly, copy) NSDictionary *userInfo; 

- (instancetype)initWithName:(NSNotificationName)name object:(nullable id)object userInfo:(nullable NSDictionary *)userInfo NS_AVAILABLE(10_6, 4_0) NS_DESIGNATED_INITIALIZER; 
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder  NS_DESIGNATED_INITIALIZER; 

@end 

@interface NSNotification (NSNotificationCreation) 

+ (instancetype)notificationWithName:(NSNotificationName)aName object:  (nullable id)anObject; 
+ (instancetype)notificationWithName:(NSNotificationName)aName object:  (nullable id)anObject userInfo:(nullable NSDictionary *)aUserInfo; 

- (instancetype)init /*NSUIImagePNGRepresentation_UNAVAILABLE*/; /* do  not invoke; not a valid initializer for this class */ 

@end 

/**************** Notification Center ****************/ 

@interface NSNotificationCenter : NSObject { 
@package 
void *_impl; 
void *_callback; 
void *_pad[11]; 
} 

#if FOUNDATION_SWIFT_SDK_EPOCH_AT_LEAST(8) 
@property (class, readonly, strong) NSNotificationCenter *defaultCenter; 

- (void)addObserver:(id)observer selector:(SEL)aSelector name:(nullable  NSNotificationName)aName object:(nullable id)anObject; 
#endif 

- (void)postNotification:(NSNotification *)notification; 
- (void)postNotificationName:(NSNotificationName)aName object:(nullable id)anObject; 
- (void)postNotificationName:(NSNotificationName)aName object:(nullable id)anObject userInfo:(nullable NSDictionary *)aUserInfo; 

-  (void)removeObserver:(id)observer; 
- (void)removeObserver:(id)observer name:(nullable NSNotificationName)aName object:(nullable id)anObject; 

- (id <NSObject>)addObserverForName:(nullable NSNotificationName)name object:(nullable id)obj queue:(nullable NSOperationQueue *)queue usingBlock:(void (^)(NSNotification *note))block NS_AVAILABLE(10_6, 4_0); 
// The return value is retained by the system, and should be held onto by the caller in 
// order to remove the observer with removeObserver: later, to stop observation. 

@end 

NS_ASSUME_NONNULL_END 

請幫我通過這個。我將非常感謝這一點。謝謝。

回答

3

這條線NSNotification.h看起來像是被修改:

[email protected] (nullable, readonly, retain) id object; 

在該行的前刪除id並嘗試重新編譯。這應該解決它。

+0

謝謝@Dave它解決了我的問題。 –

相關問題