Xcode Crashes While I Am doing SwiftUI Tutorial

Dear Fellow Developers,

I am very new to the coding world and thanks to Apple it is very satisfying and easy to study and understand Swift. However while I am following to instructions letter by letter to not make any mistake I hit a problem. After the part where I have to create a new SwiftUI View as LandmarksRow I put the following codes as it shows on the website then preview crashes then stops and I can't do anything about it. It keeps crashing. I don't know if there is a problem with the code or my computer. I checked every other swift file and I am sure it is %100 percent what it writes in the instructions. I have latest versions of software and M1 Macbook Pro with 16GB ram if that helps.

import SwiftUI

struct LandmarkRow: View {

    var landmark: Landmark

    

    var body: some View {

        Text(landmark.name)

    }

}



struct LandmarkRow_Previews: PreviewProvider {

    static var previews: some View {

        LandmarkRow(landmark: landmarks[0])

    }

}
Answered by OOPer in 698406022

Have you checked all the parts of your code containing longtitude? That should be longitude, I think.

There is no error in this code.

But there may be elsewhere in your project.

In addition, Landmark tutorial is known to be bugged in some places (not in this part).

Do you get a crash message ? What is it exactly ?

Translated Report (Full Report Below)
-------------------------------------

Incident Identifier: 33EF7B90-7D7E-401D-83CD-5D760772006E
CrashReporter Key:   E20D029A-BFAC-7BCD-0D99-273D0391CF41
Hardware Model:      MacBookPro17,1
Process:             Landmarks [29830]
Path:                /Users/USER/Library/Developer/Xcode/UserData/Previews/Simulator Devices/5706467C-4054-4B7C-9F43-A5FB113D2AB7/data/Containers/Bundle/Application/0983BADC-EDD6-44D3-9157-9C6A8BFF2763/Landmarks.app/Landmarks
Identifier:          com.oguzhanege.Landmarks
Version:             1.0 (1)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd_sim [16764]
Coalition:           com.apple.CoreSimulator.SimDevice.5706467C-4054-4B7C-9F43-A5FB113D2AB7 [4282]
Responsible Process: SimulatorTrampoline [10175]

Date/Time:           2021-12-15 08:42:55.4787 +0300
Launch Time:         2021-12-15 08:42:55.1528 +0300
OS Version:          macOS 12.1 (21C52)
Release Type:        User
Report Version:      104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000018f2e9a10
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [29830]

Triggered by Thread:  0

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 DYLD_LIBRARY_PATH=/Users/oguzhanege/Library/Developer/Xcode/DerivedData/Landmarks-caiieqqaollelecvsgbqttgnqeim/Build/Intermediates.noindex/Previews/Landmarks/Products/Debug-iphonesimulator DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot//System/Library/PrivateFrameworks/PreviewsInjection.framework/PreviewsInjection DYLD_FRAMEWORK_PATH=/Users/oguzhanege/Library/Developer/Xcode/DerivedData/Landmarks-caiieqqaollelecvsgbqttgnqeim/Build/Intermediates.noindex/Previews/Landmarks/Products/Debug-iphonesimulator
CoreSimulator 776.4 - Device: iPhone 13 Pro (5706467C-4054-4B7C-9F43-A5FB113D2AB7) - Runtime: iOS 15.0 (19A339) - DeviceType: iPhone 13 Pro
Landmarks/ModelData.swift:29: Fatal error: Couldn't parse landmarkData.json as Array<Landmark>:
keyNotFound(CodingKeys(stringValue: "longtitude", intValue: nil), Swift.DecodingError.Context(codingPath: [_JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "coordinates", intValue: nil)], debugDescription: "No value associated with key CodingKeys(stringValue: \"longtitude\", intValue: nil) (\"longtitude\").", underlyingError: nil))
dyld4 config: DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/oguzhanege/Library/Developer/Xcode/DerivedData/Landmarks-caiieqqaollelecvsgbqttgnqeim/Build/Intermediates.noindex/Previews/Landmarks/Products/Debug-iphonesimulator DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot//System/Library/PrivateFrameworks/PreviewsInjection.framework/PreviewsInjection DYLD_FRAMEWORK_PATH=/Users/oguzhanege/Library/Developer/Xcode/DerivedData/Landmarks-caiieqqaollelecvsgbqttgnqeim/Build/Intermediates.noindex/Previews/Landmarks/Products/Debug-iphonesimulator


