2012-03-27 20 views
6

ऐसा लगता है कि संकलन करने का प्रयास करते समय मुझे एक त्रुटि हो रही है और ऐसा लगता है कि यह दो फाइलों को सीधे इंगित कर रहा है .. मेनू व्यू कंट्रोलर और फर्स्ट टॉप व्यू कंट्रोलर। मुझे लगता है कि इसमें मेरे आयात के साथ कुछ करना है, क्योंकि उनमें से प्रत्येक दूसरे को आयात कर रहा है, हालांकि त्रुटि मेरी बिल्डिंग ऑब्जेक्ट का संदर्भ दे रही है, जिसका उपयोग शायद ही कभी किया जाता है। साथ ही, क्लैंग त्रुटि के साथ, मैं आमंत्रण देखने के लिए -v का उपयोग कैसे करूं?आईओएस - लिंकर त्रुटि, डुप्लिकेट प्रतीक

त्रुटि:

ld: duplicate symbol _OBJC_CLASS_$_Building in /Users/alexmuller/Library/Developer/Xcode/DerivedData/ECSlidingViewController-gjxwxiwumgohyehiawnlamggzmop/Build/Intermediates/ECSlidingViewController.build/Debug-iphonesimulator/ECSlidingViewController.build/Objects-normal/i386/FirstTopViewController.o and /Users/alexmuller/Library/Developer/Xcode/DerivedData/ECSlidingViewController-gjxwxiwumgohyehiawnlamggzmop/Build/Intermediates/ECSlidingViewController.build/Debug-iphonesimulator/ECSlidingViewController.build/Objects-normal/i386/MenuViewController.o for architecture i386 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

FirstTopViewController.h

#import <UIKit/UIKit.h> 
#import <QuartzCore/QuartzCore.h> 
#import "ECSlidingViewController.h" 
#import "MenuViewController.h" 
#import "TimesViewController.h" 
#import "BuildingViewController.h" 
#import "BuildingAnnotation.h" 
#import <MapKit/MapKit.h> 

@class BuildingViewController; 

@interface FirstTopViewController : UIViewController <MKMapViewDelegate> { 
    IBOutlet MKMapView *_map; 
    BuildingViewController *buildingVC; 
    BuildingAnnotation *buildAnnotation; 
} 

@property (nonatomic, strong) MKMapView *map; 

- (IBAction)revealMenu:(id)sender; 
- (IBAction)revealTimes:(id)sender; 
- (void)loadBuilding:(Building *)building; 

@end 

FirstTopViewController.m

#import "FirstTopViewController.h" 

@implementation FirstTopViewController 

@synthesize map = _map; 

- (void)viewDidLoad { 

    buildingVC = (BuildingViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"BuildingList"]; 
    [super viewDidLoad]; 
} 

- (void)viewWillAppear:(BOOL)animated 
{ 
    [(UIView *)[self.view viewWithTag:10] setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"RedWithNoise"]]]; 
    [super viewWillAppear:animated]; 
    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"toolbar"] forBarMetrics:UIBarMetricsDefault]; 
    [[UINavigationBar appearance] setTitleTextAttributes: 
    [NSDictionary dictionaryWithObjectsAndKeys: 
     [UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:102.0/255.0 alpha:1.0], 
     UITextAttributeTextColor, 
     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8], 
     UITextAttributeTextShadowColor, 
     [NSValue valueWithUIOffset:UIOffsetMake(0, -1)], 
     UITextAttributeTextShadowOffset, 
     [UIFont fontWithName:@"AGaramondPro-Regular" size:23.0], 
     UITextAttributeFont, 
     nil]]; 
    self.view.layer.shadowOffset = CGSizeZero; 
    self.view.layer.shadowOpacity = 0.75f; 
    self.view.layer.shadowRadius = 10.0f; 
    self.view.layer.shadowColor = [UIColor blackColor].CGColor; 
    self.view.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.view.layer.bounds].CGPath; 
    self.view.clipsToBounds = NO; 

    MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(CLLocationCoordinate2DMake(30.451667, -84.268533), 16090.344, 16090.344); 
    viewRegion = [_map regionThatFits:viewRegion]; 
    [_map setRegion:viewRegion animated:YES]; 

    if (![self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) { 
     self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"]; 
    } 

    if (![self.slidingViewController.underRightViewController isKindOfClass:[TimesViewController class]]) { 
     self.slidingViewController.underRightViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Times"]; 
    } 

    [self.view addGestureRecognizer:self.slidingViewController.panGesture]; 


} 

