简体   繁体   English

多个Xcode项目将无法再在真实的iOS设备上成功编译

[英]Multiple Xcode projects will no longer successfully compile on a real iOS device

I might have accidentally edited the NSAttributedString.h class and/or a related class, and it now seems all my Xcode projects including projects I create will not compile on my iPhone (iPhone 4s iOS version: 9.3.2) (my deployment target is iOS 9.0.). 我可能不小心编辑了NSAttributedString.h类和/或相关类,现在看来我所有的Xcode项目(包括我创建的项目)都无法在iPhone上编译(iPhone 4s iOS版本:9.3.2)(我的部署目标是iOS 9.0。)。

The Xcode projects will successfully build and deploy to a simulated iPhone. Xcode项目将成功构建并部署到模拟iPhone。

Here is an edited list of errors I get when I try and compile the app for an iPhone: 这是我尝试为iPhone编译应用程序时收到的错误的编辑列表:

System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:13:2: Prefix attribute must be followed by an interface or protocol
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:16:1: Expected method body
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:23:1: Expected method body
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:26:1: Expected method body
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:30:1: Expected method body
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:32:1: Expected method body
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:40:1: Expected method body
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:42:1: '@end' must appear in an Objective-C context
AppPods/Target Support Files/Pods-App/Pods-App-dummy.m:1:9: Could not build module 'Foundation'
Semantic Issue Group
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:14:1: Missing context for method declaration
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:22:1: Missing context for method declaration
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:25:1: Missing context for method declaration
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:28:1: Missing context for method declaration
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:31:1: Missing context for method declaration
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:39:1: Missing context for method declaration
System/Library/Frameworks/Foundation.framework/Headers/NSAttributedString.h:45:40: Attempting to use the forward class 'NSAttributedString' as superclass of 'NSMutableAttributedString'

I am using Xcode 8 beta. 我正在使用Xcode 8 Beta。

Does anyone know what would be causing this error? 有谁知道会导致此错误的原因吗?

I've tried restarting and reconnecting the iPhone,restarting Xcode, re-staring my mac, and deleting the DerivedData folder. 我尝试过重新启动并重新连接iPhone,重新启动Xcode,重新注视Mac并删除DerivedData文件夹。 I read here that the Expected method body can be caused by a "stray character" in the code but I couldn't find a stray character. 在这里阅读Expected method body可能是由代码中的“杂散字符”引起的,但是我找不到杂散字符。

Here is the NSAttributedString.h class: 这是NSAttributedString.h类:

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


#import <Foundation/NSString.h>
#import <Foundation/NSDictionary.h> 

NS_ASSUME_NONNULL_BEGIN 

NS_CLASS_AVAILABLE(10_0, 3_2)

@property (readonly, copy) NSString *string;
- (NSDictionary<NSString *, id> *)attributesAtIndex:(NSUInteger)location effectiveRange:(nullable NSRangePointer)range;

@end

@interface NSAttributedString (NSExtendedAttributedString)


@property (readonly) NSUInteger length;
- (nullable id)attribute:(NSString *)attrName atIndex:(NSUInteger)location effectiveRange:(nullable NSRangePointer)range;
- (NSAttributedString *)attributedSubstringFromRange:(NSRange)range;

- (NSDictionary<NSString *, id> *)attributesAtIndex:(NSUInteger)location longestEffectiveRange:(nullable NSRangePointer)range inRange:(NSRange)rangeLimit;
- (nullable id)attribute:(NSString *)attrName atIndex:(NSUInteger)location longestEffectiveRange:(nullable NSRangePointer)range inRange:(NSRange)rangeLimit;

- (BOOL)isEqualToAttributedString:(NSAttributedString *)other;

- (instancetype)initWithString:(NSString *)str;
- (instancetype)initWithString:(NSString *)str attributes:(nullable NSDictionary<NSString *, id> *)attrs;
- (instancetype)initWithAttributedString:(NSAttributedString *)attrStr;

typedef NS_OPTIONS(NSUInteger, NSAttributedStringEnumerationOptions) {
  NSAttributedStringEnumerationReverse = (1UL << 1),
  NSAttributedStringEnumerationLongestEffectiveRangeNotRequired = (1UL << 20)
};

- (void)enumerateAttributesInRange:(NSRange)enumerationRange options:(NSAttributedStringEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(NSDictionary<NSString *, id> *attrs, NSRange range, BOOL *stop))block NS_AVAILABLE(10_6, 4_0);
- (void)enumerateAttribute:(NSString *)attrName inRange:(NSRange)enumerationRange options:(NSAttributedStringEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(id _Nullable value, NSRange range, BOOL *stop))block NS_AVAILABLE(10_6, 4_0);

@end

NS_CLASS_AVAILABLE(10_0, 3_2)
@interface NSMutableAttributedString : NSAttributedString

- (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str;
- (void)setAttributes:(nullable NSDictionary<NSString *, id> *)attrs range:(NSRange)range;

@end

@interface NSMutableAttributedString (NSExtendedMutableAttributedString)

@property (readonly, retain) NSMutableString *mutableString;

- (void)addAttribute:(NSString *)name value:(id)value range:(NSRange)range;
- (void)addAttributes:(NSDictionary<NSString *, id> *)attrs range:(NSRange)range;
- (void)removeAttribute:(NSString *)name range:(NSRange)range;

- (void)replaceCharactersInRange:(NSRange)range withAttributedString:(NSAttributedString *)attrString;
- (void)insertAttributedString:(NSAttributedString *)attrString atIndex:(NSUInteger)loc;
- (void)appendAttributedString:(NSAttributedString *)attrString;
- (void)deleteCharactersInRange:(NSRange)range;
- (void)setAttributedString:(NSAttributedString *)attrString;

- (void)beginEditing;
- (void)endEditing;

@end

NS_ASSUME_NONNULL_END

Thanks in advance 提前致谢

您删除了@interface NSAttributedString : NSObject <NSCopying, NSMutableCopying, NSSecureCoding> NS_CLASS_AVAILABLE(10_0, 3_2)下面的@interface NSAttributedString : NSObject <NSCopying, NSMutableCopying, NSSecureCoding>

I think you had modified NSAttributedString.m with mistake. 我认为您错误地修改了NSAttributedString.m。

You can to reinstall the xcode to resolove. 您可以重新安装xcode以重新安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM