未声明的标识符的使用“AIRGoogleMapOverlay”在AIRGoogleMapOverlayManager甚至#进口后“AIRGoogleMapOverlay.h”

问题描述 投票:0回答:2

我得到Use of undeclared identifier 'AIRGoogleMapOverlay'错误,当我试图运行我通过Xcode的反应本地项目。其实我试图打开我的iPhone应用程序,当我遇到这个错误,多数民众赞成。如果我只是说反应本地运行IOS,它建立并启动模拟器上的应用程序。我想提取我不能使用模拟器做当前设备的位置。

其中存在于反应天然-谷歌-地图包AirGoogleMapOverlay Manager.m文件时发生的错误。

AIRGoogleMapOverlay.h

#ifdef HAVE_GOOGLE_MAPS

#import <Foundation/Foundation.h>
#import <GoogleMaps/GoogleMaps.h>
#import <React/RCTBridge.h>
#import "AIRMapCoordinate.h"
#import "AIRGoogleMap.h"

@interface AIRGoogleMapOverlay : UIView

@property (nonatomic, strong) GMSGroundOverlay *overlay;
@property (nonatomic, copy) NSString *imageSrc;
@property (nonatomic, strong, readonly) UIImage *overlayImage;
@property (nonatomic, copy) NSArray *boundsRect;
@property (nonatomic, readonly) GMSCoordinateBounds *overlayBounds;

@property (nonatomic, weak) RCTBridge *bridge;

@end

#endif

AIRGoogleMapOverlay.m

#ifdef HAVE_GOOGLE_MAPS

#import "AIRGoogleMapOverlay.h"

#import <React/RCTEventDispatcher.h>
#import <React/RCTImageLoader.h>
#import <React/RCTUtils.h>
#import <React/UIView+React.h>

@interface AIRGoogleMapOverlay()
  @property (nonatomic, strong, readwrite) UIImage *overlayImage;
  @property (nonatomic, readwrite) GMSCoordinateBounds *overlayBounds;
@end

@implementation AIRGoogleMapOverlay {
  RCTImageLoaderCancellationBlock _reloadImageCancellationBlock;
  CLLocationCoordinate2D _southWest;
  CLLocationCoordinate2D _northEast;
}

- (instancetype)init
{
  if ((self = [super init])) {
    _overlay = [[GMSGroundOverlay alloc] init];
  }
  return self;
}

- (void)setImageSrc:(NSString *)imageSrc
{
  NSLog(@">>> SET IMAGESRC: %@", imageSrc);
  _imageSrc = imageSrc;

  if (_reloadImageCancellationBlock) {
    _reloadImageCancellationBlock();
    _reloadImageCancellationBlock = nil;
  }

  __weak typeof(self) weakSelf = self;
  _reloadImageCancellationBlock = [_bridge.imageLoader loadImageWithURLRequest:[RCTConvert NSURLRequest:_imageSrc]
                                                                          size:weakSelf.bounds.size
                                                                         scale:RCTScreenScale()
                                                                       clipped:YES
                                                                    resizeMode:RCTResizeModeCenter
                                                                 progressBlock:nil
                                                              partialLoadBlock:nil
                                                               completionBlock:^(NSError *error, UIImage *image) {
                                                                 if (error) {
                                                                   NSLog(@"%@", error);
                                                                 }
                                                                 dispatch_async(dispatch_get_main_queue(), ^{
                                                                   NSLog(@">>> IMAGE: %@", image);
                                                                   weakSelf.overlayImage = image;
                                                                   weakSelf.overlay.icon = image;
                                                                 });
                                                               }];

}

- (void)setBoundsRect:(NSArray *)boundsRect
{
  _boundsRect = boundsRect;

  _southWest = CLLocationCoordinate2DMake([boundsRect[1][0] doubleValue], [boundsRect[0][1] doubleValue]);
  _northEast = CLLocationCoordinate2DMake([boundsRect[0][0] doubleValue], [boundsRect[1][1] doubleValue]);

  _overlayBounds = [[GMSCoordinateBounds alloc] initWithCoordinate:_southWest
                                                        coordinate:_northEast];

  _overlay.bounds = _overlayBounds;
}

@end

#endif

而这里是我的错误,在AIRGoogleMapOverlayManager

#import "AIRGoogleMapOverlayManager.h"
#import "AIRGoogleMapOverlay.h"

@interface AIRGoogleMapOverlayManager()

@end

@implementation AIRGoogleMapOverlayManager

- (UIView *)view
{
  AIRGoogleMapOverlay *overlay = [AIRGoogleMapOverlay new]; ERROR-Use of  undeclared identifier 'AIRGoogleMApOverlay'
  overlay.bridge = self.bridge; ERROR-Use of  undeclared identifier 'overlay'
  return overlay; ERROR-Use of  undeclared identifier 'overlay'
  return 0;
}

RCT_EXPORT_MODULE()

RCT_REMAP_VIEW_PROPERTY(bounds, boundsRect, NSArray)
RCT_REMAP_VIEW_PROPERTY(image, imageSrc, NSString)

@end

我知道,解决第一个将摆脱所有3个错误。另外我正在xcworkspace,不xcodeproj。

任何帮助表示赞赏!

ios xcode google-maps react-native undeclared-identifier
2个回答
2
投票

我加HAVE_GOOGLE_MAPS=1到预处理宏,所有AIRGoogleMapOverlay相关的错误都不见了。

这需要同时添加到调试和万一有人发布是想知道他们为什么试图创建一个脱机捆绑收到此错误。


0
投票

您可能需要一个桥接报。

在项目中创建一个文件,命名为例如AIRGoogleMapOverlay桥接,Header.h

并把

#import "AIRGoogleMapOverlay.h"

在里面。

最后,在您的构建设置中添加了头文件类似下面,这取决于你需要它来设置环境。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.