- (void)loadBuilding:(Building *)building { 
    if (buildingVC.buildingSelected) { 
     if (buildAnnotation != nil) { 
      [_map removeAnnotation:buildAnnotation]; 
     } 
     NSLog(@"%@", building.getName); 
     buildAnnotation = [[BuildingAnnotation alloc] initWithCoordinate:building.getLocation.coordinate withName:building.getName withAddress:building.getAddress]; 
     [_map setCenterCoordinate:buildAnnotation.coordinate animated:YES]; 
     [_map addAnnotation:buildAnnotation]; 
    } 
} 

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    self.view.layer.shadowPath = nil; 
    self.view.layer.shouldRasterize = YES; 
} 

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
    self.view.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.view.layer.bounds].CGPath; 
    self.view.layer.shouldRasterize = NO; 
} 

- (IBAction)revealMenu:(id)sender 
{ 
    [self.slidingViewController anchorTopViewTo:ECRight]; 
} 

- (IBAction)revealTimes:(id)sender { 
    [self.slidingViewController anchorTopViewTo:ECLeft]; 
} 

@end 

MenuViewController.h

#import <UIKit/UIKit.h> 
#import "ECSlidingViewController.h" 
#import "FirstTopViewController.h" 
#import "TimesViewController.h" 

@interface MenuViewController : UIViewController <UITableViewDataSource, UITabBarControllerDelegate> { 
    NSIndexPath *selectedIndex; 
} 

@end 

MenuViewController.m

#import "MenuViewController.h" 

typedef enum { 
    ENGINEERING, 
    GARNET, 
    GOLD, 
    HERITAGE, 
    NIGHT, 
    OSCEOLA, 
    RENEGADE, 
    TOMAHAWK 
} RouteName; 


@interface MenuViewController() 
@property (nonatomic, strong) NSArray *menuItems; 
@property (nonatomic, strong) NSArray *optionItems; 
@property (nonatomic, strong) NSArray *arrayItems; 

- (UIImage *)determineActiveRoute:(RouteName)route; 
@end 

@implementation MenuViewController 
@synthesize menuItems, optionItems, arrayItems; 

