Search results for

swiftui

16,623 results found

Post

Replies

Boosts

Views

Activity

Reply to SwiftUI previews stopped working everywhere after using EnvironmentObject
Thanks for the reply! I think that may help that specific app, but SwiftUI previews now crash in every SwiftUI project I have, including projects without EnivronmentObject. I reinstalled Xcode 11, but the problem persists.The crash report contains this information:Application Specific Information: -[MTLSimBuffer initWithDevice:bufferRef:content:pointer:length:options:heap:deallocator:]:89: failed assertion `Invalid storageMode 1' CoreSimulator 675 - Device: iPhone 8 (E3A5C531-2BD9-4EEE-BC8B-9AFAB54AECF8) - Runtime: iOS 13.0 (17A5534d) - DeviceType: iPhone 8
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’19
Reply to Why has forEach been deprecated?
Not w/Swift. Wrong forums.You must meanSwiftUI - where it's not simply forEach, but apparently associated initializers, I think. See https://developer.apple.com/documentation/swiftui/foreach/3347365-initIf you can show your usage/code that prompted the deprecation warning, perhaps someone can flesh it out for you. Be sure to use the SwiftUI forum, tho, thanks. Might want to move this thread there.
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’19
Reply to SwiftUI previews stopped working everywhere after using EnvironmentObject
I deleted from the Devices and Simulators window, which modifies this directory.~/Library/Developer/CoreSimulator/DevicesThen I reinstalled an iPhone X simulator, but the crash logs still state iPhone 8. I also previously previewed with an iPhone SE, which I didn't have installed as a simulator. It seems like SwiftUI previews are different from the simulator.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’19
Text() with .lineLimit greater than 1 adding vertical spacing to the encapsulating view
I'm building an app using SwiftUI that is centered around a list of articles which are either a new standalone topic, or which have a hierarchical relationship with an ancestor which was originally one of those new standalone topics.The default view in the List{} structure shows just the titles of the articles, but when tapping on an entry which shows the threaded titles, they're all expanded, via the following logic:if showDetail { ForEach(self.articles, id: .self) { article in VStack { if article.id != self.articles[0].id { Text(article.title) .font(.caption) .lineLimit(3) } Text(article.summary) .lineLimit(20) } } } else { ForEach(self.articles, id: .self) { article in if article.id != self.articles[0].id { Text(• (article.title)) } } }And it works great! Except for one thing: when expanded, the encompassing view gets enough padding at the top and the bottom for several lines of text.. If I drop the article summary's .lineLimit to 1, the padding goes away, but at 3 and above the extra padding is v
0
0
725
Jul ’19
UIViewControllerRepresentable and CNContactPickerViewController
I've succesfully created a number of UIViewControllerRepresentable using various UIViewController, with one exception: CNContactPickerViewController. Everything I've tried has given me a blank white screen. Is this UIViewController special in some way that makes it currently incompatible?import SwiftUI import ContactsUI // Minimal version struct LookupContactViewController : UIViewControllerRepresentable { func makeUIViewController(context: Context) -> CNContactPickerViewController { let contactPickerVC = CNContactPickerViewController() contactPickerVC.delegate = context.coordinator return contactPickerVC } func makeCoordinator() -> Coordinator { return Coordinator() } func updateUIViewController(_ uiViewController: CNContactPickerViewController, context: Context) { } class Coordinator: NSObject { } } extension LookupContactViewController.Coordinator : CNContactPickerDelegate { func contactPickerDidCancel(_ picker: CNContactPickerViewController) { print(Cancelled!) } func contactPicker(_ picker
12
0
3.8k
Jul ’19
Cannot preview in this file - App may have crashed
Hi,I am working with SwiftUI, and am new to Xcode, and Swift at all.I did the SwiftUI essentials Tutorial, and done the Controls and Views part.Now I am stuck on my own creation app.I try to get data from an local .json file which I stored in the Resources folder.In the preview View, I pass in the data of index 0, but while rendering the preview it always crashes, and cannot build a preview.I almost copied all the files from the BuildingListsAndNavigations project.This is my View where I try to post from the json fileimport SwiftUI struct UserRow : View { var user: User var body: some View { Text(user.name) } } #if DEBUG struct UserRow_Previews : PreviewProvider { static var previews: some View { UserRow(user: userData[0]) } } #endifhere is the data.swift fileimport UIKit import SwiftUI import CoreLocation let userData: [User] = load(users.json) func load<T: Decodable>(_ filename: String, as type: T.Type = T.self) -> T { let data: Data guard let file = Bundle.main.
5
0
3.2k
Jul ’19
Tutorial "Working with UI Controls" EditButton already shows "Done"
In Section 4, step 1, we're instructed to add a button on the left to show Done while edit mode is active. However the EditButton control already changes its text between Edit and Done based on the mode. What that control lacks is a way to perform an action when the mode changes. I can follow the tutorial and add the extra button on the left, but that's not right for production code. What should be done in that situation?https://developer.apple.com/tutorials/swiftui/working-with-ui-controlsHStack { if self.mode?.value == .active { Button(action: { self.profile = self.draftProfile // This action line needs to execute when (either) Done is tapped self.mode?.animation().value = .inactive }) { Text(Done) } } Spacer() EditButton() // This already will toggle between Edit and Done labels }
1
0
829
Jul ’19
Reply to UIViewControllerRepresentable and CNContactPickerViewController
Not the controller I want, but it works fine with UIViewControllerRepresentable.import SwiftUI import EventKitUI struct EKEventEditVCR: UIViewControllerRepresentable { typealias UIViewControllerType = EKEventEditViewController func makeUIViewController(context: UIViewControllerRepresentableContext) -> EKEventEditVCR.UIViewControllerType { let controller = EKEventEditViewController() controller.delegate = context.coordinator return controller } func updateUIViewController(_ uiViewController: Self.UIViewControllerType, context: Self.Context) { } func makeCoordinator() -> EKEventEditVCR.Coordinator { return Coordinator() } class Coordinator : NSObject, UINavigationControllerDelegate { } } #if DEBUG struct EKEventEditVCR_Previews: PreviewProvider { static var previews: some View { EKEventEditVCR() } } #endif
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’19
Reply to Xcode 11 Beta 5 Plugin Failure
What makes you think the plugin is missing? It's in my Xcode package, for both Beta releases. The error I'm referring to is because the plugin code can't find a symbol in libswiftCore.dylib, which is in /usr/lib/swift. The plugin meta data does reference SwiftUI, mentioning VStack and com.apple.dt.previews.metadata.SwiftUI, so perhaps it will shake itself out when Catalina Beta 5 is released.
Jul ’19
Reply to Build is failing on, Xcode 11 beta 5, works fine on earlier beta's
I get the same (below) from XCode Beta 5:Does this affect the SwiftUI canvas for you?DetailsLoading a plug-in failed.Domain: DVTPlugInErrorDomainCode: 2Failure Reason: The plug-in “com.apple.dt.UVKit” at path “/Applications/Xcode-beta-5.app/Contents/PlugIns/UVKit.framework” could not be loaded. The plug-in or one of its prerequisite plug-ins may be missing or damaged.Recovery Suggestion: The plug-in or one of its prerequisite plug-ins may be missing or damaged and may need to be reinstalled.User Info: { DVTPlugInDYLDErrorMessageErrorKey = dlopen(/Applications/Xcode-beta-5.app/Contents/PlugIns/UVKit.framework/UVKit, 0): Symbol not found: _$s2IDs12IdentifiablePTln Referenced from: /Applications/Xcode-beta-5.app/Contents/PlugIns/UVKit.framework/UVKitn Expected in: /usr/lib/swift/libswiftCore.dylibn in /Applications/Xcode-beta-5.app/Contents/PlugIns/UVKit.framework/UVKit; DVTPlugInExecutablePathErrorKey = /Applications/Xcode-beta-5.app/Contents/PlugIns/UVKit.framework/UVKit; DVTPlugInIdentifierErrorKey =
Jul ’19