Post

Replies

Boosts

Views

Activity

Reply to Problem decoding AttributedString containing emoji
So I was putting together a bug report when I realized the reason it was working in macOS was because I was using a web view and not the NSAttributedString. Here is a very simple example that shows the issue that you may be able to find out why it's not converting. It could be in the HTML attributing of the string... import SwiftUI struct ContentView: View { let html = "<html><head><meta name=\"viewport\" content=\"width=device-width\" /></head><body style=\"font-family: -apple-system;color: rgb(255,255,255);\"><p>Feature Answer 5</p><p><strong>This should be bold</strong></p><p><em>This should be italic</em></p><blockquote><p>Happy Christmas emoji should be supported! 🎅🎄🎁 😉</p></blockquote></body></html>" var attributedString: AttributedString { let data = Data(html.utf8) if let attributedString = try? NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil) { return AttributedString(attributedString) } else { return "Unable to pull NSAttributed string from data." } } var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") Text(attributedString) } .padding() } } #Preview { ContentView() }
Jun ’24
Reply to How do you include custom symbol resources in a package?
Okay, I think I figured it out. Change the .target to be this and it seems to work by calling the bundle version of Image initializers: .target( name: "TestLibrary", resources: [.process("Resources")] ), // test.svg was included as a symbolset Image("test", bundle: Bundle.module) Note that this code only works from within the module so the specific symbol needs to be exposed in Image form rather than as a string.
Apr ’24
Reply to [WindowHosting] UIScene property of UINSSceneViewController was accessed before it was set. What does this mean?
I'm getting the same error "UIScene property of UINSSceneViewController was accessed before it was set." 3 times in the console when I run the following targeting My Mac (Mac Catalyst). I do not get the error in the iPhone 15 Pro simulator or when running targeting My Mac (Designed for iPad) so I think it might be a bug. struct ContentView: View { @State var testIsPresented = false var body: some View { NavigationView { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundColor(.accentColor) } .toolbar { Menu("Test") { Button("Show Sheet") { testIsPresented = true } } .sheet(isPresented: $testIsPresented) { Button("Dismiss") { testIsPresented = false } } } } } }
Oct ’23