- (void)awakeFromNib 
{ 

    self.menuItems = [NSArray arrayWithObjects:@"Engineering", @"Garnet", @"Gold", @"Heritage Grove", @"Night Nole", @"Osceola", @"Renegade", @"Tomahawk", nil]; 
    self.optionItems = [NSArray arrayWithObjects:@"Buildings", @"Directions", nil]; 
    self.arrayItems = [NSArray arrayWithObjects:self.menuItems, self.optionItems, nil]; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    [self.slidingViewController setAnchorRightRevealAmount:200.0f]; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionIndex 
{ 
    return [[self.arrayItems objectAtIndex:sectionIndex] count]; 
} 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return [self.arrayItems count]; 
} 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
    return 35; 
} 

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { 
    UIView *sectionView = [[UIView alloc] init]; 
    [sectionView sizeToFit]; 
    sectionView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"navCellDivider"]]; 
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 100, 20)]; 
    label.textColor = [UIColor grayColor]; 
    label.backgroundColor = [UIColor clearColor]; 
    label.font = [UIFont fontWithName:@"AGaramondPro-Regular" size:12.0]; 
    if(section == 0) 
     label.text = @"BUS ROUTES"; 
    else 
     label.text = @"OTHER OPTIONS"; 
    [sectionView addSubview:label]; 
    return sectionView; 
} 

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { 
    return 20; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UILabel *label; 
    UIImageView *imageView; 
    NSString *cellIdentifier = @"MenuItemCell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 

    } 
    UIView *selectedView = [[UIView alloc] initWithFrame:cell.frame]; 
    selectedView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"navCellBackgroundSelected"]]; 
    cell.selectedBackgroundView = selectedView; 
    cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"navCellBackground"]]; 
    label = (UILabel *)[cell.contentView viewWithTag:100]; 
    label.font = [UIFont fontWithName:@"AGaramondPro-Regular" size:15.0]; 
    label.text = [[self.arrayItems objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]; 
    imageView = (UIImageView *)[cell.contentView viewWithTag:101]; 
    if (indexPath.section == 0) { 
     [imageView setImage:[self determineActiveRoute:indexPath.row]]; 
    } else { 
     if (indexPath.row == 0) { 
      [imageView setImage:[UIImage imageNamed:@"building"]]; 
     } else { 
      [imageView setImage:[UIImage imageNamed:@"60-signpost"]]; 
     } 
    } 

    return cell; 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    /* Type cast view as a First Top to make it easier to read. Do switch to select correct route, 
     then modify map afterwards to load up correct route. 
    TimesViewController can be set to the corresponding times when selected 
    */ 
    FirstTopViewController *mapViewController = (FirstTopViewController *)self.slidingViewController.topViewController; 
    TimesViewController *timesViewController = (TimesViewController *)self.slidingViewController.underRightViewController; 

    if (indexPath.section == 0) { 
     selectedIndex = indexPath; 
     switch (indexPath.row) { 
      case ENGINEERING: 
       NSLog(@"Engineering Selected\n"); 
       timesViewController.times.text = @"Engineering"; 
       break; 
      case GARNET: 
       NSLog(@"Garnet Selected\n"); 
       timesViewController.times.text = @"Garnet"; 
       break; 
      case GOLD: 
       NSLog(@"Gold Selected\n"); 
       timesViewController.times.text = @"Gold"; 
       break; 
      case HERITAGE: 
       NSLog(@"Heritage Grove Selected\n"); 
       timesViewController.times.text = @"Heritage Grove"; 
       break; 
      case NIGHT: 
       NSLog(@"Night Nole Selected\n"); 
       timesViewController.times.text = @"Night Nole"; 
       break; 
      case OSCEOLA: 
       NSLog(@"Osceola Selected\n"); 
       timesViewController.times.text = @"Osceola"; 
       break; 
      case RENEGADE: 
       NSLog(@"Renegade Selected\n"); 
       timesViewController.times.text = @"Renegade"; 
       break; 
      case TOMAHAWK: 
       NSLog(@"Tomahawk Selected\n"); 
       timesViewController.times.text = @"Tomahawk"; 
       break; 
      default: 
       break; 
     } 
    } else { 
     if (indexPath.row == 0) { 
      BuildingViewController *buildings = [self.storyboard instantiateViewControllerWithIdentifier:@"BuildingList"]; 
      buildings.userLoc = [[CLLocation alloc] initWithLatitude:mapViewController.map.userLocation.coordinate.latitude longitude:mapViewController.map.userLocation.coordinate.longitude]; 

      [self presentModalViewController:buildings animated:YES]; 
     } 
     [tableView deselectRowAtIndexPath:indexPath animated:NO]; 
     [tableView selectRowAtIndexPath:selectedIndex animated:YES scrollPosition:UITableViewScrollPositionNone]; 
    } 
    [self.slidingViewController anchorTopViewTo:ECRight animations:nil onComplete:^{ 
     [self.slidingViewController resetTopView]; 
    }]; 
} 

- (UIImage *)determineActiveRoute:(RouteName)route { 
    NSCalendar *gregorianCalender = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; 
    NSDateComponents *components = [gregorianCalender components:NSHourCalendarUnit fromDate:[NSDate date]]; 
    switch (route) { 
     case ENGINEERING: 
      if ([components day] % 7 == 2) { 
       if (([components hour] >= 7) && ([components hour] < 17)) { 
        return [UIImage imageNamed:@"green"]; 
       } else { 
        return [UIImage imageNamed:@"red"]; 
       } 
      } else if (([components day] % 7 == 3) || ([components day] % 7 == 4)) { 
       return [UIImage imageNamed:@"red"]; 
      } else { 
       //Weekday 
       if (([components hour] >= 7) && ([components hour] < 19)) { 
        return [UIImage imageNamed:@"green"]; 
       } else { 
        return [UIImage imageNamed:@"red"]; 
       } 
      } 
      break; 
     case GARNET: 
     case GOLD: 
     case HERITAGE: 
      if ((([components day] % 7 <= 3) || ([components day] % 7 >= 5)) && 
       (([components hour] >= 7) && ([components hour] <= 19))) { 
       return [UIImage imageNamed:@"green"]; 
      } else { 
       return [UIImage imageNamed:@"red"]; 
      } 
      break; 
     case NIGHT: 
      if ((([components day] % 7 == 6) || ([components day] % 7 <= 3)) && 
       (([components hour] >= 22.5) || ([components hour] <= 3))) { 
       return [UIImage imageNamed:@"green"]; 
      } else { 
       return [UIImage imageNamed:@"red"]; 
      } 
      break; 
     case OSCEOLA: 
     case RENEGADE: 
     case TOMAHAWK: 
      if ((([components day] % 7 <= 3) || ([components day] % 7 >= 5)) && 
       (([components hour] >= 7) && ([components hour] <= 19))) { 
       return [UIImage imageNamed:@"green"]; 
      } else { 
       return [UIImage imageNamed:@"red"]; 
      } 
      break; 
    } 
} 

