【发布时间】:2016-06-12 16:59:31
【问题描述】:
我正在关注iOS MapView example。
我在 Project/ProjectFolder/RCTMapManager.m 中创建了一个新的 Objective-C .m 文件,并添加了以下代码:
// RCTMapManager.m
#import <MapKit/MapKit.h>
#import "RCTViewManager.h"
@interface RCTMapManager : RCTViewManager
@end
@implementation RCTMapManager
RCT_EXPORT_MODULE()
- (UIView *)view
{
return [[MKMapView alloc] init];
}
@end
然后我打开 atom 并在 components/MapView.js 中创建了一个 js 文件并添加了以下代码:
// MapView.js
import { requireNativeComponent } from 'react-native';
// requireNativeComponent automatically resolves this to "RCTMapManager"
module.exports = requireNativeComponent('RCTMap', null);
然后在 Xcode 中运行构建命令来重建我之前工作的项目,构建失败并显示错误消息:
然后我注释掉了 MapView.js 中的所有内容,并注释掉了 RCTMapManager.m 中的实现。
这将构建:
// RCTMapManager.m
#import <MapKit/MapKit.h>
#import "RCTViewManager.h"
@interface RCTMapManager : RCTViewManager
@end
但是一旦我添加了实现,它就会失败并显示“链接器命令失败,退出代码 1”:
// RCTMapManager.m
#import <MapKit/MapKit.h>
#import "RCTViewManager.h"
@interface RCTMapManager : RCTViewManager
@end
@implementation RCTMapManager
RCT_EXPORT_MODULE()
- (UIView *)view
{
return [[MKMapView alloc] init];
}
@end
我想知道为什么实施会导致失败,以及如何解决?
【问题讨论】:
标签: objective-c xcode react-native