This is possible now via Menu - https://developer.apple.com/documentation/swiftui/menu (iOS 14+)
Menus are covered in this WWDC video - https://developer.apple.com/videos/play/wwdc2020/10052/ at ~11:15.
Playground Example:
import SwiftUI
import PlaygroundSupport
		
		struct ContentView: View {
				
				var body: some View {
						HStack {
								// Other views
								Text("Example View 1")
		
								// Button, that when tapped shows 3 options
								Menu {
										Button(action: {
												
										}) {
												Label("Add", systemImage: "plus.circle")
										}
										Button(action: {
												
										}) {
												Label("Delete", systemImage: "minus.circle")
										}
										Button(action: {
												
										}) {
												Label("Edit", systemImage: "pencil.circle")
										}
								} label: {
										Image(systemName: "ellipsis.circle")
								}
						}
						.frame(width: 300, height: 300, alignment: .center)
				}
		}
		
		PlaygroundPage.current.setLiveView(ContentView())
Post
Replies
Boosts
Views
Activity
On Xcode 12.1, SwiftUI Previewer crashes when it references another swift package it depends on and that swift package uses Bundle.module.
Basic code snippet that crashes:
		import SwiftUI
		import Theme // Import package that uses Bundle.module
		/// This view will crash the previewer
		struct ThisViewCrashesPreview: View {
				var body: some View {
						Text("Hello, World!")
								// If you comment out the following line, the previewer will render
								.foregroundColor(Color.themeGreenFromXCAssets)
								// Or use this line, the preview will also start to work
								.foregroundColor(Color.colorThatDoesNotUseModuleReference)
				}
		}
		struct ThisViewCrashesPreview_Previews: PreviewProvider {
				static var previews: some View {
						ThisViewCrashesPreview()
				}
		}
Code from Theme package:
		import SwiftUI
		public extension Color {
				
				static let themeGreenFromXCAssets = Color("ThemeGreen", bundle: .module)
				
				static let colorThatDoesNotUseModuleReference = Color.init(red: 0.3, green: 0.6, blue: 0.9)
				
		}
Crash Log States:
Application Specific Information: Fatal error: unable to find bundle named ThemeTheme: file Theme/resourcebundle_accessor.swift, line 27 Same issue reported here: https://stackoverflow.com/questions/64540082/xcode-12-swiftui-preview-doesnt-work-on-swift-package-when-have-another-swift/64664692#64664692
To reproduce:
Download code at: https://github.com/ryanholden8?tab=repositories See repo SwiftUI-Preview-Failing-Test-Project
Open PreviewFailingTestProject.xcodeproj
Change Target at the top of the Xcode window from PreviewFailingTestProject to MyUICode
Change deployment device to iPhone 12 mini (or any iOS device)
Open file: LocalPackages > MyUICode > Sources > MyUICode > ThisViewCrashesPreview.swift
Try to use the SwiftUI Previewer
Crash will occur and preview will not render, see lines 8-11 of ThisViewCrashesPreview.swift for more details
NOTE: See file: PreviewFailingTestProject > PreviewFailingTestProjectApp.swift > MainWindow View on lines 13-19. This renders fine on both the SwiftUI Previewer and when deployed to device.
Also experiencing this issue. Xcode 13.1 does not have this warning. Xcode 13.2 does. When the conversion process is ran it does not make any changes.