@end 
+1

डुप्लिकेट प्रतीकों का अर्थ है कि आपके पास अपनी परियोजना में 'बिल्डर' नामक दो वर्ग हैं, या संकलन सूची है। – CodaFi

+1

मेरे पास Building.h, BuildingAnnotation.h, और BuildingViewController.m/h है।क्या संकलन सूची को साफ़ करने का कोई तरीका है और क्या एक्सकोड इसे पुन: उत्पन्न करता है? –

+1

अपनी संकलन सूची साफ़ करें, फिर जब आप सब कुछ वापस जोड़ने के लिए जाते हैं, तो ".m" शब्द (उद्धरण के बिना) की खोज करें, और प्रत्येक .m फ़ाइल को हाइलाइट करें। फिर जोड़ें पर क्लिक करें। – CodaFi

उत्तर

17

आपके अनुरोध के अनुसार:

निकालें संकलन स्रोतों से अपनी कक्षाओं के सभी, फिर + बटन पर क्लिक करें और शब्द 'मीटर' के लिए खोज। प्रत्येक वर्ग को हाइलाइट करें, फिर जोड़ें पर क्लिक करें। बनाएँ और फिर से चलाओ।

+0

मुझे :( – NightFury

+0

के लिए काम की जाँच iAnum आप @implementation कि लाइन सही नाम –

+2

मैं विशिष्ट फ़ाइल कि डुप्लिकेट प्रतीकों के बारे में शिकायत की गई थी करने के लिए संकलन स्रोतों में जाने में सक्षम। यह निकाला गया है और यह और उसे पुन: जोड़ा था है नहीं था काम किया। अनिवार्य रूप से पूरी बात पर बमबारी किए बिना इस जवाब के समान। – teradyl

1

सुनिश्चित नहीं हैं लेकिन वहाँ बातें यह हो सकता है कि के एक जोड़े हैं।

  1. मुझे लगता है कि न तो वर्ग Building.h आयात करने के लिए दिखाई दे रहा है तो मेरा पहला विचार है कि संकलक जहां इस वर्ग के लिए जानकारी प्राप्त करने में पता नहीं है। क्या आपको #import जोड़ने की ज़रूरत है?

  2. अगली बात यह थी कि मैं आम तौर पर एक दूसरे को आयात करने वाले दो वर्गों से बचने की कोशिश करता हूं। संकलन में उन्हें संकलित करने के क्रम में काम करने की कोशिश करने में समस्या हो सकती है। आपको के बजाय @class ... का उपयोग करने के लिए उनमें से एक को बदलने की आवश्यकता हो सकती है ताकि संकलक कक्षा को हल करने के लिए रनटाइम तक इसे छोड़ दे।

  3. अंत में आपने साफ किया है? कुछ बार जब बहुत कुछ refactoring, पुराने वर्ग परिभाषा निर्माण निर्देशिका में छोड़ दिया है और इस तरह की समस्याएं पैदा कर सकते हैं।

23

जांचें कि आपने .m फ़ाइल आयात नहीं की है, जहां यह .h फ़ाइल होनी चाहिए। रवींद्र!

+1

परफेक्ट जोड़ा, धन्यवाद। –

+0

अद्भुत! मैं पागल हो रहा था और कभी भी इस – IMFletcher

1

फ़ाइल हटाएं और "संदर्भ निकालें" चुनें। फ़ाइल को फिर से परियोजना में खींचें और यह ठीक होना चाहिए। यह मेरे लिए काम किया।

1

यह समस्या जो मेरे लिए पैदा कर रही थी वह यह था कि मैंने एक एम फ़ाइल डुप्लिकेट की थी, लेकिन इसका नाम बदलकर @ कार्यान्वयन नहीं किया गया था। सुनिश्चित करें कि आपके पास डुप्लिकेट @ कार्यान्वयन घोषणाएं नहीं हैं।

1

मेरी आईओएस परियोजना में एकाधिक * .a फ़ाइलों के साथ तीसरे पक्ष पुस्तकालय को आयात करते समय मुझे एक ही त्रुटि हुई। मेरे मामले में '-all_load' लिंकर ध्वज को हटाने से समस्या हल हो गई।

+0

के लिए पर्याप्त रूप से पर्याप्त नहीं देखा होता था यह मेरे अधिकांश डुप्लीकेट से छुटकारा पाता था। अभी भी 4 छोड़ दिया है। –

संबंधित मुद्दे