Post

Replies

Boosts

Views

Activity

For indie developers - separate AppleID for your business?
Hi all - I am curious as to whether it is a good idea to make a separate Apple ID for distributing apps, etc. I am working on apps as a side gig and I'm trying to decide how to approach this. Are there any "gotchas" if you set up a second Apple ID just for your paid developer account? I assume you can set up your personal ID as a "developer" in App Store Connect for testing. How do you do two-factor for the "business" ID? (Do you need a separate device for that?) Do you use the same phone number for both accounts (I'm only planning on having one phone, haha)? Are there actually any meaningful advantages to having a separate Apple ID for this purpose? Thanks for any thoughts on this!
4
0
5.7k
Jan ’21
How to run UI tests for SwiftUI App lifecycle apps with different environments?
Hello - I posted this question on StackOverflow and it didn't get any traction, so I thought I'd repost it here. https://stackoverflow.com/questions/65370523/how-to-run-ui-tests-for-swiftui-app-lifecycle-apps-with-different-environments I'm trying to figure out how to run UI tests for a SwiftUI app that is using the "SwiftUI App lifecycle" with preview data - in particular some data for CoreData, but it might be more general. With the SwiftUI App lifecycle, we know have "main" entry points like: @main struct MyApp: App { 	let persistenceController = PersistenceController.shared 	 	var body: some Scene { 		WindowGroup { 			ContentView() 				.environment(\.managedObjectContext, persistenceController.container.viewContext) 		} 	} } wherePersistenceController is a struct that is managing the CoreData stuff (with this example created by Apple's template if you just make a new App and select "use CoreData"). I have written an extension with a bunch of preview data that can easily be loaded in PreviewProviders just by setting a different managedObjectContext with .environment() on the view code, etc. for use while developing the UI code. Is there a way to make this preview data available inside a UI test? We usually have UI test code that looks sort of like: class MyUITests: XCTestCase { 	 	var app: XCUIApplication! 	 	override func setUpWithError() throws { 		app = XCUIApplication() 		app.launch() 		continueAfterFailure = false 	} 	 	func testTabBarButtonsAndNavTitles() throws { 		let tabBar = app.tabBars["Tab Bar"] 		let loadAndGoTabBarButton = tabBar.buttons["Load and go"] 		loadAndGoTabBarButton.tap() 		XCTAssert(app.navigationBars["Load a thing and do it"].exists) 	} Is there a way I can tell the XCUIApplication() to use a different managedObjectContext value in the environment call when it starts? If not - it seems like the only way to test some of the SwiftUI elements would be to have the UI test function first "tap around" and enter a bunch of preview data, but this is really cumbersome. It would be better if the app could start up for testing with some saved data. Apologies for not providing a fully runnable piece of code to illustrate this, but it would require a lot of infrastructure and boilerplate, etc. Thanks for any thoughts on this!
1
1
1.9k
Jan ’21
SwiftUI NavigationView with PresentationMode creates bug in multilevel navigation hierarchy
I asked this question on StackOverflow - https://stackoverflow.com/questions/63104172/swiftui-navigationview-with-presentationmode-creates-bug-in-multilevel-navigatio also, but my interactions there have lead me to think this might be a SwiftUI bug, so I thought I'd ask here too. I have an iOS 13.5 SwiftUI (macOS 10.15.6) app that requires the user to navigate two levels deep in a NavigationView hierarchy to play a game. The game is timed. I'd like to use custom back buttons in both levels, but if I do, the timer in the second level breaks in a strange way. If I give up on custom back buttons in the first level and use the system back button everything works. Here is a minimum app that replicates the problem: class SimpleTimerManager: ObservableObject { &#9;@Published var elapsedSeconds: Double = 0.0 &#9;private(set) var timer = Timer() &#9; &#9;func start() { &#9;&#9;print("timer started") &#9;&#9;timer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true) {_ in &#9;&#9;&#9;if (Int(self.elapsedSeconds * 100) % 100 == 0) { print ("\(self.elapsedSeconds)") } &#9;&#9;&#9;self.elapsedSeconds += 0.01 &#9;&#9;} &#9;} &#9; &#9;func stop() { &#9;&#9;timer.invalidate() &#9;&#9;elapsedSeconds = 0.0 &#9;&#9;print("timer stopped") &#9;} } struct ContentView: View { &#9;var body: some View { &#9;&#9;NavigationView { &#9;&#9;&#9;NavigationLink(destination: CountDownIntervalPassThroughView()) { &#9;&#9;&#9;&#9;Text("Start the timer!") &#9;&#9;&#9;} &#9;&#9;} &#9;&#9;.navigationViewStyle(StackNavigationViewStyle()) &#9;} } struct CountDownIntervalPassThroughView: View { &#9;@Environment(\.presentationMode) var mode: Binding&lt;PresentationMode&gt; &#9;var body: some View { &#9;&#9;VStack { &#9;&#9;&#9;NavigationLink(destination: CountDownIntervalView()) { &#9;&#9;&#9;&#9;Text("One more click...") &#9;&#9;&#9;} &#9;&#9;&#9;Button(action: { &#9;&#9;&#9;&#9;self.mode.wrappedValue.dismiss() &#9;&#9;&#9;&#9;print("Going back from CountDownIntervalPassThroughView") &#9;&#9;&#9;}) { &#9;&#9;&#9;&#9;Text("Go back!") &#9;&#9;&#9;} &#9;&#9;} &#9;&#9;.navigationBarBackButtonHidden(true) &#9;} } struct CountDownIntervalView: View { &#9;@ObservedObject var timerManager = SimpleTimerManager() &#9;@Environment(\.presentationMode) var mode: Binding&lt;PresentationMode&gt; &#9;var interval: Double { 10.0 - self.timerManager.elapsedSeconds } &#9;&#9; &#9;var body: some View { &#9;&#9;VStack { &#9;&#9;&#9;Text("Time remaining: \(String(format: "%.2f", interval))") &#9;&#9;&#9;&#9;.onReceive(timerManager.$elapsedSeconds) { _ in &#9;&#9;&#9;&#9;&#9;print("\(self.interval)") &#9;&#9;&#9;&#9;&#9;if self.interval <= 0 { &#9;&#9;&#9;&#9;&#9;&#9;print("timer auto stop") &#9;&#9;&#9;&#9;&#9;&#9;self.timerManager.stop() &#9;&#9;&#9;&#9;&#9;&#9;self.mode.wrappedValue.dismiss() &#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;} &#9;&#9;&#9;Button(action: { &#9;&#9;&#9;&#9;print("timer manual stop") &#9;&#9;&#9;&#9;self.timerManager.stop() &#9;&#9;&#9;&#9;self.mode.wrappedValue.dismiss() &#9;&#9;&#9;}) { &#9;&#9;&#9;&#9;Text("Quit early!") &#9;&#9;&#9;} &#9;&#9;} &#9;&#9;.onAppear(perform: { &#9;&#9;&#9;self.timerManager.start() &#9;&#9;}) &#9;&#9;.navigationBarBackButtonHidden(true) &#9;} } Poking at this some more, I see two strange behaviors. If I don't use a pass through, everything works for manual clicking. But if I let the timer expire and create a pop back, when I try to restart it, the view immediately pops, but the timer keeps running. If I do use a pass through, the timer starts when I navigate two levels down, but the view doesn't update. I wonder if this is a bug in how SwiftUI is handling the onAppear and mode.dismiss methods.
0
0
912
Jul ’20
Launching simulator freezes whole Mac
I have a 2019 16 inch MacBook Pro running Catalina 10.15.5 with a strange problem. Just launching the Simulator can hard freeze the entire machine. The Simulator launches, the device shows a spinner that just keeps going and within a couple of seconds the machine beach-balls and the entire UI freezes with no possibility of option-command-escape to kill the Simulator. I've looked in the logs afterward and I don't see any good clues. This problem is much more likely to occur with a simulated iPhone device (much more rare with a simulated iPad) and it doesn't happen every time I launch a simulated iPhone, just somewhere between 1/3 and 1/2 of the time. Does anyone have any debugging or diagnostic ideas? Thanks!
8
0
3.4k
Jul ’20
system freeze while swiftui canvas builds preview
Hello,Running: 10.15.4 with Xcode 11.5 on MacBook Pro (16-inch, 2019)Even extremely simple "Hello world" SwiftUI apps occasionally freeze the entire machine while generating canvas previews with SwiftUI. Searching around on the internet has lead me to disable "Paralellize Builds" in the Scheme and this helps, but does not eliminate the problem. Also, similar full system freezes have occured when running the app without the appropriate simulator device already up and running, but this is less reproducible.Has anyone seen similar problems? I basically can't use previews with SwiftUI with this problem.Thanks for any thoughts.
1
0
1.1k
May ’20