Running the app on a real Apple Watch and infinite spinner - xcode

I wanted to make a clickable prototype of an app on (storyboard only). I have just added two interface controllers and some images and buttons. I filled xcassets with several images (overall less than 150kB) and tried to run the app. When there was a single interface controller with 3 buttons (images in background) + 1 imageView (around 100kB all) it took some time but the app lauched. I added 1 more interface controller and a few images to it (the biggest are around 9kB) and this time Xcode displayed me a message that it lost a connection with an iPhone but the watch is still running or the watch app timed out error. At the same time I have the app name on the watch screen and a spinner. And it's spinning for ages without any result... I've tried to delete the app from both devices, restarting, cleaning folders etc. and no success. Is there a limit of images one can put in the watch's xcassets? So frustrating...

I was also facing same issue where spinner on real devices was never ending.
This was because watch extension and watch app were missing arm64 architecture, make sure you select Standard Architectures(armv7 and arm64)in build setting.

Here is what you could do/check:
You should use the xcassets that is located in your WatchKit app, not the one in your WatchKit extension.
Build and run your main iPhone app as the primary target once.

Yeah, i've been struggling with this too...
the only way i found : i click on digital crownd of the AppleWath, then re-tap on my app and magically the app launching (and the debugger work.)
if this is not working the hard way : Reboot xcode, Clean, if still not working same as you clean, restart devices... this is so annoying.
first solution take less time, and work 7/10 times
if someone knows a beter solution i'll take it !! ;-)

Related

I am trying to build and launch my app with xcode 9.2 and when I build on a device it it is just a white screen

The screen is just white whenever I try and open my app on the device and the simulator. I have built and ran apps successfully before but I can't figure out why this one won't build correctly.
There's a few things that could cause this, but the first thing I would check is to make sure the initial view controller is set properly.

Apple Watch Program ended with exit code: 0

I'm using Xcode 8.1, Swift 3.
I'm making a custom watch face for the Apple Watch (For myself).
So i set the watch to always show last app on wake, and after sometime i noticed that it get back to the default watch and my app is closed.
For a week now I'm trying to figure out why the app keep closing.
On Xcode i tried to debug the WatchKit Extension and after some time the console just print: "Program ended with exit code: 0" and the app closed again.
I looked on google to check if WatchOs have timeout for apps and didn't find out anything about it.
Also the app is sometimes closed after 5 min and sometimes after 12 h...
The app is never pass the 1.5MB memory.
Any idea what could possibly cause that?
I faced the same issue while working on an app.
In my case I'm using SpriteKit scenes which take a lot of memory for rendering to it causes the crashing of the app on watch.
Do check the memory consumption of your app. Make it under the bar to test it on the device.
Try to remove the elements which you think of taking a lot of memory. Use Instruments to track them.
NOTE: It will run successfully on Simulator. But on the real apple watch it crashes.
App will quit after 8 minutes if it is not in the dock, this is explained in WWDC16 videos, other bug might be similar to this:
Watch App terminates upon deactivation if WKAlert is being shown

How to setup correctly iPad Launch Images in xCode 4.2 for both orientations

