Search results for

swiftui

16,584 results found

Post

Replies

Boosts

Views

Activity

SwiftUI On Device EXC_BAD_ACCESS Overflow
Hi All,Im getting what appears to be a Stack Overflow whenever compiling SwiftUI on device. It works just fine in simulator or in preview window. However when attempting to build on device it crashes with:EXC_BAD_ACCESS (code=1, address=0xfffffffffffff8c0)You can see the logs here:objc[17195]: Class _BackdropLayer is implemented in both /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/TimerSupport.framework/TimerSupport (0x13239b5e8) and /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/SwiftUI.framework/SwiftUI (0x106a8a468). One of the two will be used. Which one is undefined. objc[17195]: Class _NoAnimationDelegate is implemented in both /Applications/Xcode-beta.app/Contents/Developer/Platf
1
0
2.6k
Jun ’19
Reply to SwiftUI Preview on HDD
That's.... an interesting reply.Is the slowness and stalling we experience due to APFS problems that Apple won't spend any time testing or thinking about?If Apple could fix it, every scenario of Mac use would greatly benefit, SSD or mechanical based, regardless of the application.Can you see there's a problem with promoting this new SwiftUI development model that is only practical on >$5,000 hardware?Running Apple's internal development exclusivly on hot hardware hides a multitude of sins.Only a minority of us will have fully loaded iMac or Mac Pros available for development work.Also, external SSDs have been very troublesome for us so far with Catalina's split read-only drive layout.The CPU, memory load and disk I/O aren't showing abnormally high usage, but disk traffic just mysteriously blocks very often,and when you have to split MacOS, Xcode, and a user account because it wont all fit on one drive, development is impossibly painful.Again, is this an APFS issue that will never be looked at or f
Topic: App & System Services SubTopic: Core OS Tags:
Jul ’19
@State and @Binding error?
I've been trying to implement the example used in the WWDC session 226 - Data flow through SwiftUIand seem to be having a problem that doesn't correspond to the examples shown in the Video...I get the error:ContentView.swift:21:13: 'PlayButton.Type' is not convertible to '(Binding<Bool>) -> PlayButton'The funny thing is it worked at first but stopped working spontaneously..Any help solving this or even just confirmation it is (or isn't) a common problem is appreciated.Here's my ContentView.Swift :import SwiftUI struct ContentView : View { @State private var isPlaying: Bool = false var body: some View { VStack { Text(isPlaying ? Playing : Not Playing) PlayButton() Image(systemName: isPlaying ? pause.circle : play.circle) } } } #if DEBUG struct ContentView_Previews : PreviewProvider { static var previews: some View { ContentView() } } #endifand the (simplified) play button code:import SwiftUI struct PlayButton : View { @Binding var isPlaying: Bool var body: some View { Button(action:
1
0
3.7k
Jul ’19
Reply to @State and @Binding error?
Ok, so I was being dumb.You have to pass the @State variable (with a $ specifically to identofy the reference to the State variable) to the sub-view.Maybe the error messages could be a little less arcane? Or maybe I could be less dumb !This is working:import SwiftUI import Combine struct ContentView : View { @State private var isPlaying: Bool = false var body: some View { VStack { Text(isPlaying ? Playing : Not Playing) PlayButton(isPlaying: $isPlaying) Image(systemName: isPlaying ? pause.circle : play.circle) } } } #if DEBUG struct ContentView_Previews : PreviewProvider { static var previews: some View { ContentView() } } #endif
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’19
Problem Understanding Variables
I am having trouble wrapping my head around variables. I have read a ton of tutorials but it all seems a little big right now. I made the var myColor and that works just fine. Then when I add line 9 to change the myColor it fails to compile and of course the callout is not much help. I have tried using self.myColor and $myColor and neither seems to work. I think if I could grasp this it would open up a lot of my learning.import SwiftUI struct FigureThisOut : View { @State var myColor = Color.green var body: some View { myColor = Color.red Text(reloadCount2).color(myColor) } } #if DEBUG struct FigureThisOut_Previews : PreviewProvider { static var previews: some View { FigureThisOut() } } #endif
7
0
881
Jul ’19
Reply to Problem Understanding Variables
add a 'return' statement to line 10. 'some' indicates opaque return types, so the builder has no idea what you are trying to create when you add additional logic to the declaration of the 'body' variable. To avoid the error, you either have to tell it what you actually intend to return from the closure, or, isolate your logic to functions that exist outside of the body variable declaration (and sometimes both if the compiler can't infer what you want to return). import SwiftUI struct FigureThisOut : View { @State var myColor = Color.green var body: some View { myColor = Color.red return Text(reloadCount2).color(myColor) } } #if DEBUG struct FigureThisOut_Previews : PreviewProvider { static var previews: some View { FigureThisOut() } } #endif
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’19
MetalKit in SwiftUI
Hi,Are there any plans for integrating Metal/MetalKit with SwiftUI?Is that correct that current recommended way of the integration is to use UIViewControllerRepresentable like in the tutorial?Thank you!
18
0
16k
Jul ’19
Xcode 11 beta3 SwiftUI EXC_BAD_INSTRUCTION
I get this when traversing a NavigationLink (ex. NavigationButton) in the iOS simulator: Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)Steps to reproduce:1. List { ForEach { NavigationLink { Text(detail) } } } }2. Run in simulator3. Press on any element4. The table view cell becomes grey and EXC_BAD_INSTRUCTION is generated
4
0
2.9k
Jul ’19
List updates very slowly and blocks UI
I am building an app using SwiftUI that should display work orders I get from a web service. I have successfully got them from a web service using the following function:func getAllWorkOrders(completion: @escaping ([WorkOrder]) -> ()) { guard let url = URL(string: http://somedomain/api/workOrders) else { fatalError(URL is not correct) } let conn = URLSession(configuration: URLSessionConfiguration.ephemeral, delegate: self, delegateQueue: nil) conn.dataTask(with: url) { data, _, _ in let decoder = JSONDecoder() decoder.dateDecodingStrategy = .formatted(DateFormatter.iso8601Full) let workOrders = try! decoder.decode([WorkOrder].self, from: data!) DispatchQueue.main.async { completion(workOrders) } }.resume() }while my WorkOrder struct look like this:struct WorkOrder: Identifiable, Codable { var id: Int var ticket: Int? var date: Date var description: String var astue: Bool var state: WorkOrderState var jobs: [WorkOrderJob] var project: Project }I have also created a view model which looks like this:
8
0
4.9k
Jul ’19
Reading a Text File
I put the file in my project. If I don't comment out line 17 nothing compiles. I have tried a few different things but with no luck yet. Any pointers pardon the pun, would be great.import SwiftUI import Foundation // Determine the file name let filename = OOMA CC Temp.txt // Read the contents of the specified file let contents = try! String(contentsOfFile: filename) // Split the file into separate lines let lines = contents.split(separator:n) // Iterate over each line and print the line func printLine()->String { // var oneLine: String = Hello to all var myCounter: Int = 0 myCounter = lines.count myCounter += myCounter + 1 let str1 = String(myCounter) return str1 } struct CCdata : View { var body: some View { Text(printLine()) } }
1
0
8.4k
Jul ’19