I'm currently developing a SwiftUI application that utilizes SwiftData for data management. I am facing a challenge when trying to filter a query. Specifically, I want to filter a list of Item objects to match a Product instance that is passed to my View.
error :
Instance member 'product' cannot be used on type 'MainItemListEncap'; did you mean to use a value of this type instead
The view
//
// 311.1.1. MainRefToItem.swift
// ComparePrice
//
// Created by Herman VAN CAUWELAERT on 11/12/2024.
//
import SwiftUI
import SwiftData
struct MainItemListEncap: View {
@Bindable var product: Product
@Query(
filter: #Predicate { item in
item.productGroup == product
},
sort: [SortDescriptor(\Item.name)]
)
var items: [Item]
@Environment(\.modelContext) var modelContext
var body: some View {
ForEach(items) { item in
VStack(alignment: .leading) {
Text(item.name)
Text(item.description)
}
}
}
}
the product class.
import SwiftData
import Foundation
@Model
final class Product: CustomStringConvertible, CustomDebugStringConvertible {
@Attribute(.unique) var productName: String
var productDescription: String
var outputCurrency: String
// Gebruik een `String` als opslag voor `outputSystem`
var outputSystemRawValue: String = MeasurementSystem.metric.rawValue
// Computed property om `MeasurementSystem` te gebruiken
var outputSystem: MeasurementSystem {
get {
MeasurementSystem(rawValue: outputSystemRawValue)
}
set {
outputSystemRawValue = newValue.rawValue
}
}
// er zijn verschillend item versies voor een product
// als er een hoofdproduct gedelete wordt, dan zullen alle onderliggende items ook gedelete worden
@Relationship(deleteRule: .cascade, inverse: \Item.productGroup) var refToItems = [Item]()
init(productName: String = "", productDescription: String = "what is this product", outputCurrency: String = "EUR", outputSystem: MeasurementSystem = MeasurementSystem.metric) {
self.productName = productName
self.productDescription = productDescription
self.outputCurrency = outputCurrency
self.outputSystem = outputSystem
}
}
the item class
import Foundation
import SwiftData
@Model
final class Item: CustomStringConvertible, CustomDebugStringConvertible {
var timestamp: Date
@Attribute(.unique) var name: String
var productGroup: Product?
var shop: String //TODO: becomes Shop
var price: Double
var currency: String
var quantity: Double
var unit: String //TODO: becomes Unit
var isShown : Bool
var minimumQuantity: String
var rateStr: String {
conversionRate != nil ? " (rate: \(ValueFormatter.shared.format(conversionRate!)))" : ""
}
init(timestamp: Date = Date()
, name: String
, shop: String = "Colruyt"
, price:Double = 1.00
, currency: String = "EUR"
, quantity: Double = 1.0
, unit: String = "g"
, isShown:Bool = true
, conversionRate: Decimal? = 1
, minimumQuantity: String = "1"
) {
self.timestamp = timestamp
self.name = name
self.shop = shop
self.price = price
self.currency = currency
self.quantity = quantity
self.unit = unit
self.isShown = isShown
self.conversionRate = conversionRate
self.minimumQuantity = minimumQuantity
}
}
Apple Developers
RSS for tagThis is a dedicated space for developers to connect, share ideas, collaborate, and ask questions. Introduce yourself, network with other developers, and foster a supportive community.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi everyone,
I’m a developer from Argentina, and I recently attempted to publish my app on Google Play under a US LLC. I submitted all the required documentation and followed the process step-by-step. After 40 days of back-and-forth communication and providing all the requested information, my application was ultimately rejected without a clear explanation.
I understand that having a US company and bank account is a requirement for developers like me to operate internationally, but this rejection has left me quite confused about what went wrong.
Has anyone else faced a similar situation? If so, how did you resolve it? Any advice or guidance would be greatly appreciated!
Thanks in advance!
Topic:
Community
SubTopic:
Apple Developers
“At this rate, I’m starting to get frustrated. I’ve registered for the developer program twice, but they’re still asking me for the registration fee, and my registration is not being approved. Moreover, I haven’t received any response to my emails, and since the information is limited in English, I can’t search for solutions. Could someone please take care of this issue now?”
When I run a mixed OC and SWFit project, systems running before iOS 18 will experience the following crashes
When I run a mixed OC and SWFit project, systems running before iOS 18 will experience the following crashes
I'm a developer that has only produced for a single company. Though my developer account shows me as the account holder, my "Enrolled as" status is "Organization," and the "Entity" field shows the name of that company. I want to build an app for a separate company/organization, but unsure how to proceed. My App Store Connect account shows the original company name beneath my name as the only option in the account ID selector menu, so when I begin the New App process it automatically assumes I'm doing it for that company. Can I change my "Enrolled as" status to something independent of any organization, do I need to create a completely separate account to do this, or how should I proceed?
Any help would be appreciated.
Thanks.
My iPad 7th generation updated to iOS 18.3 I’m getting the loading 5 bar symbol and No sound at all . Tried hard resetting multiple time and nothing works
Topic:
Community
SubTopic:
Apple Developers
/Library / Preferences / com.apple.networkd.plist If enable_unified_http is true, streaming video does not work. Does anyone know this? Why isn't anyone answering?
Topic:
Community
SubTopic:
Apple Developers
Hello,
We’re experiencing an issue in our app where a subset of users are being logged out automatically without any apparent reason. This is impacting both iOS 16 and iOS 17 users (though it’s hard to confirm if it’s platform-specific). Here’s a breakdown of the situation:
Symptoms
Some users report being logged out of the app randomly, even after remaining active.
The issue doesn’t seem to affect all users—just a specific subset.
Users are prompted to log in again, and once they do, the app behaves as expected until the issue recurs.
I have developed a mobile app using SwiftUI that supports GoogleMaps. Now I am in the process of building a CarPlay application. I assume CarPlay only supports Apple MapKit, as I could not find any way to integrate the Google Maps. Below are few queries,
Could you please guide me on how I can obtain the user's current location on the CarPlay app launch? Is there a way CarPlay can get the details from the mobile app(not pretty sure as its using Google Maps)?
If the user is logged out from the mobile app, what is the flow in CarPlay? Do we have any standard login page asking user to login to the mobile app first?
Is there any UI asking the user to capture the location in CarPlay?
This is my first CarPlay app. Kindly guide me to a document or so that covers these details.
Thanks a ton!!
Hi all,
The use of setVoiceProcessingEnabled increases the channel count of my microphone audio from 1 to 5. This has downstream effects, because when I use AVAudioConverter to convert between PCM buffer types the output buffer contains only silence.
Here is a reproduction showing the channel growth from 1 to 5:
let avAudioEngine: AVAudioEngine = AVAudioEngine()
let inputNode = avAudioEngine.inputNode
print(inputNode.inputFormat(forBus: 0))
// Prints <AVAudioFormat 0x600002f7ada0: 1 ch, 48000 Hz, Float32>
do {
try inputNode.setVoiceProcessingEnabled(true)
} catch {
print("Could not enable voice processing \(error)")
return
}
print(inputNode.inputFormat(forBus: 0))
// Prints <AVAudioFormat 0x600002f7b020: 5 ch, 44100 Hz, Float32, deinterleaved>
If it helps, the reason I'm using setVoiceProcessingEnabled because I don't want the mic to pick up output from the speakers. Per wwdc
When enabled, extra signal processing is applied on the incoming audio, and any audio that is coming from the device is taken
Here is my conversion logic from the input PCM format (which in the case above is 5ch, 44.1kHZ, Float 32, deinterleaved) to the target format PCM16 with a single channel:
let outputFormat = AVAudioFormat(
commonFormat: .pcmFormatInt16,
sampleRate: inputPCMFormat.sampleRate,
channels: 1,
interleaved: false
)
guard let converter = AVAudioConverter(
from: inputPCMFormat,
to: outputFormat) else {
fatalError("Demonstration")
}
let newLength = AVAudioFrameCount(outputFormat.sampleRate * 2.0) guard let outputBuffer = AVAudioPCMBuffer(
pcmFormat: outputFormat,
frameCapacity: newLength) else {
fatalError("Demonstration")
}
outputBuffer.frameLength = newLength
try! converter.convert(to: outputBuffer, from: inputBuffer)
// Use the PCM16 outputBuffer
The outputBuffer contains only silence. But if I comment out inputNode.setVoiceProcessingEnabled(true) in the first snippet, the outputBuffer then plays exactly how I would expect it to.
So I have two questions:
Why does setVoiceProcessingEnabled increase the channel count to 5?
How should I convert the resulting format to a single channel PCM16 format?
Thank you,
Lou
This wasn't happening until I updated Xcode to 16.2 (I'm using Sequoia 15.2). When I run any Mac app, I get these errors:
Can't find or decode reasons
Failed to get or decode unavailable reasons
Can't find or decode disabled use cases
I even got these errors running "Hello, world" which tells me that either I need to reinstall or there is a bug.
Thanks for any help,
-Ashley
Hi,
After updating to Xcode 16.2, I am getting an error running all iOS apps. I'm using Sequioa 15.2.
Error creating the CFMessagePort needed to communicate with PPT.
I ran the default Hello World app and got the same error message (plus another error not showing up on my apps - Failed to send CA Event for app launch measurements for ca_event_type: 1 event_name: com.apple.app_launch_measurement.ExtendedLaunchMetrics).
Can I ignore the error or is it truly affecting my app (all are testflight versions and it's fine if I don't update them for awhile, although not ideal).
Hopefully someone can help!
Thanks,
-Ashley
Like I said in the title, it looks like MetalTools.framework is missing or corrupted. I think I saw that the symbolic link was broken. They look like aliases in the finder, but I can't find the original.
This was a problem with Ventura (using the last compatible Xcode version) and Sequoia 15.2 (Xcode 16.2). I didn't use Xcode before that. Note that none of my apps need Metal API (I don't think). I only noticed it when Xcode gave an error regarding Metal.
Sorry this is so long; I hope the Terminal info will help.
I don't want to reinstall Sequoia and this has been a problem since at least Ventura.
Recommendations?
ls -l /System/Library/PrivateFrameworks/MetalTools.framework/
total 0
lrwxr-xr-x 1 root wheel 27 Dec 7 01:11 MetalTools -> Versions/Current/MetalTools
lrwxr-xr-x 1 root wheel 26 Dec 7 01:11 Resources -> Versions/Current/Resources
drwxr-xr-x 4 root wheel 128 Dec 7 01:11 Versions
ls -la /System/Library/PrivateFrameworks/MetalTools.framework/
total 0
drwxr-xr-x 5 root wheel 160 Dec 7 01:11 .
drwxr-xr-x 1885 root wheel 60320 Dec 7 01:11 ..
lrwxr-xr-x 1 root wheel 27 Dec 7 01:11 MetalTools -> Versions/Current/MetalTools
lrwxr-xr-x 1 root wheel 26 Dec 7 01:11 Resources -> Versions/Current/Resources
drwxr-xr-x 4 root wheel 128 Dec 7 01:11 Versions
codesign -v /System/Library/PrivateFrameworks/MetalTools.framework/MetalTools
/System/Library/PrivateFrameworks/MetalTools.framework/MetalTools: No such file or directory
ls -la /System/Library/PrivateFrameworks/MetalTools.framework/Versions/
total 0
drwxr-xr-x 4 root wheel 128 Dec 7 01:11 .
drwxr-xr-x 5 root wheel 160 Dec 7 01:11 ..
drwxr-xr-x 4 root wheel 128 Dec 7 01:11 A
lrwxr-xr-x 1 root wheel 1 Dec 7 01:11 Current -> A
ls -la /System/Library/PrivateFrameworks/MetalTools.framework/Versions/A/
total 0
drwxr-xr-x 4 root wheel 128 Dec 7 01:11 .
drwxr-xr-x 4 root wheel 128 Dec 7 01:11 ..
drwxr-xr-x 10 root wheel 320 Dec 7 01:11 Resources
drwxr-xr-x 3 root wheel 96 Dec 7 01:11 _CodeSignature
Note - -rwxr-xr-x 1 root wheel MetalTools should be in the above list (according to ChatGPT)
system_profiler SPDisplaysDataType
Intel UHD Graphics 630 and AMD Radeon Pro 5500M (includes:
Metal Support: Metal 3
Playground code => "Metal is supported." Default device: Apple iOS simulator GPU.
Thanks, Ashley
After Updating My iPhone 15 Pro To IOS 18.3 beta, 1 Day Later A Pixel seemed stuck or burnt,
and then after 1 Day on 25 Dec The Screen Went Black Or Turned Off But Responded To My Touch,
the reason i suppose the screen went black would be a memory glitch happening when i opened the camera from the Lock Screen or a graphica card issue
if anyone can help I would appreciate it
Topic:
Community
SubTopic:
Apple Developers
I bought Pioneer SPH-DA97DAB CarPlay radio but hardly can use the phone due to a loud echo that the caller hears during a call. how can I solve this does CarPlay has echo cancelation?
Hi all, if anyone from apple Dev team is seeing this, please do consider supporting device mirroring without the need to login to icloud and with cable connection in addition to wi-fi.
I am working in a corporate setting which does not allow us to login to icloud, thus I am unable to use device mirroring when my work really needs is, I am stuck with Quick time preview.
I am quite sure, that this does not only apply to me.
15.2 has a major problem with Thunderbolt devices. Dozens of reports on the discussion forum after people upgraded from prior versions. In my case 15.1 was working flawlessly. After upgrading to 15.2 the MAC PRO (2019) won't even boot with multiple Thunderbolt devices attached. If as suggested I disconnect all those devices the MAC boots but I no longer have my Thunderbolt drives available. Someone from Apple really needs to start listening to this. We have posted feedback after feedback and I keep getting told no one else has this problem. Well 4 pages of people on the discussion forum would disagree with that.
Topic:
Community
SubTopic:
Apple Developers
Hi !
I am trying to insert interstitial ads in my app with facebook ads.
I found app id, placement id and when I am running my app I have the following error :
Interstitial ad failed to load with error: Error Domain=com.facebook.ads.sdk Code=1001 "No fill" UserInfo={NSLocalizedDescription=No fill, FBAdErrorDetailKey={
msg = "No fill";
}}
Could you help me ?
After updating to IOS Beta 18.3 car play won't work on iPhone 16 Pro. My daughters does on my Range Rover so it is the BETA update. Can not remove beta update, please help.
Topic:
Community
SubTopic:
Apple Developers