App suddenly will not run on device - xcode

I have been running an app on my ipod that I've been developing for a while now and all of a sudden it won't run. I haven't changed xcode or macos; I've deleted the derived data folder; I've restarted the device, computer and xcode and cleaned.
The error I'm getting is: "could not start debugserver on MyDevice when trying to launch My.app"
My provisioning profile and device are green. I can't understand what I could possibly have changed.
Any ideas?
Thanks.

Restart Xcode and the device and you should be fine.

just CMD+shift+K, clean you project. when it's done, it should be work. at least for me.

Try deleting the installed application from your phone. That worked for me as none of the above methods did.

I had this issue while I was testing iOS beta. I updated iOS version on device and I had to restart xcode and then reconnect to

Restart xcode.
Unplug iPhone/iPad from usb cable (If connected with usb cable).
Turn off wifi and connect again (If you are using wifi debug).
Clean project.
Run your app again.

Related

React-Native IOS real device does not connect to Metro server

My Simulator works fine it connects to the development server first try. But on my real device I have to delete node modules, reinstall Podfiles, clean building folder and delete Derived Data then it loads a bunch of time in Xcode and finally connects to dev server. But after I stop it and I want to run it again it wont connect. I used to able to just run npm start and launch my app on my phone and it connected automatically, and I could make changes, it refreshed and everything, but now even with Xcode running it doesn't work 10/9 times.
And yes I'm on the same network with my phone as the computer. I tried to set my mac's IP on Bundle Settings on the phone, no success.
Anyone got any idea?
Have the same problems. These are my steps to 'fix' this:
Ensure that you don't have ethernet internet cable plugged in. Only wifi network (iPhone and Mac has to be on the same wifi network)! I think that this was the main problem in my situation.
Turn off the metro, the app usually starts (because the native app build contains also js build).
Then run the metro again.
Shake your device and Configure Bundler with your Mac's IP
it seams that only resave of this screen helps - so you don't have to spend time with finding and entering the IP
Then it should connect to your metro
I spent hours trying all possible fixes...
Another hints:
https://github.com/facebook/react-native/issues/29587
https://github.com/facebook/react-native/issues/29396
delete pods file
update ios pod
cleanup DerivedData
update react-native (I don't have problem with clean RN app)
update xCode, iPhone, Mac
try different iPhone device
For me it was the XCode build which was targeted for Release, not Debug.
Simply navigate Product > Scheme > Edit Scheme and change the Build Configuration to Debug.
Once the app is launched shake the device to enter the dev menu, click configure bundler and put the IP address of the machine running metro. Mine was set to default localhost. There is also a metro.config.js that I think you can set this up to use a spec.
If you're on a mac the local IP address can be found in system pref -> network -> WIFI
The only thing the predictably works for me is connecting with the mac to the iphone's hotspot.
Not ideal, but nothing else worked for me 🤷‍♀️
I'm on m1 in case it matters
For me it was enough to remove node_modules folder
rm -rf node_modules
Then I have run
npm install;
npm start -- --reset-cache;
And reinstalled pods
cd ios; rm -rf Podfile.lock Pods; pod --repo-update install; cd ..;
Make sure your Mac and iPhone are connected to the same wifi.
In your xcode go to:
Window -> Devices and Simulators -> click on your iPhone-> make sure Connect via network checkbox is checked.
Shake your iPhone -> in the poped up modal select Configure bundle
Press and hold Option key and click on your wi-fi icon in the menu bar. Under your wifi network there will be your IP address. Paste it to the modal from previous step. No need to specify port and file name.
Make sure the Local Network permission is enabled for the app; otherwise iOS won't be able to access your Mac and the jsbundle
If you're on:
IOS: 16.0 >
XCode: 14.0 >
Make sure your iPhone and Mac are on the same wi-fi.
Go into XCode > Click your project > Build Phases > Bundle React Native Code and Images > tick the box for 'For Install Builds Only'.
If it's already ticked, untick the box then build. Then re-tick the box then build again.
Your app should request local network access this is the key fact with this issue. You can check in the settings of your app on the iPhone.
As a rule of thumb whenever running an app on iOS device, or even a simulator I've used before I uninstall the app before running again.
Unsure if you had a previous version in this instance but worth a shot in the dark.
I find running via Xcode rather than react-native run-ios is more consistent also.
Turn off/on wi-fi on device / on mac, rebuild app
What worked for me after trying everything I could, was creating a file main.jsbundle inside the ios folder, adding to the XCode project and target the file with the application using the Target Membership section (in XCode)
On iOS 16 the real device can't connect on metro bundler. To verify this, open safari and enter your mac's IP, eg. 192.168.1.10:8081 (8081 is the bundler port), if the page won't load then there's a network issue.
Solution:
Untick the Disable unless needed checkbox under Mac network settings:
This will put the iOS device in hotspot mode but the mac will continue using the WiFi connection for internet browsing. Don't know what kind of sorcery this is but it works.

Xcode 12.3 keeps freezing

I updated to the latest AppStore release of Xcode (12.3, 12C33).
It worked fine for an hour or two. After that it started to constantly freeze after being open for a few seconds to minutes.
I've tried the following, all without success so far:
restart macOS
clear derived data
tried with different projects
updating to latest macOS 11
Any other ideas or suggestions how to fix this?
Update
I can confirm that this is fixed in Xcode 12.5
I found an answer by Darr on the question "Xcode freezes after upgrade to 12.3" on Apple's developer forums that worked for me:
Unpairing my device connected via network and using only lightning cable seems to have resolved the issue for me.
Xcode > Window > Devices and Simulators > device > Connect via network
After going mad, I fixed this by removing all devices from Devices and Simulators (I had connect via network activated).
For now, it's working fine.
Power off your Apple Watch
Xcode may hang if the host Mac is connected to an iOS device which has one or more companion watches. The hangs occur when the watches aren't fully prepared for development, or if they are experiencing poor wireless connectivity. (72490921) (FB8945320)
Workaround: Power off the watches, or unpair them from the iPhone.
Xcode 12.4 Release Notes
You can force Xcode to freshly prepare a watch for development using these steps:
Force-quit Xcode.
Power-off and disconnect all iOS device from the Mac.
Reboot the Mac.
Launch Xcode, close all projects, and open the Devices and Simulators window.
Power-on and unlock an iOS device and its companion watchOS devices by entering the passcode as required.
Plug the iOS device into the Mac using USB cable.
Check each iOS device and each watch for any pairing request and approve the requests.
Monitor the status of device preparation in the Devices and Simulators window. If Xcode presents device-preparation errors, follow the guidance in the error message to resolve the error.
Once Xcode finishes preparing the iOS device and its companion watches for development, repeat steps 5 through 8 for each remaining iOS device and its companion watches until you verify that Xcode has prepared all devices for development. You may now open your Xcode projects and resume development.
I've been having the same problem. I had an iOS device connected via USB, unplugged it and it un-froze. Then I continued to have issue requiring force close each time.
I then clear derived data and things have been fine. I opened a StickerPack project and also had the same issue. Clearing DerivedData also fixed it.
Clear Derived Data:
Xcode pulldown menu > Preferences > Locations tab
Click the little arrow next to the path under Derived Data.
Delete the entire folder for you project. It will look like "MyAppName-bwonddotztrgkkfexrjxoncvmjit"
See this explanation about whether it's safe to delete DerivedData for your project.
I had the same problem with appstore version and someone advised to install from site, now it works fine. https://developer.apple.com/download/more/
Disable WLAN on my iMac fixes the problem currently.
Hope they will releast a fix very soon.
Xcode 12.3 is unstable and many times it crashes.
I reverted back to Xcode 12 and copied disk image of 14.3 in Device Support folder of Xcode (Contents > Developer > Platforms > iPhoneOS.platforms-DeviceSupport).
This I needed to debug on iPhone device having version iOS 14.3
https://github.com/mspvirajpatel/Xcode_Developer_Disk_Images/releases
I recently had similar situation. My Xcode 12.3 project could not be opened. I tried to open directly from popup that appears on start of the Xcode.
What worked for my was to downgrade Xcode to 12.2 and launch Xcode on new project. And then click my old one.
Maybe it would work without downgrading but I didn't check.
I had this problem too. I fixed it by going Devices and Simulators in the Windows file and disconnecting the iPhone reference I had for my phone when testing and app. Since the phone was no longer connected, its presence seemed to create a freeze.
In my case XCode 12.5 hangs/freezes on startup more or less instantly, right after it opens kind of an empty workspace.
I removed everything that I could imagine that deals with XCode on my machine, but it didn't help.
At the end I just used the hotkey for "Close Workspace" - Ctrl+Alt+Cmd+W
I hit this combo very often, very fast right after opening XCode and it worked!
The strange empty workspace showed up and closed instantly - now I could select other projects and everything works again.
There could be the multiple reasons and in my case reason was source control
preferences > Source Control > uncheck Enable source control
I have these performance problems with the newly updated Xcode from the AppStore to 12C33 (Xcode frozen for many seconds, instability of interface builder, etc.) only with apps which have frameworks added with cocoa pods and when working in the xcworkspace-file. (Integration of frameworks with Catharge even fail with error message 65). I'm running Xcode under macOS Catalina. Don't know what the technical reason could be, hence would appreciate if someone has an idea on this how to fix it.
Update: In the meantime I could fix it:
I eliminated my own devices from the device list and did then a deintegration and a new install of the cocoa pods for the projects. Afterwards I setup my devices again in the device list and all worked well again. Only eliminating and reintegration of my devices as described above didn't work in my case.

Cannot run my App on a device disconnected from Xcode

With the last version of Xcode (12.0), I do not succeed to run my App on my device without usb cable.
When connected, the app is installed and works well, but when I remove the cable the App closes and I cannot reopen it...
Then, I have an alert on Xcode saying "Lost connection to the debugger..."
I tried to modify the Runner configuration settings with Releaser and Debug, but same results.
For info: I am using Flutter sdk.
Please help..

Xcode Project won't run on iOS Device

Xcode gives me this message every-time I try running my app on my iPhone. (Works fine on the simulator.) (And this occurs in every project I have.) (I also just downloaded Xcode again.)
This is the message I get.
App Installation Failed.
Unknown Error Occurred.
How do I fix this error?
Unplugging iOS Device and plugging it back it in fixed it for me.
Alright, it was a simple fix:
Go into Xcode Preferences -> Accounts -> More Info. Hit the refresh icon.
Clean your project. Project -> Clean.
Force quit Xcode.
Reboot Mac and Device.
If you have the same App but downloaded from AppStore, I suggest to remove the App manually from your device, then try to run the new version with XCode.
After following the suggestions in this thread (restarting iPhone, cleaning Xcode project, quitting and re-launching Xcode) and others (setting Team to None then back to my Team) and unplugging and replugging Lightning connector from my iPhone 6 I was still experiencing this problem. Xcode would even display an error that my iPhone 6 was locked, even though it was not.
I was able to fix it by unplugging the USB-A connector of the USB to Lightning cable from my MacBook Pro, then plugging it back in. I'm not sure why that made the difference, but glad that it did resolve this annoying problem.
I have this issue regularly. There are a number of techniques that help me overcome it, including the classic "turn it off and back on again."
One thing that isn't mentioned here is that the iPhone should be switched on, unlocked, connected to the mac and then the app should be run (with the iPhone unlocked). Don't lock it!
Make sure your device name doesn't have any emoji (Xcode 11.0)
if you using vpn services, then you need to turn off vpn. Works for me

XCode finished running application on phone

I can't debug any application on my iPhone. XCode compiles the application, deploys it to iPhone, says it is running the app, and immediately I see the message "Finished running x.app on iDevice". Although the app crashes, it is copied to the phone. After this crash I can start the application on the phone without problems but can't seem to debug any project on the phone. No old projects, no new projects, everything seems to be broken.
There are lots of advices to solve this problem on SO but none of them helped me a bit.
I use XCode 4.6 on Mac OSX 10.8.2.
had the same problem when i changed the project name and the app name.
i've done several times reset to the simulator 'ios simulator' --> 'reset....'.
try it, also try to delete old app in device and simulator, do 'product' --> 'clean', and then try again.
it sounds silly but its working for me when i has the same issue.
Try changing the Version number in 'deployment target' in your App's target in XCode to something else.
Does it run in your Simulator?
Try running in some other device (some other device version,like 4S or 4)
Is the issue with iPad or iPhone or both?

Resources