Skip to content

Instantly share code, notes, and snippets.

@scspijker
Created December 8, 2018 13:32
Show Gist options
  • Save scspijker/7863cad56cd0c6e86cf553464956427b to your computer and use it in GitHub Desktop.
Save scspijker/7863cad56cd0c6e86cf553464956427b to your computer and use it in GitHub Desktop.
enum VoiceControlStates: String {
case loading = "loading"
case listening = "listening"
case recognized = "recognized"
}
let vct = CPVoiceControlTemplate(voiceControlStates: [
CPVoiceControlState(identifier: VoiceControlStates.loading.rawValue, titleVariants: ["loading"], image: nil, repeats: true),
CPVoiceControlState(identifier: VoiceControlStates.listening.rawValue, titleVariants: ["listening"], image: nil, repeats: true),
CPVoiceControlState(identifier: VoiceControlStates.recognized.rawValue, titleVariants: ["recognized"], image: nil, repeats: true)
])
CPBaseController.sharedInstance.interfaceController?.pushTemplate(vct, animated: true)
Crash:
0 CoreFoundation 0x1e873bef8 __exceptionPreprocess + 228
1 libobjc.A.dylib 0x1e7909a40 objc_exception_throw + 55
2 CoreFoundation 0x1e8640ac4 +[NSException raise:format:] + 115
3 CarPlay 0x2125a7944 CPAssertAllowedClasses + 159
4 CarPlay 0x2125a79c4 -[CPInterfaceController pushTemplate:animated:] + 83
5 Flitsmeister 0x100bfe700 closure #1 in static FMCPMapTemplate.installMapButtons(template:) + 8349440 (FMCPMapTemplate.swift:53)
6 Flitsmeister 0x100c005dc thunk for @escaping @callee_guaranteed (@guaranteed CPMapButton) -> () + 8357340 (:0)
7 CarPlay 0x2125a57fc -[CPMapButton handlePrimaryAction] + 91
8 CarPlay 0x2125b5b8c __50-[CPMapTemplate handleActionForControlIdentifier:]_block_invoke + 687
9 libdispatch.dylib 0x1e81736c8 _dispatch_call_block_and_release + 23
10 libdispatch.dylib 0x1e8174484 _dispatch_client_callout + 15
11 libdispatch.dylib 0x1e81209ec _dispatch_main_queue_callback_4CF$VARIANT$mp + 1067
12 CoreFoundation 0x1e86ca1bc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 11
13 CoreFoundation 0x1e86c5084 __CFRunLoopRun + 1963
14 CoreFoundation 0x1e86c45b8 CFRunLoopRunSpecific + 435
15 GraphicsServices 0x1ea938584 GSEventRunModal + 99
16 UIKitCore 0x215540bc8 UIApplicationMain + 211
17 Flitsmeister 0x100424418 main + 115736 (main.m:36)
18 libdyld.dylib 0x1e8184b94 start + 3
@anonymcek
Copy link

Just one minor issue there that took me some time to figure out as Apple's documentation was lousy at that time. CPVoiceControlTemplate is modal so you need to use ...interfaceController.presentTemplate(vct, animted: true) instead of push...

@scspijker
Copy link
Author

Thanks a bunch, that was it, we we're looking ages for it! xD

@SjoerdPerfors
Copy link

Works !
Thanks a lot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment