I'm restarting my app using CoreData and CloudKit and want to implement testing before I get too far and it becomes unmanageable. Is there a good tutorial anyone has found for testing when using SwiftUI (macOS and iOS but not storyboards).
Thanks. It seems overwhelming right now and I don't know where to start. :)
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi,
I'm creating a SwiftUI MacOS app with a NavigationSplitView consisting of a Sidebar and Detail. It works great; however, whenever I ran the app the sidebar is hidden. As a user I can easily click the button or menu option to bring it back BUT it's frustrating to do AND I need to test the app now.
Is there a way to have it open by default when running the app or, at least, programmatically so I can set it as a user default? And/Or a way to make it visible when running UITests?
Thanks
I'm creating a multiplatform app on the Beta Xcode and have just migrated code over to set an image from the photo library. When I run the app on my iPad (with beta OS) it works fine. When running the same code on the iOS simulator I end up with a blank view without any images.
There are a lot of errors outputted to the console starting with:
2022-07-12 09:59:46.037994-0700 MyAppName[10647:2080202] [UIFocus] TtGC7SwiftUI14_UIHostingViewVS_7AnyView implements focusItemsInRect: - caching for linear focus movement is limited as long as this view is on screen.
objc[10647]: Class _EXRunningExtension is implemented in both myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x7ff864a43f90) and myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x1231e5d48). One of the two will be used. Which one is undefined.
objc[10647]: Class EXConcreteExtension is implemented in both myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x7ff864a43fe0) and myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x1231e5d98). One of the two will be used. Which one is undefined.
objc[10647]: Class EXExtensionPointCatalog is implemented in both myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x7ff864a44030) and myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x1231e5de8). One of the two will be used. Which one is undefined.
and ending with:
objc[10647]: Class _EXSceneSessionConnectionResponse is implemented in both myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x7ff864a45250) and myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x1231e7008). One of the two will be used. Which one is undefined.
objc[10647]: Class EXService_Subsystem is implemented in both myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x7ff864a452a0) and myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x1231e7058). One of the two will be used. Which one is undefined.
objc[10647]: Class _EXConnectionHandlerExtension is implemented in both myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x7ff864a45318) and myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x1231e70d0). One of the two will be used. Which one is undefined.
objc[10647]: Class EXXPCUtil is implemented in both myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x7ff864a45340) and myPathway/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ExtensionFoundation.framework/ExtensionFoundation (0x1231e70f8). One of the two will be used. Which one is undefined.
2022-07-12 09:59:47.154471-0700 MyAppName[10647:2080475] [NSExtension] Unable to setup extension context - error: Couldn’t communicate with a helper application.
2022-07-12 09:59:47.154654-0700 MyAppName[10647:2080349] [NSExtension] Async Begin using error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.mobileslideshow.photo-picker.apple-extension-service" UserInfo={NSDebugDescription=connection to service named com.apple.mobileslideshow.photo-picker.apple-extension-service}
2022-07-12 09:59:47.154847-0700 MyAppName[10647:2080202] UIImagePickerController UIViewController create error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.mobileslideshow.photo-picker.apple-extension-service" UserInfo={NSDebugDescription=connection to service named com.apple.mobileslideshow.photo-picker.apple-extension-service}
I guess I'm wondering if someone else came across this and how you fixed it. Is it an error on my side or the beta software?
Hey,
During a developer Q&A today I was referred to a "Sundae shop" (the ice cream) sample code from, I think it was, WWDC 2020. Does anyone know where I can find it? I want it mainly for ObservedObject updates for my view from an async model.
Thanks :)
I'm looking to test my Xcode project using the default file set up XCTestCase... but I need to test it against a service that will need to be started before the test and stopped after the test. I was hoping to start and end it within the setUpWithError and tearDownWithError methods but I don't know how. Is there a way I could run commands from the testing environment?
Basically I want to figure out where it's executing from ls one time, move my files over, and then I can go through starting the service setUpWithError, running the tests, and then ending the service tearDownWithError.
Specifically the service runs a Docker image and I use a Makefile to make it a simple command. I just want to start and end it from the test environment.
Thanks
I'm setting up tests for my Xcode Multiplatform App. To create a test environment I created a docker image that I want to run an XCTestCase against. I understand I'd have to make sure Docker is running before running the test. That said I have a permission denied when trying to connect to the docker daemon socket.
Background: I'm using a makefile to store the commands and planned to run the docker build and docker run commands in the setUpWithError while running the docker kill command in tearDownWithError. To run the commands I used Process to execute the shell commands. I'm currently doing this is a test function to get it up and going.
Issue: When I try to run the docker command Xcode tells me that it doesn't give me the permission to run it:
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create?name=remarkable": dial unix /var/run/docker.sock: connect: operation not permitted.
See 'docker run --help'.
I only want to use Docker to run this specific XCTestCase. Is there anyway to run it from here JUST for the test? Or do I need to manually run docker and kill it before/after I run these tests?
Thanks for any help.
Hi,
I'm looking through the Backyard Birds app and trying to wrap my head around StoreKit 2 and make it work with my app.
Currently my app is three tabs that, for example, call access1, access2, and profile. I want to make users pay for access to the first two tabs and, by default, profile is visible on download for unsubscribed members. In the Backyard Birds app they have three levels that are clear cut and then they figure out access for family sharing by the highest level the user has.
I currently have six subscriptions listed under my group:
level1:
all access annual
all access monthly
level2:
access1 only annual
access1 only monthly
access2 only annual
access2 only monthly
My thought with this (not set up yet) is if the user subscribes to all access they have access to all three tabs. If they subscribe to access1 only they have access to the first and third(profile) tabs. If they subscribe to access2 then they have access to the second and third tabs.
I guess my main problem is I don't know how to implement func status(for statuses: [Product.SubscriptionInfo.Status], ids: PassIdentifiers) -> PassStatus as if there's a family member with access1 and another family member with access2 then the current person should essentially have all access (all three tab access).
Before I stumbled along further I wanted to check with all of you and see if there's a better way to set up or continue with the Backyard Pass example with different logic in status.
Thanks everyone.
I like how the TabView control looks on the mac and ipad and decided to see if my current code can show the tabs in my multi-platform app just to realize that whenever I click on one of those tabs my macOS app currently crashes every time I press any other tab with the error: Thread 1: "NSToolbar 0x600003de33c0 already contains an item with the identifier com.apple.SwiftUI.navigationSplitView.toggleSidebar. Duplicate items of this type are not allowed."
While trying to troubleshoot I noticed several other people have had a similar issue with differing reasons (toolbars and searchers mentioned) all in macOS since upgrading to 15.0: https://forums.developer.apple.com/forums/thread/763829
Minimal Viable Project: to show the issue
I commented out most of my code calls hoping to create a project that worked so I could bring my code back in and see if it broke. I still had this issue so I next created a minimal viable example.
Here it is:
import SwiftUI
import SwiftData
@Model
class Issue {
var name: String
init(name: String) {
self.name = name
}
}
@main
struct TestMultiplatformApp: App {
var sharedModelContainer: ModelContainer = {
let schema = Schema([
Issue.self,
])
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
do {
return try ModelContainer(for: schema, configurations: [modelConfiguration])
} catch {
fatalError("Could not create ModelContainer: \(error)")
}
}()
var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(sharedModelContainer)
}
}
struct ContentView: View {
@State var isCompact: Bool = true
var body: some View {
VStack {
if isCompact {
EntryTab()
} else {
EntrySidebar()
}
Toggle(isOn: $isCompact, label: {
Text(isCompact ? "TabView" : "Sidebar")
})
.padding(.horizontal, 20)
.padding(.bottom, 20)
}
}
}
public struct tabControl: Identifiable, Hashable, Sendable {
public static func == (lhs: tabControl, rhs: tabControl) -> Bool {
lhs.id < rhs.id
}
public var id: Int // Tab Number
public var displayName: String
public init(id: Int, displayName: String) {
self.id = id
self.displayName = displayName
}
}
struct EntryTab: View {
let entryTabs = [
tabControl(id: 0, displayName: "row 0"),
tabControl(id: 1, displayName: "row 1"),
tabControl(id: 2, displayName: "row 2"),
tabControl(id: 3, displayName: "row 3")
]
@State private var selectedTab: Int = 0
var body: some View {
TabView(selection: $selectedTab) {
ForEach(entryTabs) { tabCtrl in
NavigationSplitView {
Text("Selected tab is \(selectedTab)")
} detail: {
Text("Choose item from sidebar... in future this would be content")
}
.tabItem {
Text(tabCtrl.displayName)
}
.tag(tabCtrl.id)
}
}
}
}
struct EntrySidebar: View {
@State private var selectedTabID: Int?
let entryTabs = [
tabControl(id: 0, displayName: "row 0"),
tabControl(id: 1, displayName: "row 1"),
tabControl(id: 2, displayName: "row 2"),
tabControl(id: 3, displayName: "row 3")
]
var body: some View {
NavigationSplitView(sidebar: {
List(entryTabs, id:\.id, selection: $selectedTabID) { thisItem in
Text(thisItem.displayName)
}
}, content: {
Text("Hi selected tab: \(String(describing: selectedTabID))")
}, detail: {
Text("Choose item from sidebar... in future this would be content")
})
.onAppear() {
// Set the selected tab
selectedTabID = 1
}
}
}