Provide views, controls, and layout structures for declaring your app's user interface using SwiftUI.

SwiftUI Documentation

Posts under SwiftUI tag

2,348 Posts
Sort by:
Post not yet marked as solved
1 Replies
53 Views
SwiftUI in visionOS has a modifier called preferredSurroundingsEffect that takes a SurroundingsEffect. From what I can tell, there is only a single effect available: .systemDark. ImmersiveSpace(id: "MyView") { MyView() .preferredSurroundingsEffect(.systemDark) } I'd like to create another effect to tint the color of passthrough video if possible. Does anyone know how to create custom SurroundingsEffects?
Posted Last updated
.
Post not yet marked as solved
0 Replies
31 Views
So I have a simple view for my SwiftUI application below: import SwiftUI struct ContentView: View { var body: some View { List { ForEach(0..<4) { index in RowView(index: index) .accessibilityIdentifier("row") } } } } struct RowView: View { let index: Int var body: some View { HStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") Spacer() ButtonView(index: index) } .padding() } } struct ButtonView: View { let index: Int var body: some View { VStack { if index != 3 { Button(action: {}, label: { Text("Cancel") }) .accessibilityIdentifier("cancel_button") } Button(action: {}, label: { Text("Submit") }) .accessibilityIdentifier("submit_button") } } } My goal is to reference each cancel and submit button per row for a UI Test, which I have tried doing so here: let rowElements = app.tables.cells.matching(identifier: "row") for i in 0..<rowElements.count { let cancelButton = rowElements.element(boundBy: i).buttons["cancel_button"] let submitButton = rowElements.element(boundBy: i).buttons["submit_button"] XCTAssertTrue(cancelButton.exists, "Cancel button does not exist in row \(i)") XCTAssertTrue(submitButton.exists, "Submit button does not exist in row \(i)") } Even with the identifiers set like this my tests fail and say it cannot find the buttons labeled as they are with their specific identifiers or the rows. What is the correct way to reference elements if they are in a list or table for UI Testing? I'm specifically trying to use accessibility Identifiers to make my life easy.
Posted
by matson.
Last updated
.
Post not yet marked as solved
1 Replies
49 Views
Hi I reviewed this post: How to change navigation title color in swiftUI This seems to work fine if the intention is to apply the title color across an application. I would like to apply a different text title color selectively depending on the View being shown. And in some instances revert back to the color depending on the light and dark themes. Same result occurs using a viewmodifier or simply using onAppear and onDisappear with the title color is applied to all views. And if you do modify it in onDisappear, when you navigate back to another view which changes the color onAppear it has the same color as the previous view. The only way I've found this to work is using UIViewControllerRepresentable and handling the viewWillAppear and viewWillDisappear something like this: NavigationBarView( viewWillAppear: { nav in nav.navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.white] }, viewWillDisappear: { nav in nav.navigationBar.largeTitleTextAttributes = nil } ) Has anyone been successful in getting a different title text color to apply to different views using a modifier or onAppear and onDisappear? Appreciate any guidance.
Posted
by craigaps.
Last updated
.
Post not yet marked as solved
1 Replies
62 Views
I'm trying to figure out how to debug this issue. I have a fairly simple program that I built using the Hello World sample code as reference. Here is my code: import SwiftUI @main struct Core_USDZ_ViewerApp: App { var body: some Scene { // Main Menu scene // WindowGroup (id: "main-menu"){ CoreUsdzMenu() } // Scene that takes data as an input // for volumetric viewing // WindowGroup (for: URL.self) { $content in CoreUsdzVolume(url: content) } defaultValue: { URL(string: "https://developer.apple.com/augmented-reality/quick-look/models/pancakes/pancakes.usdz")! } .windowStyle(.volumetric) .defaultSize(width: 0.2, height: 0.3, depth: 0.3, in: .meters) // Full surround scene /* ImmersiveSpace { // put our immersive view here } */ } } In the simulator, this launches the main menu scene, but when installed on the Vision Pro using TestFlight it skips the main menu and goes straight to the second WindowGroup. Since the data isn't populated, it uses the defaultValue and just shows pancakes. I'm having trouble logging and debugging this issue, as I don't have access to the hardware myself. I have to push the code to TestFlight and wait for a coworker to test it. Does anyone have ideas of why this could be happening? Any help is appreciated. Logging and debugging tips especially. I'm used to just putting log messages in my code to debug, but maybe there are some breakpoint techniques I should be using here or something. Oh, also, here is my CoreUsdzMenu script: import SwiftUI import RealityKit import UniformTypeIdentifiers struct CoreUsdzMenu: View { @Environment(\.openWindow) private var openWindow @Environment(\.dismissWindow) private var dismissWindow @State var entity: Entity? = nil @State var showFilePicker: Bool = false init() { NSLog("In CoreUsdzMenu") } var body: some View { VStack{ Text("Core USDZ Viewer v1.1") .font(.title) .frame(width: 500.0, height: 100.0) /* usdz list HStack(spacing: 100.0) { Spacer() // Load the UsdzList view into the window! UsdzList() Spacer() }*/ /* button test for window Button { openWindow(value: usdzData[1].url) } label: { Text("open test window") }*/ // A view for displaying the loaded asset. /* RealityView( make: { content in // Add a placeholder entity to parent the entity to. // let placeholderEntity = Entity() placeholderEntity.name = "$__placeholder" if let loadedEntity = self.entity { placeholderEntity.addChild(loadedEntity) } content.add(placeholderEntity) }, update: { content in guard let placeholderEntity = content.entities.first(where: { $0.name == "$__placeholder" }) else { preconditionFailure("Unable to find placeholder entity") } // If there is a loaded entity, remove the old child, // and add the new one. // if let loadedEntity = self.entity { placeholderEntity.children.removeAll() placeholderEntity.addChild(loadedEntity) } } )*/ // A button that displays a file picker for loading a USDZ. // Button( action: { showFilePicker = true }, label: { Text("Load USDZ") } ) .padding() } // can import usdz and realityFile UTT types .fileImporter(isPresented: $showFilePicker, allowedContentTypes: [.usdz, .realityFile]) { result in // Get the URL of the USDZ picked by the user. // Guarded for errors. // guard let url = try? result.get() else { print("Unable to get URL") return } NSLog("In CoreUsdzMenu") // add new .usdz to our data list // for later!~ // use Observables n stuff //usdzData.addUsdz(url) // This task is just an asynchronous block of code. Not linked // to the RealityView explicitly; the update parameter of the // RealityView function responds when this task updates the entity. // Task { // As the app is sandboxed, permission needs to be // requested to access the file, as it's outside of // the sandbox. // if url.startAccessingSecurityScopedResource() { defer { url.stopAccessingSecurityScopedResource() } // Load the USDZ asynchronously. // On load, triggers RealityView's update. // //self.entity = try await Entity(contentsOf: url) // Try using the Volumetric Window to display the // content: // openWindow(value: url) } } } } } Thank you for reading!
Posted
by dganim8s.
Last updated
.
Post not yet marked as solved
0 Replies
36 Views
I know the short answer is, no, you cannot update an older version of your app… but it got me thinking…. could you make a new version of an app that supports older iOS versions and then quickly release another version of the app that supports iOS 16+ only? Wouldn‘t this effectively allow you to make a new version for for iOS 12 devices and still allow you to have iOS 16+ features that are needed for the current version? one of my apps needs features found in swiftUI (iOS 16+) but I’d like to update an old version that was not on swiftUI.
Posted
by Sinime.
Last updated
.
Post marked as solved
2 Replies
43 Views
I'm on my final steps 'polishing' my app before submitting to AppStore however there is something that bothers me. My Feedback section is somehow asking for the User's data in order to submit a Feedback. Do i need to include some sort of Privacy Policy for this? The app is working offline and is for educational purposes teaching users the basics of Swift in an interactive way. ... it doesn't require any sensitive information from the user apart from this form...Feedback is critical, any suggestion?
Posted
by OsmanM94.
Last updated
.
Post not yet marked as solved
3 Replies
2.1k Views
I have a SwiftUI menu Menu{ .... }, label : { Image(...).accessibility(identifier: "cardMenu") } I used to be able to bring up the menu (before upgrading to xcode 13 (ios15)) like this let app = XCUIApplication() app.launch() app.buttons["cardMenu"].tap() But now i am unable to see the identifier in app.buttons. Can't seem to find the identifier anymore. I've tried looking for the identifier in the other app fields and changing to use text instead of identifer. No luck. These tests used to work prior to the upgrade. Any help would be appreciated
Posted
by jsh22.
Last updated
.
Post not yet marked as solved
0 Replies
52 Views
I need to create a carousel component with the following requirements (sorted by relevance): Objectives Every image is 16:9 aspect ratio and resizes to fit the screen. Needs a zoom and pan functionality, possibly the same way as iOS Photos app. Needs to work both in landscape and portrait mode, with a smooth transition between orientations. When orientation changes, the image needs to be rotated to preserve the center of the image (like Photos app and hyperoslo/Lightbox) The component should only take the minimum necessary space. In most use cases, such component should have other subviews both above and below. Circularity. I would like the carousel to wrap around. What I tried: Using a TabView with .tabViewStyle(PageTabViewStyle()).indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .always)) modifiers. This didn't work: rotating the interface caused the view to get stuck between pages (it looks like it's a well known [bug]).(https://stackoverflow.com/questions/72435939/swiftui-tabview-is-not-working-properly-on-orientation-change). Implementing a single page (that is, an image view) using an UIScrollView and an UIViewRepresentable, then collecting them into an HStack. Unfortunately I need to use zoomScale and contentOffset properties of the UIScrollView outside of the UIViewRepresentable itself. The net result was that .init() was invoked for every image in the carousel at every rotation, causing severe stutters and an horrible rotation animation. Implementing the whole carousel using UIKit, and an UICollectionView, whose cells were an instance of UIScrollView. The problem is, the UIScrollView needs to recompute its constraints upon rotation but a cell is an instance of UIView, so it can't respond to rotations via viewWillTransition(to:CGSize, with: any UIViewControllerTransitionCoordinator). In the UICollectionView itself, you can only access the visible cells (one at a time is visible), and cells are cached, so even after rotating, some occasionally are presented on screen with the same appearance as before the rotation (some do, some don't, in the same UICollectionView). Also when rotating, it looks like the UIScrollView of the visible cell is being recreated, making it impossible to preserve the image center (I use this subclass of UIScrollView for this purpose). And the UICollectionView is taking the full window size, not just the bare minimum necessary space. Help: With all of this in mind, what options do I realistically have? If necessary I can raise the minimum iOS version to 16.0, even though I guess it doesn't make any significative difference since SwiftUI introduced MagnifyGesture only from iOS 17.0.
Posted Last updated
.
Post not yet marked as solved
0 Replies
33 Views
I was coding a sidebar on macOS and folded it with my mouse, but every time I run the app, I can't see the sidebar, so I can't use the sidebar. If you add a new image once, you can't see the same, but the third window also shows the sidebar well. I don't know why It's similar when you run it on another computer at all. Current code import CoreData struct ContentView: View { @Environment(\.managedObjectContext) private var viewContext @State private var isSidebarVisible: Bool = true var body: some View { NavigationView { if isSidebarVisible { Sidebar() } MemoListView().environment(\.managedObjectContext, viewContext) } .frame(minWidth: 700, minHeight: 400) .toolbar { ToolbarItem(placement: .navigation) { Button(action: toggleSidebar) { Image(systemName: "sidebar.leading") } } } } private func toggleSidebar() { withAnimation { isSidebarVisible.toggle() } } struct Sidebar: View { @Environment(\.managedObjectContext) private var viewContext var body: some View { List { NavigationLink(destination: EasyWebListView().environment(\.managedObjectContext, viewContext)) { Label("Web Links", systemImage: "link") } NavigationLink(destination: MemoListView().environment(\.managedObjectContext, viewContext)) { Label("Memos", systemImage: "note.text") } NavigationLink(destination: ThemeListView().environment(\.managedObjectContext, viewContext)) { Label("Themes", systemImage: "photo.on.rectangle.angled") } NavigationLink(destination: AccessView().environment(\.managedObjectContext, viewContext)) { Label("Access Records", systemImage: "clock.fill") } } .navigationTitle("My App") } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) } } And the code used when there was a problem before. import CoreData struct ContentView: View { @Environment(\.managedObjectContext) private var viewContext @State private var isSidebarVisible: Bool = true var body: some View { NavigationView { Sidebar().environment(\.managedObjectContext, viewContext) MemoListView().environment(\.managedObjectContext, viewContext) } .frame(minWidth: 700, minHeight: 400) .toolbar { ToolbarItem(placement: .navigation) { Button(action: { withAnimation { isSidebarVisible.toggle() } }) { Image(systemName: "sidebar.leading") } } } } struct Sidebar: View { @Environment(\.managedObjectContext) private var viewContext var body: some View { List { NavigationLink(destination: EasyWebListView().environment(\.managedObjectContext, viewContext)) { Label("Web Links", systemImage: "link") } NavigationLink(destination: MemoListView().environment(\.managedObjectContext, viewContext)) { Label("Memos", systemImage: "note.text") } NavigationLink(destination: ThemeListView().environment(\.managedObjectContext, viewContext)) { Label("Themes", systemImage: "photo.on.rectangle.angled") } NavigationLink(destination: AccessView().environment(\.managedObjectContext, viewContext)) { Label("Access Records", systemImage: "clock.fill") } } .listStyle(SidebarListStyle()) .navigationTitle("My App") } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) } }
Posted Last updated
.
Post not yet marked as solved
1 Replies
97 Views
Hi Folks, I would like it so that when I press the button on the HomeScreen, the TabView hides and the toolbar item appears in its place. Currently, the toolbar item stacks on top of the TabView. However, when I try to hide the TabView, with an if condition for example, the screens turn black. I think it's because of the screen calls in the TabView. Is there an option to achieve what I want? I'm new to SwiftUI, so I'm very glad for any Solutions or advices. struct NavBar: View { var body: some View { TabView { HomeScreen() .tabItem { Label( "Home", systemImage: "house" ) } ... } } } struct HomeScreen: View { @State private var showDeleteButton = false var body: some View { Button("Show/Dissmiss Delete Button", action: { showDeleteButton.toggle() }).toolbar { if showDeleteButton { ToolbarItem(placement: .bottomBar) { Button("Delete", action: {}) } } } } }
Posted Last updated
.
Post not yet marked as solved
1 Replies
75 Views
I have a simple main app architecture: struct ContentView: View { @State private var isSignedIn = false @AppStorage("onboardingCompleted") var onboardingCompleted: Bool = false var body: some View { Group { if onboardingCompleted && isSignedIn { MainView() } else { OnboardingView() } } .onAppear() { signIn() } } OnboardingView is a NavigationView. MainView is a TabView. I switch between these when the user finishes onboarding. However, as the user taps on the finish button in the last onboarding step, this gets written to the console: Trying to pop to a missing destination - SwiftUI/NavigationBridge_PhoneTV.swift:213 - please file a bug report. In production, this causes a crash. I looked around and it seems it is an issue when you embed TabView inside NavigationView or vice versa? But here it's not the case, they are standalone and I switch between them. Any thoughts?
Posted Last updated
.
Post not yet marked as solved
1 Replies
83 Views
I want to have a list of tasks and each task have a list of navigationLinks each NavigationLink has subtaskName as a label and subtaskDetails as destination and every List (tasks list and subtasks list) has .onDelete and .onMove behaviors But when I implement the code below the navigationLink act weird. navigationLink inside List inside List is not navigating when clicked and it is only triggered and navigates to SubtaskDetailView when clicking the outer List row. How can I fix this problem? import SwiftUI struct ContentView: View { @State private var tasks: [Task] = [ Task(name: "Task 1", subtasks: [ Subtask(name: "Subtask 1", details: "Details for Subtask 1"), Subtask(name: "Subtask 2", details: "Details for Subtask 2") ]), Task(name: "Task 2", subtasks: [ Subtask(name: "Subtask 1", details: "Details for Subtask 1"), Subtask(name: "Subtask 2", details: "Details for Subtask 2") ]), Task(name: "Task 3", subtasks: [ Subtask(name: "Subtask 1", details: "Details for Subtask 1"), Subtask(name: "Subtask 2", details: "Details for Subtask 2") ]) ] var body: some View { NavigationView { List { ForEach(tasks.indices, id: \.self) { index in TaskView(task: $tasks[index]) } .onDelete(perform: deleteTask) .onMove(perform: moveTask) } .navigationTitle("Tasks") .toolbar { EditButton() } } } private func deleteTask(at offsets: IndexSet) { tasks.remove(atOffsets: offsets) } private func moveTask(from source: IndexSet, to destination: Int) { tasks.move(fromOffsets: source, toOffset: destination) } } struct TaskView: View { @Binding var task: Task var body: some View { List { Text(task.name) .font(.headline) .padding(.bottom, 4) ForEach(task.subtasks.indices, id: \.self) { index in NavigationLink(destination: SubtaskDetailView(details: task.subtasks[index].details)) { Text(task.subtasks[index].name) } } .onDelete(perform: { indexSet in task.subtasks.remove(atOffsets: indexSet) }) .onMove(perform: { indices, newOffset in task.subtasks.move(fromOffsets: indices, toOffset: newOffset) }) } .frame(minHeight: CGFloat(task.subtasks.count) * 80) } } struct SubtaskDetailView: View { let details: String var body: some View { Text(details) .navigationTitle("Subtask Details") } } struct Task: Identifiable { let id = UUID() var name: String var subtasks: [Subtask] } struct Subtask: Identifiable { let id = UUID() var name: String var details: String } Thanks!
Posted Last updated
.
Post marked as solved
3 Replies
427 Views
Hello! I've been trying to create a custom USDZ viewer using the Vision Pro. Basically, I want to be able to load in a file and have a custom control system I can use to transform, playback animations, etc. I'm getting stuck right at the starting line however. As far as I can tell, the only way to access the file system through SwiftUI is to use the DocumentGroup struct to bring up the view. This requires implementing a file type through the FileDocument protocol. All of the resources I'm finding use text files as their example, so I'm unsure of how to implement USDZ files. Here is the FileDocument I've built so far: import SwiftUI import UniformTypeIdentifiers import RealityKit struct CoreUsdzFile: FileDocument { // we only support .usdz files static var readableContentTypes = [UTType.usdz] // make empty by default var content: ModelEntity = .init() // initializer to create new, empty usdz files init(initialContent: ModelEntity = .init()){ content = initialContent } // import or read file init(configuration: ReadConfiguration) throws { if let data = configuration.file.regularFileContents { // convert file content to ModelEntity? content = ModelEntity.init(mesh: data) } else { throw CocoaError(.fileReadCorruptFile) } } // save file wrapper func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper { let data = Data(content) return FileWrapper(regularFileWithContents: data) } } My errors are on conversion of the file data into a ModelEntity and the reverse. I'm not sure if ModelEntity is the correct typing here, but as far as I can tell .usdz files are imported as ModelEntities. Any help is much appreciated! Dylan
Posted
by dganim8s.
Last updated
.
Post not yet marked as solved
0 Replies
60 Views
My app is iOS 17 targeted and uses a card-based list view with Delete and Duplicate trailing and leading swipe actions. The Delete and Duplicate buttons display appropriately on iPad with rounded corners, height equal to card height and width expanding to fill the leading or trailing space created by the swipe action (with padding between the edge of the button and the edge of the card). See screenshot: However, on iPhone (a) the button heights extend from the top of the first card to the bottom of the last card in the scrolled list, (b) the width expands to completely fill the space without padding between the button and the cards, and (c) only the leading (or trailing) top and bottom corners are rounded (respectively). See screenshots: The swipe action modifiers are standard and applied on a CardView in the following view chain (NavigationSplitView -> ZStack -> Group -> ZStack -> List -> ForEach -> ZStack -> CardView | NavigationLink with empty view as workaround for a toolbar bug. Here are the swipe actions : .swipeActions(edge: .trailing, allowsFullSwipe: false) { Button(role: .destructive, action: { // Perform "Delete" action }) { Label("Delete", systemImage: "trash") } } .swipeActions(edge: .leading, allowsFullSwipe: false) { Button(action: { // Perform "Duplicate" action }) { Label("Duplicate", systemImage: "doc.on.doc") } } I’ve tried embedding the buttons within a Geometry reader to explicitly contain the height and width but this results in a compiler error and I suspect that the solution might be a lot simpler. Any thoughts on a fix or an explanation of why the buttons display properly on iPad device and simulator but not on iPhone device or simulator is appreciated. Thanks in advance!
Posted
by Donovan.
Last updated
.
Post not yet marked as solved
0 Replies
49 Views
Does anybody encounter the same problem when using Animation Hitches from the instruments? It's stuck everytime i finish recording in the meanwhile all other instruments works just fine. Here is a picture attached. I do have to use Force Quit.
Posted
by OsmanM94.
Last updated
.
Post not yet marked as solved
1 Replies
71 Views
Some users report random crashing when just navigating the app. The app is really simple, here is the structure (it's MVP so most of the screens are not done yet): @State private var isChatModalPresented = false @State private var selectedTab = 0 @State private var previousTab = 0 var body: some View { TabView(selection: $selectedTab) { Text("Dashboard") .tabItem { Label("Dashboard", systemImage: "house") } .tag(0) Text("Training") .tabItem { Label("Training", systemImage: "flame") } .tag(1) Text("") .tabItem { Label("Chat", systemImage: "bubble.left") } .tag(2) Text("Recovery") .tabItem { Label("Recovery", systemImage: "heart") } .tag(3) Text("Community") .tabItem { Label("Community", systemImage: "person.3") } .tag(4) } .onChange(of: selectedTab) { neco in if selectedTab == 2 { self.isChatModalPresented = true selectedTab = previousTab } else { previousTab = selectedTab } } .fullScreenCover(isPresented: $isChatModalPresented) { ChatView(isPresented: $isChatModalPresented) } } } It's supposed to be a standard tabview, except that when you tap on the middle item, it's supposed to present a view from the bottom using fullScreenCover. Is this code correct? I am supplying the crash log: Exception Subtype: KERN_PROTECTION_FAILURE at 0x0f00002a00000000 -> 0x0000002a00000000 (possible pointer authentication failure) Exception Codes: 0x0000000000000002, 0x0f00002a00000000 VM Region Info: 0x2a00000000 is in 0x1000000000-0x7000000000; bytes after start: 111669149696 bytes before end: 300647710719 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL commpage (reserved) fc0000000-1000000000 [ 1.0G] ---/--- SM=NUL ...(unallocated) ---> GPU Carveout (reserved) 1000000000-7000000000 [384.0G] ---/--- SM=NUL ...(unallocated) UNUSED SPACE AT END Termination Reason: SIGNAL 10 Bus error: 10 Terminating Process: exc handler [25839] Triggered by Thread: 0 Thread 0 name: Thread 0 Crashed: 0 libobjc.A.dylib 0x0000000184eb98a4 lookUpImpOrForward + 72 (objc-runtime-new.mm:7331) 1 libobjc.A.dylib 0x0000000184eb4cc4 _objc_msgSend_uncached + 68 2 UIKitCore 0x000000018f01f46c -[UIViewController dealloc] + 860 (UIViewController.m:3270) 3 UIKitCore 0x000000018f0e8a88 -[UINavigationController dealloc] + 296 (UINavigationController.m:871) 4 UIKitCore 0x000000018f4ce920 -[_UISplitViewControllerColumnContents .cxx_destruct] + 44 (UISplitViewControllerPanelImpl.m:438) 5 libobjc.A.dylib 0x0000000184eb5374 object_cxxDestructFromClass(objc_object*, objc_class*) + 116 (objc-class.mm:457) 6 libobjc.A.dylib 0x0000000184eb509c objc_destructInstance + 80 (objc-runtime-new.mm:9057) 7 libobjc.A.dylib 0x0000000184eb503c _objc_rootDealloc + 80 (NSObject.mm:2153) 8 CoreFoundation 0x000000018cb51f48 cow_cleanup + 164 (NSDictionaryM.m:141) 9 CoreFoundation 0x000000018cb51e54 -[__NSDictionaryM dealloc] + 148 (NSDictionaryM.m:407) ... 36 UIKitCore 0x000000018ef9eedc UIApplicationMain + 340 (UIApplication.m:5270) 37 SwiftUI 0x00000001919b0898 closure #1 in KitRendererCommon(_:) + 176 (UIKitApp.swift:51) 38 SwiftUI 0x00000001919b06dc runApp<A>(_:) + 152 (UIKitApp.swift:14) 39 SwiftUI 0x000000019162125c static App.main() + 128 (App.swift:114) 40 REDACTED 0x00000001044243f4 static REDACTED.$main() + 52 (REDACTER.swift:0) 41 REDACTED 0x00000001044243f4 main + 64 42 dyld 0x00000001af8e2dcc start + 2240 (dyldMain.cpp:1269) It seems that something is happening under the hood regarding deallocation inside underlying UIKit views so I suspect this main navigation is the culprit?
Posted Last updated
.
Post not yet marked as solved
1 Replies
138 Views
After updating our build server to Xcode 15.3, the frameworks (e.g. CCIeNewsNetworking) we build and release seems to reference SwiftUI. Our deployment target is iOS11. Customers have complained when running on iOS12: dyld: Library not loaded: /System/Library/Frameworks/SwiftUI.framework/SwiftUI Referenced from: /private/var/containers/Bundle/Application/81538A25-464A-46E0-BC4D-6E1C002C82F0/Test.app/Frameworks/CCIeNewsNetworking.framework/CCIeNewsNetworking Reason: image not found and I can see that "import SwiftUI" now appears in arm64-apple-ios.private.swiftinterface: diff CCIeNewsNetworking.xcframework-7.3*/ios-arm64/CCIeNewsNetworking.framework/Modules/CCIeNewsNetworking.swiftmodule/arm64-apple-ios.private.swiftinterface 2,4c2,3 &lt; // swift-compiler-version: Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100) &lt; // swift-module-flags: -target arm64-apple-ios11.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Onone -module-name CCIeNewsNetworking &lt; // swift-module-flags-ignorable: -enable-bare-slash-regex --- &gt; // swift-compiler-version: Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4) &gt; // swift-module-flags: -target arm64-apple-ios11.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Onone -enable-bare-slash-regex -module-name CCIeNewsNetworking 7a7 &gt; import DeveloperToolsSupport 9a10 &gt; import SwiftUI 12a14 &gt; import _SwiftConcurrencyShims 217c219 &lt; @objc public func removeOperation(issueIdentifer: Swift.String, fileName: Swift.String) --- &gt; @objc public func removeOperation(issueIdentifier: Swift.String, fileName: Swift.String) I don't recall having changed anything in the project settings, so where does "import SwiftUI" come from, and how can I avoid it ?
Posted Last updated
.
Post not yet marked as solved
1 Replies
106 Views
as the title said, I want to sample the current pixel in the layer and if the color is the same as one in the parameter, I need to find a way to return that position back to SwiftUI. Do you think that's possible? in Shader.Argument I didn't find a way to directly convert to a pointer.
Posted Last updated
.
Post marked as solved
2 Replies
104 Views
I have encountered an issue with nested view updates that I don't understand. Maybe someone can explain what is happening. In the code below the ContentView loads 2 views in succession. MyView1 followed by MyView2. MyView displays a button while MyView2 displays the value of its first argument. When the button is pressed MyView1 changes the value of its bound first argument. The ContentView is reloaded because of the change to its first argument. This results in MyView1 and MyView2 both being loaded again. Looked at from a procedural point of view this isn't what I was expecting. import SwiftUI @main struct MyApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { @State var mydata1:Int = 0 @State var mydata2:Int = 1 var body: some View { VStack { Text("Hello world \(mydata1)") MyView1(v1:$mydata1, v2:$mydata2) Text(" myData1 = \(mydata1) myData2 = \(mydata2) ") MyView2(v1:$mydata1, v2:$mydata2) Text("Bye bye \(mydata1)") } } } struct MyView1:View { @Binding var v1:Int @Binding var v2:Int var body: some View { Text("MyView1") if $v1.wrappedValue == 0 { Button(action: { $v1.wrappedValue = 10 }, label: { Text("OK") }) } } } struct MyView2:View { @Binding var v1:Int @Binding var v2:Int var body: some View { Text("MyView2") if $v1.wrappedValue == 0 { Text("v1 = \(v1) v2 = \(v2) ") } else { Text("???") } } }
Posted Last updated
.