React-Native-Mapbox-GL无法链接

时间:2017-01-30 15:23:59

标签: react-native linker cocoapods mapbox-gl react-native-ios

当逐步复制RCTMapboxGL (5.1.0) RCTMapboxGL时,我遇到了链接器的错误。每次我尝试使用Undefined symbols for architecture arm64: "_OBJC_CLASS_$_RCTMapboxAnnotation", referenced from: objc-class-ref in libRCTMapboxGL.a(RCTMapboxGL.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) 时都会发生这种情况。

我尝试了两个:

Xcode控制台:

Manual installation process for iOS

  • Duplicate definition

Xcode控制台:

RCTMapboxAnnotation

缺少的符号../node_modules/react-native-mapbox-gl/ios/RCTMapboxGL.xcodeproj位于import {provideRoutes} from "@angular/router"; ,已作为参考添加到我的项目中。

Installation process with CocoaPods

Xcode构建设置中的其他链接器标志

RCTMapboxAnnotation

1 个答案:

答案 0 :(得分:1)

我的解决方案是修复MapboxGL库中的所有React导入语句。

#import <React/MissingClass.h>形式将它们转换为全局导入解决了问题:

e.g。 #import RCTView.h#import <React/RCTView.h>

(共9个文件):

RCTMapboxAnnotation.m

#import "RCTMapboxAnnotation.h"
#import <React/RCTEventDispatcher.h>
#import <React/UIView+React.h>
#import <React/RCTBridge.h>
#import <React/RCTUtils.h>

RCTMapboxAnnotation.h

#import "RCTMapboxAnnotation.h"
#import <MapBox/MapBox.h>
#import <UIKit/UIKit.h>
#import <React/RCTConvert+MapKit.h>
#import <React/RCTComponent.h>
#import "RCTMapboxGL.h"

RCTMapboxAnnotationManager.m

#import "RCTMapboxAnnotationManager.h"
#import <React/RCTUIManager.h>
#import <React/RCTConvert+CoreLocation.h>
#import <React/UIView+React.h>
#import "RCTMapboxAnnotation.h"

RCTMapboxAnnotationManager.h

#import <React/RCTViewManager.h>

RCTMapboxGL.h

#import <Mapbox/Mapbox.h>
#import <React/RCTView.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTBridgeModule.h>

RCTMapboxGL.m

#import "RCTMapboxGL.h"
#import <React/RCTBridgeModule.h>
#import <React/RCTEventDispatcher.h>
#import <React/UIView+React.h>
#import <React/RCTLog.h>
#import "RCTMapboxGLConversions.h"
#import "RCTMapboxAnnotation.h"

RCTMapboxGLManager.h

#import <React/RCTViewManager.h>

RCTMapboxGLManager.m

#import "RCTMapboxGLManager.h"
#import "RCTMapboxGL.h"
#import <Mapbox/Mapbox.h>
#import <React/RCTConvert+CoreLocation.h>
#import <React/RCTConvert+MapKit.h>
#import <React/RCTBridge.h>
#import <React/RCTEventDispatcher.h>
#import <React/UIView+React.h>
#import <React/RCTUIManager.h>
#import "RCTMapboxGLConversions.h"
#import "MGLPolygon+RCTAdditions.h"
#import "MGLPolyline+RCTAdditions.h"

RCTMapboxGLConversions.m

#import <Foundation/Foundation.h>
#import <React/RCTConvert+CoreLocation.h>
#import <React/RCTConvert+MapKit.h>
#import "RCTMapboxGL.h"