Post

Replies

Boosts

Views

Activity

Reply to Coding help requested
Found your GitHub repo, unfortunately it did not contain the Xcode project file so couldn't get it up and running. I would change this: guard let url = Bundle.main.url(forResource: chimesSoundEffect, withExtension: "mp3") else { return } to this: guard let url = Bundle.main.url(forResource: chimesSoundEffect, withExtension: "mp3") else { print("No sound file found") return } To see if the file is actually found. Furthermore, I would change this: let chimesSoundEffect = "Chimes-sound-effect.mp3" to this: let chimesSoundEffect = "Chimes-sound-effect" Since you already have the withExtension in the Bundle.url call. Also I would check if you have included the mp3 file in the Target membership of the app: 1. First in Xcode, select the mp3 file in the left hand side where the project files are. 2. Check from the Inspector (View > Inspectors > File) and then see from the Target Membership section if there is a check in the checkbox for the app target. If not, the mp3 file is not included in the target binary and cannot be found.
Jun ’23
Reply to WeatherKit or SwiftUI date formatting issues
Get the time zone of the location and use that: import Foundation let sanFrancisco = TimeZone(identifier: "PST") let time = Date.now let timeFormatter = DateFormatter() timeFormatter.dateStyle = .none timeFormatter.timeStyle = .short timeFormatter.timeZone = sanFrancisco timeFormatter.locale = .current let timeStr = timeFormatter.string(from: time) print("\(timeStr)") // For me, prints 2.08, local time was 12.08. And, if starting from a coordinate, rather than a timezone identifier: import Foundation import CoreLocation let sanFrancisco = CLLocation(latitude: 37.77493, longitude: -122.41942) let geoCoder = CLGeocoder() do { let placemarks = try await geoCoder.reverseGeocodeLocation(sanFrancisco) if !placemarks.isEmpty { if let placemark = placemarks.first { let time = Date.now let timeFormatter = DateFormatter() timeFormatter.dateStyle = .none timeFormatter.timeStyle = .short timeFormatter.timeZone = placemark.timeZone timeFormatter.locale = .current let timeStr = timeFormatter.string(from: time) print("\(timeStr)") } else { print("No placemark for the coordinate") } } } catch { print("Failed to geolocate coordinate: \(error.localizedDescription)") }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’23
Reply to Coding help requested
You specify the sound to play: let chimesSoundEffect = "Chimes-sound-effect.mp3" But then use a different one when loading the sound file: guard let url = Bundle.main.url(forResource: "sound", withExtension: "mp3") else { return } Should you use the one you specify in the variable (without the extensions since you provide it as withExtension parameter): let chimesSoundEffect = "Chimes-sound-effect" ... guard let url = Bundle.main.url(forResource: chimesSoundEffect, withExtension: "mp3") else { return } Hard to say otherwise what could be the issue. If you'd like someone else to test and help out getting this to work, I'd say put this in GitHub as a public repository and let others contribute there. It would be lots of work for others to create an empty project to test out this code of yours there, including putting mp3 files in resources of the app. And if the issue is elsewhere in your project (like where the mp3 file is located), seeing this code only may not be enough to solve your issues.
Jun ’23
Reply to WARNING: Application performed a reentrant operation in its NSTableView delegate. This warning will become an assert in the future.
Having the same problem, anyone has anything new to help solve the issue? I have a NavigationSplitView with three columns and a .searchable()on the first column List view. Data to the views come from Core Data @FetchRequest. Whenever user removes a character from the search field or clears the search field, the same warning is displayed. When entering search text, warning does not appear. This does not happen always. For example when I enter a search text resulting in one row, and then remove one letter from search text. Then three rows are displayed and this warning does not appear. After removing another letter, resulting to five rows appearing, then this warning appears. Relevant parts of code below. struct ContentView: View { @Environment(\.managedObjectContext) var moc @FetchRequest (sortDescriptors: [SortDescriptor(\.subject)]) private var categories: FetchedResults<Category> @State private var selectedCategory : Category? = nil @State private var selectedTerm: Term? = nil @State private var searchText = "" var body: some View { NavigationSplitView { List(selection: $selectedCategory) { ForEach(categories, id: \.self) { category in CategoryRowView(category: category) .swipeActions(edge: .trailing) { Button(role: .destructive) { toDeleteCategory = category showDeleteCategoryConfirmation.toggle() } label: { Label("Delete", systemImage: "trash") } } } } .listStyle(.sidebar) .searchable(text: $searchText) ... } content: { if let category = selectedCategory { List(category.viewTerms(filter: searchText.isEmpty ? nil : searchText), id: \.self, selection: $selectedTerm) { term in and the implementation of category.viewTerms(filter: ) that does the filtering based on searchText (Category is a Core Data class): extension Category { ... func viewTerms(filter: String?) -> [Term] { var terms = viewTerms if filter != nil { terms = terms.filter( { $0.termSearchText.localizedCaseInsensitiveContains(filter!) } ) } return terms } var viewTerms: [Term] { let terms = categoryTerms?.allObjects as? [Term] ?? [] return terms.sorted(by: {$0.viewPrimaryName < $1.viewPrimaryName } ) } Where the Category.categoryTerms is a one-to-many Core Data relationship from Category entity to Term entity.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’23
Reply to Xcode X Switt X SQLite
Should this...: fmResultSet = ... ...be: let fmResultSet = ... ..instead? And apparently: while fmResultSet!.next() == true Is not the valid way since next() returns the next result object, not a boolean value true or false. So perhaps you need to replace that with: while fmResultSet!.next() != nil Later you use the isEmpty property, and that is either true or false but you compare that to nil instead.
Topic: Programming Languages SubTopic: Swift Tags:
May ’23
Reply to Newbie help pls
If he sent the code, those are just text files and you can view them with any text editor. Unless he used Interface Builder, in that case it would be a bit inconvenient to view the GUI files. If you wish to test the app, why doesn't the developer send you the app he build that runs on your environment?
May ’23
Reply to Outlook for Mac Disaster
If you complain about how Outlook works, you should go complain in Microsoft forums since they develop it. Not Apple. If you complain about Apple developed software from the user perspective, then you should go complaining to user support forums, not developer forums.
Topic: App & System Services SubTopic: General Tags:
May ’23
Reply to Coding help requested
Found your GitHub repo, unfortunately it did not contain the Xcode project file so couldn't get it up and running. I would change this: guard let url = Bundle.main.url(forResource: chimesSoundEffect, withExtension: "mp3") else { return } to this: guard let url = Bundle.main.url(forResource: chimesSoundEffect, withExtension: "mp3") else { print("No sound file found") return } To see if the file is actually found. Furthermore, I would change this: let chimesSoundEffect = "Chimes-sound-effect.mp3" to this: let chimesSoundEffect = "Chimes-sound-effect" Since you already have the withExtension in the Bundle.url call. Also I would check if you have included the mp3 file in the Target membership of the app: 1. First in Xcode, select the mp3 file in the left hand side where the project files are. 2. Check from the Inspector (View > Inspectors > File) and then see from the Target Membership section if there is a check in the checkbox for the app target. If not, the mp3 file is not included in the target binary and cannot be found.
Replies
Boosts
Views
Activity
Jun ’23
Reply to Cmake and ninja still referencing old SDK after upgrading to XCode command line tools 14.3.1
If using cmake, remove the cmake generated temporary files / directories. Then rerun the cmake command and then run the build command (either make or ninja).
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to WeatherKit or SwiftUI date formatting issues
Get the time zone of the location and use that: import Foundation let sanFrancisco = TimeZone(identifier: "PST") let time = Date.now let timeFormatter = DateFormatter() timeFormatter.dateStyle = .none timeFormatter.timeStyle = .short timeFormatter.timeZone = sanFrancisco timeFormatter.locale = .current let timeStr = timeFormatter.string(from: time) print("\(timeStr)") // For me, prints 2.08, local time was 12.08. And, if starting from a coordinate, rather than a timezone identifier: import Foundation import CoreLocation let sanFrancisco = CLLocation(latitude: 37.77493, longitude: -122.41942) let geoCoder = CLGeocoder() do { let placemarks = try await geoCoder.reverseGeocodeLocation(sanFrancisco) if !placemarks.isEmpty { if let placemark = placemarks.first { let time = Date.now let timeFormatter = DateFormatter() timeFormatter.dateStyle = .none timeFormatter.timeStyle = .short timeFormatter.timeZone = placemark.timeZone timeFormatter.locale = .current let timeStr = timeFormatter.string(from: time) print("\(timeStr)") } else { print("No placemark for the coordinate") } } } catch { print("Failed to geolocate coordinate: \(error.localizedDescription)") }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to Switch off using font ligatures for editors on MacOS. How?
Which editors? Some editors have a setting you can use switch ligatures on or off. Alternatively, use a font that does not have ligatures.
Replies
Boosts
Views
Activity
Jun ’23
Reply to Coding help requested
You specify the sound to play: let chimesSoundEffect = "Chimes-sound-effect.mp3" But then use a different one when loading the sound file: guard let url = Bundle.main.url(forResource: "sound", withExtension: "mp3") else { return } Should you use the one you specify in the variable (without the extensions since you provide it as withExtension parameter): let chimesSoundEffect = "Chimes-sound-effect" ... guard let url = Bundle.main.url(forResource: chimesSoundEffect, withExtension: "mp3") else { return } Hard to say otherwise what could be the issue. If you'd like someone else to test and help out getting this to work, I'd say put this in GitHub as a public repository and let others contribute there. It would be lots of work for others to create an empty project to test out this code of yours there, including putting mp3 files in resources of the app. And if the issue is elsewhere in your project (like where the mp3 file is located), seeing this code only may not be enough to solve your issues.
Replies
Boosts
Views
Activity
Jun ’23
Reply to SwiftData Configurations for Private and Public CloudKit
Maybe using several ModelConfiguration objects and specifying a CloudKit container identifier for those: https://developer.apple.com/documentation/swiftdata/modelconfiguration/init(_:schema:url:readonly:cloudkitcontaineridentifier:)
Replies
Boosts
Views
Activity
Jun ’23
Reply to UIDocumentBrowserViewController iOS16 additionalTrailingNavigationBarButtonItems are duplicated
The only time my app had duplicate toolbar buttons was when the toolbar extension was attached inside an element in a List. When I moved the toolbar up in the view hierarchy, that fixed it. But this is just guessing without seeing any code of yours, and my app is SwiftUI.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to iOS 17 System Storage Size
Beta versions include debugging, analytics and testing versions of code / data and logs. So I would expect them to be considerably larger than final released versions.
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to Adding a Widget extension to Multiplatform app targeting macOS iOS and iPadOS
OK, so what I can do is: Create two widget targets, one for iOS and one for macOS. In the app target General settings, scroll to Frameworks, Libraries and Embedded Content. Select, in the Filters section, for each of the extensions, on which platform they should be embedded to, one for each. That should do it.
Replies
Boosts
Views
Activity
Jun ’23
Reply to WARNING: Application performed a reentrant operation in its NSTableView delegate. This warning will become an assert in the future.
Having the same problem, anyone has anything new to help solve the issue? I have a NavigationSplitView with three columns and a .searchable()on the first column List view. Data to the views come from Core Data @FetchRequest. Whenever user removes a character from the search field or clears the search field, the same warning is displayed. When entering search text, warning does not appear. This does not happen always. For example when I enter a search text resulting in one row, and then remove one letter from search text. Then three rows are displayed and this warning does not appear. After removing another letter, resulting to five rows appearing, then this warning appears. Relevant parts of code below. struct ContentView: View { @Environment(\.managedObjectContext) var moc @FetchRequest (sortDescriptors: [SortDescriptor(\.subject)]) private var categories: FetchedResults<Category> @State private var selectedCategory : Category? = nil @State private var selectedTerm: Term? = nil @State private var searchText = "" var body: some View { NavigationSplitView { List(selection: $selectedCategory) { ForEach(categories, id: \.self) { category in CategoryRowView(category: category) .swipeActions(edge: .trailing) { Button(role: .destructive) { toDeleteCategory = category showDeleteCategoryConfirmation.toggle() } label: { Label("Delete", systemImage: "trash") } } } } .listStyle(.sidebar) .searchable(text: $searchText) ... } content: { if let category = selectedCategory { List(category.viewTerms(filter: searchText.isEmpty ? nil : searchText), id: \.self, selection: $selectedTerm) { term in and the implementation of category.viewTerms(filter: ) that does the filtering based on searchText (Category is a Core Data class): extension Category { ... func viewTerms(filter: String?) -> [Term] { var terms = viewTerms if filter != nil { terms = terms.filter( { $0.termSearchText.localizedCaseInsensitiveContains(filter!) } ) } return terms } var viewTerms: [Term] { let terms = categoryTerms?.allObjects as? [Term] ?? [] return terms.sorted(by: {$0.viewPrimaryName < $1.viewPrimaryName } ) } Where the Category.categoryTerms is a one-to-many Core Data relationship from Category entity to Term entity.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to Xcode X Switt X SQLite
Should this...: fmResultSet = ... ...be: let fmResultSet = ... ..instead? And apparently: while fmResultSet!.next() == true Is not the valid way since next() returns the next result object, not a boolean value true or false. So perhaps you need to replace that with: while fmResultSet!.next() != nil Later you use the isEmpty property, and that is either true or false but you compare that to nil instead.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’23
Reply to dyld[34280]: symbol not found in flat namespace (_cblas_caxpy)
Does this help? https://stackoverflow.com/questions/35006614/what-does-symbol-not-found-expected-in-flat-namespace-actually-mean
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
May ’23
Reply to Crash on fetching health kit data
Could you show two actual date values that cause the issue to appear?
Replies
Boosts
Views
Activity
May ’23
Reply to Newbie help pls
If he sent the code, those are just text files and you can view them with any text editor. Unless he used Interface Builder, in that case it would be a bit inconvenient to view the GUI files. If you wish to test the app, why doesn't the developer send you the app he build that runs on your environment?
Replies
Boosts
Views
Activity
May ’23
Reply to Outlook for Mac Disaster
If you complain about how Outlook works, you should go complain in Microsoft forums since they develop it. Not Apple. If you complain about Apple developed software from the user perspective, then you should go complaining to user support forums, not developer forums.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
May ’23