I have a SwiftUI view that I'm trying to dismiss with a button.
Here's the dismiss code:
struct MyBackButton: View {
var backButton: Bool
var dismiss: DismissAction
var body: some View {
Button(
action: dismiss.callAsFunction
) {
HStack {
if backButton {
Image(systemName: "chevron.left")
.imageScale(.large)
Text("Write!")
} else {
Text(" ")
}
}.foregroundColor(Color("AccentColor"))
}
}
}
The containing view contains the environment declaration and the button code:
struct ProjectView: View {
@Environment(\.dismiss) private var dismiss
here's the body of the view containing the following modifier that creates the button
.configureView("Write!", publisher: publisher, dismiss: dismiss)`
When the button is pressed the dismiss action is invoked but nothing happens.
I've tried many variants of this code without success. Any help welcomed.
I am using Xcode 15.3 beta.
Post
Replies
Boosts
Views
Activity
Connect says I have to update agreements, tax and banking, but when I try and load the page the browser hangs and doesn't load the page. I am using Safari and Sonoma. This looks like a bug.
After installing beta 8 I'm suddenly getting the following:
ld: warning: building for 'macCatalyst', but linking in dylib (/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa.tbd) built for 'macOS'
Any help gratefully received.
I tried coding along with the WWDC23 'Dive Deeper into SwiftData' video but can't get the sample code to compile.
For example the Card class fails with lots of errors associated with @Model. The first of these is: Type 'Card' does not conform to protocol 'PersistentModel'
import SwiftUI
import SwiftData
@Model
final class Card {
var front: String
var back: String
var creationDate: Date
init(front: String, back: String, creationDate: Date = .now) {
self.front = front
self.back = back
self.creationDate = creationDate
}
}
On the other hand the following stand alone code (in it's own project) compiles without error. So I am confused and a little fed up with Apple publishing sample code that doesn't compile.
import SwiftData
@Model
final class Card {
var front: String
var back: String
var creationDate: Date
init(front: String, back: String, creationDate: Date = .now) {
self.front = front
self.back = back
self.creationDate = creationDate
}
}
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
}
}
#Preview {
ContentView()
}
I just installed Xcode beta 6 and tried compiling the SwiftData sample app. It fails with a couple of dozen compile errors. Clearly this must have worked for WWDC23 so what's gone wrong?
The following says type 'Card' does not conform to protocol 'PersistentModel'
@Model
final class Card: PersistentModel {
This seems pretty basic.
Any suggestions
I have just upgraded to Sonoma 14. When I launch Xcode 14.3.1 it says I need to update to the latest version and send me to the AppStore where the latest version is 14.3.1? I have beta Xcode 15 installed, but can upload apps compiled with it to the AppStore.
What's going on?
Something weird has happened to my machine. It says it is running Ventura. But I had upgraded to Monterey some time ago. If I go to Software update there is no Monterey option, just a later version of Ventura.
A Monterey disk icon appears on my desktop after startup (separate from Macintosh HD). If I open this it's empty. If I eject it it it says Preboot wasn't ejected, if I force that then it says Update wasn't ejected, then finally forcing that says VM wasn't ejected. That gets rid of it until the next restart.
Has anyone any idea what is going on.
For the last few months the battery on my MacBook has drained within 24 hours in sleep mode. I have Ventura 13 installed and suspect it's somehow the culprit. There are no apps left running. Any suggestions?
I have been trying to get an app accepted but the review team has rejected it 4 times now on the grounds that I have selected 'made for kids'. I have never dome this if they mean the checkbox in the age rating thread. I have even sent them a screen shot. They never reply to my requests for an explanation. The stupid thing is that this app in its Mac Catalyst form was accepted a week ago and is on sale. I have lodged an appeal. Has anyone else had to put up with this?
I'm suddenly getting this error when distributing an app that uploaded ok a couple of days ago. Nothing had changed. The associated message is: Profile doesn't include the selected signing certificate. I've checked the certificates and they are OK. I am using automatic signing. Any ideas?
So I installed the latest OS update from Settings not realising that it wasn’t a Monteray update, but Ventura beta. But then when I tried running XCode I get a message that it won’t work with Ventura. So I’m stuck because I was about to release an App, but can’t because the App Store won’t accept stuff built with beta software.
So thanks Apple. Of course it’s all my own fault for not reading the Release notes where it is buried in the detail.
I am trying to upload app previews for iPad having done so successfully for iPhone. No matter how hard I try the store rejects them claiming "Your app preview contains unsupported or corrupted Audio". I am using Mac OS Ventura. Has anyone else hit this issue?
I can't get my app's document icon to appear for my document extension. I have tried different ways of configuring it based on Apple's documentation and various solutions posted on the internet.
At first I tried adding the icon to the imported type identifier box where it says 'Add imported type identifier icons here' nothing happens when I select an icon (.png) stored in the project. I have checked the info.plist source and there is nothing there.
I have since tried editing the source directly. Here are the relevant pieces of my latest attempt. Can anyone tell me where I'm going wrong. Thanks.
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<string>writingshed.png</string>
<key>CFBundleTypeName</key>
<string>Writing Shed Data</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>wsd</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeDescription</key>
<string>Writing Shed Data</string>
<key>UTTypeIconFiles</key>
<array>
<string>writingshed.png</string>
</array>
<key>UTTypeIdentifier</key>
<string>WritingShedData</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>wsd</string>
</array>
</dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
</dict>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>UTTypeConformsTo</key>
<array/>
<key>UTTypeDescription</key>
<string>Writing Shed Data</string>
<key>UTTypeIconFiles</key>
<array>
<string>writingshed.png</string>
</array>
<key>UTTypeIdentifier</key>
<string>WritingShedData</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>wsd</string>
</array>
</dict>
</dict>
</array>
I have an NSAttributedString attribute in an entity marked as Transformable with the transformer set to NSSecureUnarchiveFromDataTransformerName.
I have a Transformer defined as:
class AttributedStringTransformer: NSSecureUnarchiveFromDataTransformer {
override class func allowsReverseTransformation() -> Bool {
return true
}
override class func transformedValueClass() -> AnyClass {
return NSAttributedString.self
}
override class var allowedTopLevelClasses: [AnyClass] {
return [NSAttributedString.self]
}
override func transformedValue(_ value: Any?) -> Any? {
guard let data = value as? Data else {
fatalError("Wrong data type: value must be a Data object; received \(type(of: value))")
}
return super.transformedValue(data)
}
override func reverseTransformedValue(_ value: Any?) -> Any? {
guard let string = value as? NSAttributedString else {
fatalError("Wrong data type: value must be a Reminder object; received \(type(of: value))")
}
return super.reverseTransformedValue(string)
}
}
extension AttributedStringTransformer {
/// The name of the transformer. This is the name used to register the transformer using `ValueTransformer.setValueTrandformer(_"forName:)`.
static let name = NSValueTransformerName(rawValue: String(describing: AttributedStringTransformer.self))
/// Registers the value transformer with `ValueTransformer`.
public static func register() {
let transformer = AttributedStringTransformer()
ValueTransformer.setValueTransformer(transformer, forName: name)
}
}
The transformer is registered on launch.
When I launch the app with the string initialised to an empty attributed string the app fails right away with:
CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x6000005679c0> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null)
2021-08-12 08:53:30.390456+0100 Easiwriter[5985:108985] [error] error: -executeRequest: encountered exception = <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo = (null)
CoreData: error: -executeRequest: encountered exception = <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo = (null)
2021-08-12 08:53:30.391637+0100 Easiwriter[5985:108985] [error] error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x600000550a80> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null)
CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x600000550a80> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null)
2021-08-12 08:53:30.458505+0100 Easiwriter[5985:108985] [error] error: -executeRequest: encountered exception = <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo = (null)
CoreData: error: -executeRequest: encountered exception = <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo = (null)
2021-08-12 08:53:30.459614+0100 Easiwriter[5985:108985] [error] error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x600000550a80> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null)
CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x600000550a80> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null)
2021-08-12 08:53:30.459835+0100 Easiwriter[5985:108985] [error] error: -executeRequest: encountered exception = <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo = (null)
CoreData: error: -executeRequest: encountered exception = <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo = (null)
2021-08-12 08:53:30.471535+0100 Easiwriter[5985:108985] [error] error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x60000056d8c0> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null)
CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x60000056d8c0> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null)
I have put break points on the transformer, but it never hits them.
The behaviour of the app gives me the feeling that this is a bug in CoreData, but I can't pin it down.
Can someone please suggest what might be wrong. I am using Xcode 13.0 beta 5 (it failed on beta 4 as well).
Is there a way of adding a border to a SwiftUI Menu. By this I mean the menu that appears when its button is tapped, not the button itself. I've tried using .menuStyle, but this only seems to affect the button.