Skip to content

Commit f242c4d

Browse files
committed
Fix crashing on preview mode
1 parent 44eae77 commit f242c4d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

TweetNest/Shared/TweetNestApp.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ struct TweetNestApp: App {
6868
case .active, .inactive:
6969
Self.session.resumeBackgroundTaskTimers()
7070
#if canImport(CoreSpotlight)
71+
#if DEBUG
72+
if !Self.isPreview {
73+
Self.session.persistentContainer.usersSpotlightDelegate.startSpotlightIndexing()
74+
}
75+
#else
7176
Self.session.persistentContainer.usersSpotlightDelegate.startSpotlightIndexing()
7277
#endif
78+
#endif
7379
case .background:
7480
Self.session.pauseBackgroundTaskTimers()
7581
#if (canImport(BackgroundTasks) && !os(macOS)) || canImport(WatchKit)
@@ -78,8 +84,14 @@ struct TweetNestApp: App {
7884
}
7985
#endif
8086
#if canImport(CoreSpotlight)
87+
#if DEBUG
88+
if !Self.isPreview {
89+
Self.session.persistentContainer.usersSpotlightDelegate.stopSpotlightIndexing()
90+
}
91+
#else
8192
Self.session.persistentContainer.usersSpotlightDelegate.stopSpotlightIndexing()
8293
#endif
94+
#endif
8395
@unknown default:
8496
break
8597
}

0 commit comments

Comments
 (0)