I include "Reachability/Reachability.m"
我把“可达性/ Reachability.m”
AppDelegate.h
#import <UIKit/UIKit.h>
#import "Reachability/Reachability.m"
@class ...;
@interface ... : NSObject <UIApplicationDelegate> {
UIWindow *window;
... *viewController;
Reachability *hostReach;
NetworkStatus netStatus;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property (nonatomic) NetworkStatus netStatus;
-(void)updateInterfaceWithReachability: (Reachability*) curReach;
@end
AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h"
@implementation ...
@synthesize window=_window;
@synthesize navigationController=_navigationController;
@synthesize netStatus;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reachabilityChanged:) name: kReachabilityChangedNotification object: nil];
hostReach = [[Reachability reachabilityWithHostName:@"www.apple.com"]retain];
[hostReach startNotifier];
[self updateInterfaceWithReachability:hostReach];
// Set the view controller as the window's root view controller and display.
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
and I get an error
我得到一个错误。
ld: duplicate symbol _OBJC_IVAR_$_Reachability.localWiFiRef in /Users/../Documents/../build/.. .build/Debug-iphonesimulator/.. .build/Objects-normal/i386/..ViewController.o and /Users/../Documents/../build/.. .build/Debug-iphonesimulator/.. .build/Objects-normal/i386/..AppDelegate.o
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
how to solve this problem? and what it might be related?
如何解决这个问题?它有什么关系呢?
4 个解决方案
#1
5
I was having the same problem because one third-party library (libPusher) I'm using was including Reachability already.
我遇到了同样的问题,因为我使用的第三方库(libPusher)已经包括了可达性。
Since that library was pre-compiled, I wasn't sure what to do, but adding only Reachability.h
to the project (and not Reachability.m
) worked. That allowed me to import it and use the class but I didn't have the duplicate symbol issue.
由于该库是预编译的,所以我不确定该做什么,但只增加了可达性。h对项目(而不是可达性)起作用。这允许我导入它并使用这个类,但是我没有重复的符号问题。
#2
2
You only import header files. Do,
您只导入头文件。做的,
#import "Reachability/Reachability.h"
#3
2
you have to make sure your project folder contains one Reachability.h and one Reachability.m files , ASIHTTPRequest library has both these files in it hence the duplicate symbol error when adding the Reachability library. after removing the duplicate files do a clean build
您必须确保您的项目文件夹包含一个可达性。h和可达性。m文件,ASIHTTPRequest库中都有这些文件,因此添加可达性库时,会出现重复的符号错误。删除重复的文件后,进行一个干净的构建。
#4
0
- Removing the reference of reachability.m from the project.
- 消除可达性的参考。从项目。
- Add Framework or files you want (which created this issue).
- 添加您想要的框架或文件(创建这个问题)。
- Clean and Build project
- 清洁和建设项目
It worked for me.
它为我工作。
when i tried adding framework in project, and this duplicate issue appeared.
当我尝试在项目中添加框架时,这个重复的问题出现了。
#1
5
I was having the same problem because one third-party library (libPusher) I'm using was including Reachability already.
我遇到了同样的问题,因为我使用的第三方库(libPusher)已经包括了可达性。
Since that library was pre-compiled, I wasn't sure what to do, but adding only Reachability.h
to the project (and not Reachability.m
) worked. That allowed me to import it and use the class but I didn't have the duplicate symbol issue.
由于该库是预编译的,所以我不确定该做什么,但只增加了可达性。h对项目(而不是可达性)起作用。这允许我导入它并使用这个类,但是我没有重复的符号问题。
#2
2
You only import header files. Do,
您只导入头文件。做的,
#import "Reachability/Reachability.h"
#3
2
you have to make sure your project folder contains one Reachability.h and one Reachability.m files , ASIHTTPRequest library has both these files in it hence the duplicate symbol error when adding the Reachability library. after removing the duplicate files do a clean build
您必须确保您的项目文件夹包含一个可达性。h和可达性。m文件,ASIHTTPRequest库中都有这些文件,因此添加可达性库时,会出现重复的符号错误。删除重复的文件后,进行一个干净的构建。
#4
0
- Removing the reference of reachability.m from the project.
- 消除可达性的参考。从项目。
- Add Framework or files you want (which created this issue).
- 添加您想要的框架或文件(创建这个问题)。
- Clean and Build project
- 清洁和建设项目
It worked for me.
它为我工作。
when i tried adding framework in project, and this duplicate issue appeared.
当我尝试在项目中添加框架时,这个重复的问题出现了。