【发布时间】:2022-03-08 04:20:00
【问题描述】:
所以我有一个问题只有适用于 iOS 的模拟器,我可以在整个应用程序崩溃之前与地图交互大约两秒钟...
当我使用自己的设备时,它可以正常工作...
这是一个 gif:https://gyazo.com/67a5d7f10586d0368eb631346122867b
这是我的实现:
import React, { useEffect } from "react";
import { StatusBar } from "react-native";
import MapboxGL from "@react-native-mapbox-gl/maps";
function MapScreen() {
const context = useEquipment();
// const { deployedEquipment } = context!;
const defaultCameraCoordinates = {
latitude: context?.location?.latitude ?? 0,
longitude: context?.location?.longitude ?? 0,
};
return (
<>
<StatusBar animated={true} backgroundColor="black" barStyle="dark-content" />
<MapboxGL.MapView style={styles.map}>
</MapboxGL.MapView>
</>
);
}
来自设备的错误:
应用特定信息: dyld4 配置:DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot 以 NSException 类型的未捕获异常终止 *** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“*** -[__NSPlaceholderArray initWithObjects:count:]:尝试从对象 [0] 插入 nil 对象” 中止()调用 CoreSimulator 783.5 - 设备:iPhone 13 (D63AEBAD-44FF-4884-8F91-259CAEA4FC7F) - 运行时:iOS 15.2 (19C51) - 设备类型:iPhone 13
Podfile:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
target 'DigiCatchRN' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => true
)
target 'DigiCatchRNTests' do
inherit! :complete
# Pods for testing
end
pre_install do |installer|
$RNMBGL.pre_install(installer) #mapbox
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!()
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
$RNMBGL.pre_install(installer) # mapbox
end
end
【问题讨论】:
标签: react-native dictionary mapbox mapbox-ios