-1

I keep getting this error but I have no idea where it's coming from.

linker command failed with exit code 1 (use -v to see invocation)

enter image description here

How do I fix this?

Here's the code from WebView.m

 #import "WebViewController1.h"

    @interface ViewController ()

    @property (strong, nonatomic) IBOutlet UIWebView *webView;
    @property (weak, nonatomic) IBOutlet UIWebView *webView2;

    @end

    @implementation ViewController

Here's the code from WebViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController


@end
PHP Web Dev 101
  • 535
  • 2
  • 9
  • 21

3 Answers3

1

It looks like you have duplicate class names (ViewController) one in WebView.m and one in ViewController.m

Stanislav Ageev
  • 778
  • 4
  • 10
1

You have done one of two things wrong here.

You either mistakenly imported ViewController.m (instead of ViewController.h) into WebView.m. Or your WebView.h and .m mistakenly declare the ViewController class instead of the WebView class.

Based on the comments and the updated question it seems to be latter problem.

Both ViewController.h/.m and WebView.m/WebViewController.h declare the class ViewController.

  1. You really need to give your .h and .m files the same name. I would suggest renaming WebView.m to WebViewController.m. It makes things a lot clearer if the .h and .m for a class are the same and have the same name as the class.
  2. Fix WebViewController.h so you declare WebViewController instead of ViewController:

    @imterface WebViewController : UIViewController
    
  3. Fix WebViewController.m (the former WebView.m so you define WebViewController instead of ViewController.

    #import "WebViewController.h"
    
    @interface WebViewController ()
    
    @property (strong, nonatomic) IBOutlet UIWebView *webView;
    @property (weak, nonatomic) IBOutlet UIWebView *webView2;
    
    @end
    
    @implementation WebViewController
    
rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • So how do I fix this? – PHP Web Dev 101 Aug 17 '15 at 16:42
  • If you are importing `ViewController.m`, fix the import statement to import `ViewController.h`. If your `WebView.h` and `.m` declare `ViewController` instead of `WebView`, fix your `@interface` and `@implementation` lines to declare `WebView`. – rmaddy Aug 17 '15 at 16:45
  • Instead of ViewController, I put "UIwebView" but then I received 6 different errors. Here's what my .m file looks like (which UIwebView on @implementation and @interface) - http://i.stack.imgur.com/tOUxz.png – PHP Web Dev 101 Aug 17 '15 at 16:51
  • You're not doing what I stated. Your `ViewController.m` and `ViewController.h` files are fine (most likely). You need to edit your `WebView.h` and `WebView.m` files. This has nothing to do with references to `UIWebView`. If you are still having issues, update your question with your `WebView.h` file and the top portion of your `WebView.m` file (from the 1st learn just just a few lines beyond the `@implementation` line). – rmaddy Aug 17 '15 at 16:55
  • I added the code from the webview.m and the viewcontroller.h to my question – PHP Web Dev 101 Aug 17 '15 at 17:02
  • I clearly stated to add `WebView.h` and `WebView.m`. – rmaddy Aug 17 '15 at 17:04
  • There is no WebView.h only WebView.m and WebViewController.h – PHP Web Dev 101 Aug 17 '15 at 17:06
0

You might have imported ViewController.h in your WebView.h and at the same time for your need , might have imported WebView.h in your ViewController.h The compiler will find the same ViewController imported two times , first in your WebView.h and Second is your actual ViewController.h

This is because the duplicate entries are found.

Please do not import the ViewController.h in your WebView.h while you are importing WebView.h in your ViewController.h

Shubham Ojha
  • 461
  • 5
  • 17
  • Simply importing the two .h files wouldn't cause a linker error for duplicate symbols. If anything, you might get a compiler error. – rmaddy Aug 17 '15 at 15:54