Post

Replies

Boosts

Views

Activity

Strange Bug
I have a swiftUI app after I decided to add a document type After I opened the infos tab I clicked on "documents" and Xcode crashed. I've filed a bug (FB10465644). Any way so I added the imported & exported document and now its won't work. I ran the executive in my app and it gave me this: .....frovasvohxblobefzbrrwtvqtyuu/Build/Intermediates.noindex/Previews/UtilityScript/Products/Debug/UtilityScript.app/Contents/MacOS/UtilityScript ; exit; SwiftUI/AppWindowsController.swift:1103: Fatal error [1]    30982 illegal hardware instruction   Saving session...completed. [Process completed] in Xcode: SwiftUI/AppWindowsController.swift:1103: Fatal error 2022-06-26 13:26:19.042228+0800 UtilityScript[31108:471855] SwiftUI/AppWindowsController.swift:1103: Fatal error (lldb)  HELP I'VE NEVER THIS BEFORE I JUST WANT TO KNOW IF It"S MY BUG OR SWIFTUI'S AND I JUST WANT MY APP DONE🫠 info.plist: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>BuildMachineOSBuild</key> <string>22A5286j</string> <key>CFBundleDevelopmentRegion</key> <string>en</string> <key>CFBundleDocumentTypes</key> <array> <dict/> </array> <key>CFBundleExecutable</key> <string>UtilityScript</string> <key>CFBundleIdentifier</key> <string>-----</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>UtilityScript</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleSupportedPlatforms</key> <array> <string>MacOSX</string> </array> <key>CFBundleVersion</key> <string>1</string> <key>DTCompiler</key> <string>com.apple.compilers.llvm.clang.1_0</string> <key>DTPlatformBuild</key> <string>14A5228q</string> <key>DTPlatformName</key> <string>macosx</string> <key>DTPlatformVersion</key> <string>13.0</string> <key>DTSDKBuild</key> <string>22A5266o</string> <key>DTSDKName</key> <string>macosx13.0</string> <key>DTXcode</key> <string>1400</string> <key>DTXcodeBuild</key> <string>14A5228q</string> <key>LSMinimumSystemVersion</key> <string>13.0</string> <key>NSHumanReadableCopyright</key> <string>-----</string> <key>UTExportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.plain-text</string> </array> <key>UTTypeIcons</key> <dict/> <key>UTTypeIdentifier</key> <string>-----</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>.utlscript</string> </array> </dict> </dict> </array> <key>UTImportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.plain-text</string> </array> <key>UTTypeIcons</key> <dict> <key>UTTypeIconText</key> <string>utilityscript</string> </dict> <key>UTTypeIdentifier</key> <string>-----</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>.utlscript</string> </array> </dict> </dict> </array> </dict> </plist>
2
1
612
Jun ’22
Pass on Binding
I have this: struct TableRow: View { @Binding var data: TodoItem var body: some View { ... } } and this: List {     ForEach(data) { datum in         TableRow(data: ???) // <- what goes here?             .swipeActions {                 Button(role: .destructive) {                     data.delete(datum)                 } label: {                     Label("Delete", systemImage: "trash")                 }           }     } }
1
0
342
Jun ’22
No idea
I have a structure TodoItem struct TodoItem: Codable, Hashable, Identifiable {     var id: UUID = UUID()     var item: String     var done: Bool = false } And I have an array of them, and I’d like to find out a way to calculate(in a array) how many are done; that is, myArray.count / itemsDone .count is easy, itemsDone can be achieved like this: extension Array where Element == TodoItem {     var itemsDone: Double {         var done: Double = 0         for i in self {             if i.done { done += 1 }         }         return done     } } but it didn’t. struct ContentView: View { @State var todos: [TodoItem] … ProgressView(value: todos.itemsDone / todos.count) // Error My Playground won’t let me copy the error(no idea why) and my family’s iPad is in Chinese so one is Chinese. I’ll try it on Xcode and see if I can find out more. will update with the error. EDiT nor will this work: ProgressView(value: todos.itemsDone, total: todos.count)
5
0
556
Jun ’22
@AppStorage
I have a structure TodoItem struct TodoItem: Codable, Hashable, Identifiable {     var id: UUID = UUID()     var item: String     var done: Bool = false } How can I use AppStorage on [TodoItem]?
1
0
1.1k
Jun ’22
Export SwiftUI View
I know this is a strange and easy question. but JUST CANT FIND ANY REFERENCE aaaaaaaa I'm using SwiftUI and wants to export to PDF (best I can find Creating PDFs on MacOS without UIKit) export to image export to HTML export to everything possible etc BONUS print the page I can only find UIKit support and they are all outdated. AND IF POSSIBLE how to integrate ShareLink to share these(PDF, Image, HTML, etc) and write them onto disk using NSSavePane? even better how to do this on a of the platforms (I know I'm greedy😂) Thanks for any help🙏
0
0
750
Jun ’22
WeatherKit and SwiftUI
I'm trying out weather kit and I'm using swiftUI I have a view that accepts a CurrentWeather type value in initailizer I cannot find a way to initialize a CurrentWeather How can I preview It? This won't work: // forecaster and forecast is defined by me struct WeatherView_Previews: PreviewProvider {     static var previews: some View { // <- static WeatherView(weather: await forecaster.forcast(latitude: 0, longtitude: 0)) // <- concurrency     } }
1
0
882
Jun ’22
Weird UI layout in SwiftUI .swipeActions
OK after I'm done with my last issue I came across some weird UI layout this is really a serious issue because afterward it looks like this😂 why? I've never met this kind of issue before in my same code before upgrading to Ventura code: List { ...                 Section {                     ForEach(data) { datum in                         TableRow(data: datum)                             .swipeActions {                             Button(role: .destructive) {                                 data.delete(datum)                             } label: {                                 Label("Delete", systemImage: "trash")                             }                         }                     }                 } ... }
1
0
487
Jun ’22
Why isn't my "Add button" not working?
I'm trying out Swift Charts and I'm pretty messed up After I deleted all of my items, I couldn't add items anymore import SwiftUI extension Array where Element == ChartsData {     mutating func delete(_ item: ChartsData) {         self.removeAll {             $0 == item         }     } } struct ContentView: View {     var ofType: ChartsType     @State var data: [ChartsData] = []     var body: some View {         List {             VStack {                 HStack {                     Spacer() // MARK - add button                     Button {                         data.append(ChartsData(item: "item"))                     } label: {                         Image(systemName: "plus").imageScale(.large)                     }.buttonStyle(.plain).padding()                 }                                  List {                     ForEach(data) { datum in                         TableRow(data: datum).swipeActions {                             Button(role: .destructive) {                                 data.delete(datum)                             } label: {                                 Label("Delete", systemImage: "trash")                             }                         }                     }                 }                 NavigationLink{                     ChartsView(ofType: .BarChart, data: data)                 } label: {                     Text("Generate").font(.largeTitle).foregroundStyle(.linearGradient(colors: [.orange, .yellow, .blue, .purple], startPoint: .topTrailing, endPoint: .bottomLeading))                 }.padding()             }         }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView(ofType: .BarChart, data: [             ChartsData(item: "testItem1", value: 10),             ChartsData(item: "testItem2", value: 20)         ])     } }
1
0
514
Jun ’22
Virtualization
I know how to use Virtualization now But I don't know how to write interface in AppKit So I should find a way to embed a NSView(the VM's UI) in a SwiftUI View However I couldn't find any reference on how except NSViewRepresentable which, of course, will not work I know there must be a easy way to do this But I'm just can't find it... any help is appreciated
1
0
788
Jun ’22
Really easy question
I know this is really easy I want to get the absolute path for the current app And I can achieve using String(reflecting: Bundle.main.bundleURL) But what outputs isn't like /User/***/..... but file:///User/xx/... so what can I do to get a absolute path in /***/***/*** format? thanks
1
0
273
Jun ’22