Ok. So I have iPad app in Xcode 4.2 targeted for iOS 5.1. I provided it with launch images for both landscape and portrait modes and it has some serious trouble with using them properly.
First in landscape mode it shows proper landscape image but rotated by 90 degrees CW and cropped on the right side. Then when it starts to display it properly but does it also in portrait mode (as if it doesn't recognize portrait mode at all anymore).
I've seen some suggestions like providing portrait image with rotated content for landscape mode, etc. but the problem is I can't for the life of me make xCode use both images in right moments.
Is there some voodoo for that? Like setting them in proper order, use plist directly or the slots in GUI, putting them in some special directory or two different directories, I don't know - anything? Fighting xCode over such things will make me puke with blood one day...
Ok, one thing to know is that xCode seems to be very capricious when it comes to updating settings, resources etc. I deleted references to the launch images from the project, cleaned the product in xCode and removed the app from simulator but it still somehow managed to use the launch images even though it didn't show copying the images in build log.
I'm not sure if it took the pictures from derived data or what but I had to delete derived data and remove the images manually from the app bundle in ~/Library/Application\ Support/iPhone\ Simulator/5.1/Applications/ to make it stop. Then I pasted the images manually into the app bundle and now after publishing both images work properly in the simulator ignoring the fact that I didn't set them up at all in xCode!
I'm still not sure how to proceed with the device version - it obviously doesn't have the launch images now...
Apparently xCode doesn't care at all about setting anything about the launch images apart from including properly named images in the project so they get copied to the bundle. As I wrote above you can even inject the images into the app bundle and it still works.
The other side is that once you get the images there it may by hard to get rid of them.
So anyway now I have nothing in my plist about the images, nor anything in the slots in the Target Info and I have four working launch images in my app (both orientations and retina).
Hope it helps someone sometime..

XCode: What's the fastest way to restart my app so I can debug faster?

Say I am debugging and accidentally go past the function I wanted to step into. Currently, I rerun the app again through xcode (apple+R) and have to wait for the app to load again. Is there a faster way? I looked into the stop command (apple+.) but when I load the app again from the simulator my breakpoints don't trigger.
Restarting is probably your best bet, but it sounds like you may simply have too many breakpoints set if you're mindlessly hitting "Next" by the time you get to the one you want. Try turning off some of the preceding breakpoints (particularly those in loops).
If the breakpoint is in a loop, and you really only care about it under certain conditions (why else would you skip past it?), try setting it up as a conditional breakpoint that will only stop when you need it to. Check the answer to this question for more info on how to do so.
Ok so what i understand from the question is this : you have some breakpoints into a function...you run the app from xcode ..it didn't go into that function...then you went to simulator and run it from there and the breakpoints didn't trigger.
If that what you ment by the question ..your problem is that when you run the app from the icon in the simulator that doesn't run in debug mode it runs in release mode-ish (with some minor differences) .The debug mode only works when it's directly started from xcode (so of course your breakpoints didn't trigger).
As for the loading speed..you can't do anything about that it loads as fast as it possibly can. I personally only build and run on the actual device ..and from my experience it takes 2~4 s from the time i hit run till the app loads completely. That being said i noticed that if you have a splash screen (Default.png) it takes 1~2 s more to load so what i do is just remove the Default.png from the project , delete the app from device, restart the device, restart xcode and the screen wont be loaded every time . It may not seem like much ..per build but on the course of a few weeks of development it ads up to minutes. Also..don't forget to add the Default.png when you release it ...i forgot once and app got rejected :)

Launch image doesn't update

I'm using Xcode 4.3.1. Adding launch image is pretty simple -- just drag the image to the Project->Summary->Launch Images window.
So I set a launch image before and it worked. But when I dragged a different image and run the app on my iPhone again, the launch image still remain the same as the old one. Even after I delete the launch image from the Launch Images window, the old image still shows up upon launching.
I've tried clearing the build as well. Didn't work.
Help please. Very much appreciated!
I had the same issue, but with launch storyboard. I had to rename the image I've used as a background.
Deleting from the device didn't help with Xcode 4.5.1. The build process is caching the image. With a hint from Zorayr's answer to related question "Xcode, can't remove “Launch image” from project," I decided to track the cached image down and destroy it, so it wouldn't keep being built and showing up in my test App.
Eventually, I found that Xcode (at least 4.5) builds the images by default in the following path off your home directory:
~/Library/Developer/Xcode/DerivedData/<ProjectName>-<uniqueID>/Build/Products/<Scheme>-iphone{os,simulator}/<ProjectName>.app/
So in addition to removing the old App image from the device (or simulator,) you also need to remove the image file(s) from the build cache. But just doing something like
rm ~/Library/Developer/Xcode/DerivedData/MyProject-fpwnjlbayydgzxcdlyrwxrwntapr/Build/Products/Debug-iphoneos/MyProject.app/Default*.png
won't always solve your problem. Instead, you might get a strange error in a popup window saying something like "Signed product moved or deleted." (I can't reproduce it right now to get the exact text.) It doesn't show up in the log file, and it just hangs the build process (in Xcode 4.5.1.) To get around that, I deleted all of the files under the <ProjectName>.app/ directory tree and the sibling directory tree <ProjectName>.app.dSYM/ containing (seemingly) the symbol tables and signature files for the parallel products. The build process will then re-create everything with no more complaints.
What worked for me on iOS 10.2.1, iPhone 5s hardware test device, Xcode 8.2.1
I think it has nothing to do with Xcode. The test device appears to be caching the LaunchScreen.storyboard image. I needed to reboot my device by holding home + top button. Then I rebuilt, low and behold, the image updated.
You should delete the app from the device, then launch it again.
Quit the simulator and then run the project again.
For device, as mentioned in other answers, delete the app from the device and then run the app again.
Steps that worked for me in 2020 (xCode Version 11.4.1):
Delete derived data
Restart xCode
Delete app on device
Restart device
Clean rebuild and run
Except the last step, I think the order doesn't matter.
It's really annoying though and I'm not even sure if it always works.
Pretty pathetic on apple's side. Good luck guys!
If you were using an asset catalog, it can also help to delete the images from the Images.xcassets file, and then load them manually in General>Launch Images.
This is what worked for me
Put the new image in project folder
Run app on device/simulator
Put image in xcassets under a different name
Run app again and it works
I thought I would create an update for anyone who is XCode 10 (and possibly XCode 9) and experiencing a blank black or white screen after modifying a launch image.
In my case I had to create launch images for the iPhone XR, iPhone X, iPhone XS and iPhone XS Max.
Originally I just had a sample white launch image for testing. After creating my proper image for the XR and replacing the sample the change would simply never show (on the XR device). I would still get a white screen.
I tried all of these in combination and failed:
-deleting the app beforehand.
-deleting xcode derived data and cleaning the build.
-restart Xcode and the device and the computer.
-deleting any existence of the white launch image on the computer.
-manually editing the JSON in a new images asset with the correct file names
The XR device would continuously show a white screen and after meddling with the build setting and migrating back to image packs it turned to black.
Solution:
Ultimately it started working after I also replaced the white 'XS' launch image with a new one as well. Even though the device is an XR. This is an odd solution but solutions like this have helped with launch images throughout the years.
For me, quitting the Simulator and restarting it worked -- I can finally see the updated launch image. The note above from Emil Korngold triggered me to try this.

Resources