Unknown Xcode Error: linker command failed with exit code 1 (use -v to see invocation)
Unknown Xcode Error: linker command failed with exit code 1 (use -v to see invocation)
我一直收到此错误,但我不知道它从哪里来。
linker command failed with exit code 1 (use -v to see invocation)
我该如何解决这个问题?
这是来自 WebView.m
的代码
#import "WebViewController1.h"
@interface ViewController ()
@property (strong, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet UIWebView *webView2;
@end
@implementation ViewController
这是来自 WebViewController.h
的代码
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
您似乎有重复的 class 个名称 (ViewController),一个在 WebView.m 中,一个在 ViewController.m
中
您可能在 WebView.h 中导入了 ViewController.h,同时根据您的需要,可能在 ViewController.h 中导入了 WebView.h
编译器会发现相同的 ViewController 被导入了两次,第一次是在你的 WebView.h 中,第二次是你实际的 ViewController.h
这是因为发现了重复的条目。
在 ViewController.h
中导入 WebView.h 时,请不要在 WebView.h 中导入 ViewController.h
你在这里做错了两件事之一。
您可能错误地将 ViewController.m
(而不是 ViewController.h
)导入了 WebView.m
。或者您的 WebView.h
和 .m
错误地声明了 ViewController
class 而不是 WebView
class.
根据评论和更新后的问题,它似乎是后一个问题。
ViewController.h/.m
和 WebView.m/WebViewController.h
都声明 class ViewController
。
- 您确实需要为您的 .h 和 .m 文件命名。我建议将
WebView.m
重命名为 WebViewController.m
。如果 class 的 .h 和 .m 与 class. 相同且名称相同,则事情会更清楚
修复 WebViewController.h
以便声明 WebViewController
而不是 ViewController
:
@imterface WebViewController : UIViewController
修复WebViewController.m
(之前的WebView.m
所以你定义WebViewController
而不是ViewController
.
#import "WebViewController.h"
@interface WebViewController ()
@property (strong, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet UIWebView *webView2;
@end
@implementation WebViewController
我一直收到此错误,但我不知道它从哪里来。
linker command failed with exit code 1 (use -v to see invocation)
我该如何解决这个问题?
这是来自 WebView.m
的代码 #import "WebViewController1.h"
@interface ViewController ()
@property (strong, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet UIWebView *webView2;
@end
@implementation ViewController
这是来自 WebViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
您似乎有重复的 class 个名称 (ViewController),一个在 WebView.m 中,一个在 ViewController.m
中您可能在 WebView.h 中导入了 ViewController.h,同时根据您的需要,可能在 ViewController.h 中导入了 WebView.h 编译器会发现相同的 ViewController 被导入了两次,第一次是在你的 WebView.h 中,第二次是你实际的 ViewController.h
这是因为发现了重复的条目。
在 ViewController.h
中导入 WebView.h 时,请不要在 WebView.h 中导入 ViewController.h你在这里做错了两件事之一。
您可能错误地将 ViewController.m
(而不是 ViewController.h
)导入了 WebView.m
。或者您的 WebView.h
和 .m
错误地声明了 ViewController
class 而不是 WebView
class.
根据评论和更新后的问题,它似乎是后一个问题。
ViewController.h/.m
和 WebView.m/WebViewController.h
都声明 class ViewController
。
- 您确实需要为您的 .h 和 .m 文件命名。我建议将
WebView.m
重命名为WebViewController.m
。如果 class 的 .h 和 .m 与 class. 相同且名称相同,则事情会更清楚
修复
WebViewController.h
以便声明WebViewController
而不是ViewController
:@imterface WebViewController : UIViewController
修复
WebViewController.m
(之前的WebView.m
所以你定义WebViewController
而不是ViewController
.#import "WebViewController.h" @interface WebViewController () @property (strong, nonatomic) IBOutlet UIWebView *webView; @property (weak, nonatomic) IBOutlet UIWebView *webView2; @end @implementation WebViewController