Kernel Triage:
VM - pmap_enter failed with resource shortage
VM - pmap_enter failed with resource shortage
VM - pmap_enter failed with resource shortage
VM - pmap_enter failed with resource shortage
VM - pmap_enter failed with resource shortage


Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libswiftCore.dylib            	       0x18f2e9a10 _assertionFailure(_:_:file:line:flags:) + 300
1   libswiftCore.dylib            	       0x18f2e9a10 _assertionFailure(_:_:file:line:flags:) + 300
2   Landmarks                     	       0x102ee0470 load<A>(_:) + 1900 (ModelData.swift:29)
3   Landmarks                     	       0x102edfcf0 one-time initialization function for landmarks + 96 (ModelData.swift:9)
4   libdispatch.dylib             	       0x18010a6c8 _dispatch_client_callout + 16
5   libdispatch.dylib             	       0x18010bda4 _dispatch_once_callout + 28
6   Landmarks                     	       0x102ee08bc landmarks.unsafeMutableAddressor + 72 (ModelData.swift:9)
7   LandmarkRow.2.preview-thunk.dylib	       0x1051173a0 static LandmarkRow_Previews.__preview__previews.getter + 76
8   Landmarks                     	       0x102edf54c protocol witness for static PreviewProvider.previews.getter in conformance LandmarkRow_Previews + 12
9   SwiftUI                       	       0x1b8fa6458 static PreviewProvider._previews.getter + 88
10  Landmarks                     	       0x102edf590 protocol witness for static _PreviewProvider._previews.getter in conformance LandmarkRow_Previews + 40
11  SwiftUI                       	       0x1b8fa6d08 static _PreviewProvider._allPreviews.getter + 32
12  PreviewsInjection             	       0x103366e24 0x103348000 + 126500
13  PreviewsInjection             	       0x10336184c 0x103348000 + 104524
14  PreviewsInjection             	       0x10335bab0 0x103348000 + 80560
15  PreviewsInjection             	       0x10335ac6c 0x103348000 + 76908
16  PreviewsInjection             	       0x10335acc8 0x103348000 + 77000
17  libdispatch.dylib             	       0x180108ed4 _dispatch_call_block_and_release + 24
18  libdispatch.dylib             	       0x18010a6c8 _dispatch_client_callout + 16
19  libdispatch.dylib             	       0x1801180d4 _dispatch_main_queue_callback_4CF + 992
20  CoreFoundation                	       0x18034fc34 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
21  CoreFoundation                	       0x18034a1a4 __CFRunLoopRun + 2448
22  CoreFoundation                	       0x180349308 CFRunLoopRunSpecific + 572
23  GraphicsServices              	       0x18bf025ec GSEventRunModal + 160
24  UIKitCore                     	       0x184d3b4e0 -[UIApplication _run] + 992
25  UIKitCore                     	       0x184d3ffc0 UIApplicationMain + 112
26  SwiftUI                       	       0x1b93bed98 closure #1 in KitRendererCommon(_:) + 160
27  SwiftUI                       	       0x1b93becf4 runApp<A>(_:) + 164
28  SwiftUI                       	       0x1b8e12fb0 static App.main() + 80
29  Landmarks                     	       0x102ed8a80 static LandmarksApp.$main() + 100 (LandmarksApp.swift:10)
30  Landmarks                     	       0x102ed8b24 main + 12
31  dyld_sim                      	       0x1031d5c04 start_sim + 20
32  dyld                          	       0x1031250f4 start + 520

(removed)

Accepted Answer

Have you checked all the parts of your code containing longtitude? That should be longitude, I think.

Xcode Crashes While I Am doing SwiftUI Tutorial
 
 
Q