So I have an issue only with the simulator for iOS, I can interact with the map for about two seconds before the whole app crashes...
When I use my own device, it works fine...
here's a gif: https://gyazo.com/67a5d7f10586d0368eb631346122867b
Here is my implementation:
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>
</>
);
}
The error from the device:
Application Specific Information: dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot terminating with uncaught exception of type NSException *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]' abort() called CoreSimulator 783.5 - Device: iPhone 13 (D63AEBAD-44FF-4884-8F91-259CAEA4FC7F) - Runtime: iOS 15.2 (19C51) - DeviceType: 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
I finally found a solution for this, and it turns out that my simulator runs ios 15.2 crashed. When I downloaded another version below this version. In my case 13.5. It finally works :)