SKScene didMove(to view: SKView) is called twice on some devices (not in simulators and other devices) - sprite-kit

I've asked this question before (to no avail), and it follows up a more recent inquiry about the same app.
I have a GameScene called from the body of a SwiftUI view. App deployment is set to iOS 14.0.
On xCode simulators and an iPhone13 (all using iOS 15), the app works as designed.
However, on an iPhone8 using iOS 14.8, it does not work: Print statements to the console indicate that didMove(toView: SKView) is inexplicably being called twice: once when expected and then after the a startGameAction() function is called. The game flashes on the screen for a moment, but then (as didMove() gets called a second time, the view changes to the initial state. But the game is "running" in the background; the music is playing and when the timer runs out, the "Round Over" info is displayed normally.
If it helps, I uploaded the project to github if any kind and curious person would like to take a look.
Thanks!

Related

watchOS application is not opening in background after scheduling

Apple Watch Series 3 watchOS 4.x.x, iPhone 6 iOS 11.x.x, Xcode 9.2
I downloaded the code from the following link:
SOURCE CODE
Then able to install and run this swift application on my apple watch.
As per code, I tapped "Schedule Refresh" button and put my app in background by pressing crown button. Then app was not opening in background for making server call.
I was expecting, following function will be called, but not
func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) { }
So, please let me know if anyone tried this sample app to run watch application in background.

Swift and Spritekit won't run on device running iOS 7.1

I'm getting a really weird warning when I try to run my Swift project on my device, using Xcode 6.
The device is running iOS 7.1, and my mac is running Mavericks.
I have written a little game in Swift and SpriteKit, and it works in Simulator, but when I try to run it on my device, I get a warning, and my device only shows a black background.
I get the same result when trying to run a fresh SpriteKit project. But if I run a fresh Single Page Application using Swift, it runs normally.
This is the warning I get:
Any suggestions?
I also got this crash and, comparing to the 7.1.1 SDK SpriteKit game template, it appears to be related to loading the scene from an .sks file.
I changed it to use a different initializer like this:
let scene = GameScene(size: skView.bounds.size)
After that, the template project is not crashing anymore on my iPad mini with iOS 7.1.1. However, the plane sprites don't get rendered. You can see the node count (on the bottom right corner) go up with each tap, but the sprites aren't visible. The "Hello, World!" label shows fine, though...
Same behaviour here: default generated SpriteKit game was crashing. Now with the XCode 6 final, it all seems to work just fine, but try to add a particle emitter, and you back to XCode crashing hell. XCode keeps crashing on any particle emitter file saved as .sks file. I found that this is a known bug in XCode 6, that seems to be fixed only in 6.1 beta. See: Can't open particle SKS files
I was getting this problem too, with me it was crashing on the self.addChild(myLabel) on the default scene that loads (the one with Chalkduster "Hello, World!" and spaceships spinning on touch, I think it's called GameScene by default).
Comment out the self.addChild(myLabel) in GameScene and see if that stops the crashes. As a temporary solution I just made the viewDidLoad method load up another scene straight away and the new scene acts as you'd expect. It seems like it's something on Apples end of things, xCode6 is only in beta after all.
Try again with the latest Xcode 6 beta 4. There are still some bugs, but the basic SpriteKit template is now working fine.

App won't respond until rotation/2x occurs on iPad3

I am wondering if anyone else has had this happen to them. I have a iPhone App that I have been updating for over a year and it has been working just fine on my iPad2, iPhone 3GS, as well as the 4G, 4GS, and 5. However, just recently I obtained an iPad3 to test the App on. Something very strange happens: When the App is loaded through Xcode in development it comes up and looks perfect - however, it won't respond to any touches at all. I have an alert that pops up on load and you can close that, but the actual main view controller will not react to any drag or touch gestures - it is essentially frozen. However! When I rotate the device and the App rotates correctly, it suddenly starts working just fine, even if I rotate it back! The simulator for the iPad running iOS6 in normal and retina does the same thing even though it works just fine on my iPad2. However, the simulator for the iPhone works just fine.
Like I said, this doesn't happen on any other device. Even loaded the same way all devices allow tapping like normal. Here is what I have been able to confirm:
iPad3 device: frozen
iPad-retina sim: frozen
iPad-normal sim: frozen
iPad2 device: normal
iPhone-retina sim: normal
iPhone-normal sim: normal
iPhone 4S device: normal
iPhone 4 device: normal
If all the iPhones worked and the iPads didn't, it would make some sense. But my ipad2 works just fine. Also, if I use the iPad3 open it, it is frozen. BUT! If I hit the 2X button, it starts working again even without rotation.
I also decided to test and see if it would work as a Universal App. On the iPad3 when I switch it over to Universal, it works just fine to begin with. So something weird must be going on with the simulator. Any ideas?
Thanks!!
-Mark
A view (in your case the whole thing) not accepting any input often means that one of the superviews has a frame smaller than its contents. This could be the case here, strangely only in specific situations, upon rotation the view frame gets the correct size and stays correct afterwards.
Did you solve this in the meantime? You can try to give the views different transparent background colors and/or make them clipToBounds, starting with the top view controller's view. That way you'll see if something is wrong with the frames.

iPhone app is controlling itself without IBAction

I have a simple application. It is you touch start button, then the display will change, then you shake your iPhone, it shows you some texts. The problem I am having now is first time the app was developed for iOS 3.0. Since then the codes weren't touched. Last week I upgraded my Xcode into version 4.2. Then my app is controlling itself no touches required. It will control itself. When I modified the touchesbegan function, it doesn't change. Neither the accelerometer does. So what could be the problem?

QLPreviewController shows a blank document after returning from background

I am having an issue with QLPreviewController on XCode 4.2 iOS SDK 5.0. I run my code on iPod Touch running iOS 4.3.3. Basically my app uses QLPreviewController to preview PDF files in Documents directory and if the app resigns active, the next time it becomes active it will require a user to enter 4-digit PIN number. The app runs fine in general, previewing PDF files with no problem at all. The problem I'm facing is that QLPreviewController shows a blank screen after the app returns from background (and of course after a correct PIN has been entered).
I have the screenshots below. The one before going to background is http://www.mediafire.com/i/?vxdmrx5mjxrwglp
and the one after returning from background is http://www.mediafire.com/i/?jhdmavzvccj0f2q
Please note that the source PDF file is not modified at all, and I did call both refreshCurrentPreviewItem and reloadData methods in viewDidAppear.
Similar problems on iPhone Simulator running 4.3.2. However, this problem does not occur on iOS 5.
Does anyone ever experience this issue? Any comments or workaround would be much appreciated.
Thanks
PS. It is strange that when the application goes to background, the delegate previewControllerDidDismiss: is fired on iOS 4. On iOS 5, this does not happen. Perhaps this is the reason of the blank screen. Any thought? Any workaround?
I had an issue on iOS 5.1 where the custom button I had on the Quicklook toolbar disappeared when coming back from the background. I fixed it by using an NSNotifcation for when the app became active again and the Quicklook controller listened for it and re-updated the navigation button.
I assume something similar could be done with reloading the document.