Post

Replies

Boosts

Views

Activity

Announce my apps' Notifications in CarPlay
My app uses UNMutableNotificationContent() to play a custom sound, and has a phrase as a message. I just got a vehicle with CarPlay. When my iPhone is connected to CarPlay, when the notification goes off at a time, it shows on the iPhone, but does not make any noise whatsoever. What I'd like to happen, is for CarPlay to announce the message when the notification goes off, like it does with Apple's messages app. As my phone is set right now, when I have my airPods in, it will announce the notification from my app. But not for CarPlay. What do I need to add to my app to allow CarPlay to announce the message that comes in from a notification (again, local, not a push notification).
0
0
450
Aug ’23
Problems after App Transfer
I have just created a new business developer account, and I have transferred all of my apps to it. That was easy. The app id's are all in my new account. If I create a new Xcode project, I can install it on the actual device with no issues. My problem is when I try to update one of my apps that i've downloaded from the App store. I get the message "Unable to install 'appName'". I've been googling for 24 hours, trying to look into this. I found a post that stated that this isn't an issue for users when I finally get around to sending an update to the AppStore. I have made a provisional profile for the app, and after temporarily shutting off "Automatic Code Signing" I installed it. That didn't work either. No errors, just the "Unable to install" message.(I've switched back to "Automatic Code Signing" since that wasn't the problem.) So how do I update my app using the new developer account?
3
1
843
Nov ’22
Recording AVSpeechSynthesizer
I'm trying to record a phrase using AVSpeechSynthesizer.write. It appears to save "something", but when I try to play that back, nothing is played. Not sure where I'm going wrong (wrong file type, not actually saving a file, I don't have the play portion set correctly). Any help would be greatly appreciated. The "speakPhrase" function is just to prove that the AVSpeech is set up properly. That works just fine. import AVFoundation import Foundation class Coordinator {     let synthesizer: AVSpeechSynthesizer     var player: AVAudioPlayer?     init() {         let synthesizer = AVSpeechSynthesizer()         self.synthesizer = synthesizer     }     var recordingPath:  URL {         let soundName = "Finally.caf"         // I've tried numerous file extensions.  .caf was in an answer somewhere else.  I would think it would be         // .pcm, but that doesn't work either.         // Local Directory         let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)         return paths[0].appendingPathComponent(soundName)     }     func speakPhrase(phrase: String) {         let utterance = AVSpeechUtterance(string: phrase)         utterance.voice = AVSpeechSynthesisVoice(language: "en")         synthesizer.speak(utterance)     }     func playFile() {         print("Trying to play the file")         do {             try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default)             try AVAudioSession.sharedInstance().setActive(true)                          player = try AVAudioPlayer(contentsOf: recordingPath, fileTypeHint: AVFileType.caf.rawValue)             guard let player = player else {return}                 player.play()         } catch {             print("Error playing file.")         }     }     func saveAVSpeechUtteranceToFile() {         let utterance = AVSpeechUtterance(string: "This is speech to record")         utterance.voice = AVSpeechSynthesisVoice(language: "en-US")         utterance.rate = 0.50         synthesizer.write(utterance) { [self] (buffer: AVAudioBuffer) in             guard let pcmBuffer = buffer as? AVAudioPCMBuffer else {                 fatalError("unknown buffer type: \(buffer)")             }             if pcmBuffer.frameLength == 0 {                 // Done             } else {                 // append buffer to file                 do {                     let audioFile = try AVAudioFile(forWriting: recordingPath, settings: pcmBuffer.format.settings, commonFormat: .pcmFormatInt16, interleaved: false)                     try audioFile.write(from: pcmBuffer)                 } catch {                     print(error.localizedDescription)                 }             }         }     } }
0
0
942
Sep ’22
SwiftUI and Xcode 12 - Keyboard Notification
let nofiticationCenter = NotificationCenter.default notificationCenter.addObserver(self, selector: #selector(keyBoardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil) Doesn't appear to work with Xcode 12 beta 1. Has something replaced UIResponder for keyboard notifications?
1
0
686
Jun ’20
Background Color of Navigation View with List View
Now that we are on the GM of Xcode, I'm still not getting something basic with background color. Below is just a test app. The goal is to make the entire background green, and the "cells" red. When you click on a cell, it goes to a sample detail, and the entire background is the correct green color. I've found workarounds that will allow the Navigation view to be green, but when I add the List, it goes back to white. I was just going to get rid of List and call it good, but then the edit button doesn't work (Edit button not shown in this example).Is there a way to make this background green on the ContentView?struct ContentView: View { var body: some View { NavigationView { List { ForEach(1...3, id: \.self) { index in NavigationLink( destination: DetailView()) { ContentCell() } .frame(height: 100) } } .navigationBarTitle("My List") }.background(Color.green)// Not working } } struct ContentCell: View { var body: some View { GeometryReader { geometry in VStack { Text("An item to display.") } .frame(width: (geometry.size.width), height: geometry.size.height, alignment: .center) .background(Color.red)// Working } } } struct DetailView: View { var body: some View { VStack { Text ("At the detail view") } .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) .background(Color.green)// Working .edgesIgnoringSafeArea(.all) } }
3
0
1.0.0k
Sep ’19
SwiftUI Editing the information in the Detail of a Master/Detail
Working on a sample app. The goal is to have a list pulled up from CoreData in a MasterView, and then click on one to go to a DetailView where you can edit the information and save. When you edit the "name" in the DetailView, it not only updates the DetailView to reflect the change, but it also reflects the change on the MasterView as well. I've tried numerous ways to accomplish this, but so far have not come up with an answer.// Code generation is turned OFF in the xcdatamodeld file public class EntityName: NSManagedObject, Identifiable { @NSManaged public var name: String @NSManaged public var active: Bool } extension EntityName { static func allEntityNameFetchRequest() -> NSFetchRequest<EntityName> { let request: NSFetchRequest<EntityName> = EntityName.fetchRequest() as! NSFetchRequest<EntityName> request.sortDescriptors = [NSSortDescriptor(key: "name", ascending: true)] return request } } struct MasterView: View { @Environment(\.managedObjectContext) var managedObjectContext @FetchRequest(fetchRequest: EntityName.allEntityNameFetchRequest()) var allEntityNames: FetchedResults<EntityName> var body: some View { NavigationView { List { ForEach(self.allEntityNames) { entityName in NavigationLink(destination: DetailView(entityName: entityName)) { VStack(alignment: .leading) { Text(entityName.name) .font(.headline) Text(String(entityName.active)) .font(.subheadline) } } } } } .onAppear() { // Just want to populate the Core Data to have a few to work with if self.allEntityNames.count == 0 { for _ in 1...3 { let newEntry = EntityName(context: self.managedObjectContext) newEntry.name = "New Entry" try! self.managedObjectContext.save() } } } } } struct DetailView: View { var entityName = EntityName() @State private var name = "" @State private var booley = false var body: some View { VStack { Text("Name: \(entityName.name)") Text("Active: \(String(entityName.active))") // What I'd like to do now: //TextField("", text: $entityName.name) //Toggle(isOn: $entityName.active) } } }
1
0
3.6k
Aug ’19