App closes automatically when not ran from Xcode - ios

I am developing an app using react native.
When I test it on iOS device connected by USB (when I run from Xcode Integrated development environment). It works as expected. But if I unplug USB cable, the app is still on the phone, can be opened but only displays "NameofTheApp - Powered by React native" and shuts automatically after 10 seconds.
I have following questions
Is it normal as it is only on development mode
Is it a bug which i have to fix before releasing app?

This happened because when you run from the XCode, it has two modes.
1. Debug
2. Release
The crash happened because you were running in release while running xcode.
While running in Xcode, edit schema and set the mode as debug as follows:
Choose Product -> Scheme -> Edit Scheme. Change the Build Configuration under the Info tab to debug.

For me I had the 'debug executable' checkmark checked.
This is at Product -> Scheme -> Edit Scheme,
Select Run section on left side, info tab and verify that debug executable is Unchecked

You are trying to run the debug version which is unusable after USB debugging because it got disconnected from the server. You need to run it in production mode. Here is how to do

Related

Xcode 14 is not getting attached to Simulator in Debug mode

While debugging any iOS application, Xcode builds and run successfully, also launches a simulator but it is not able to attach debugger from Xcode 14 to Simulator iOS app.
It throws an error in Xcode:
Xcode console says:
Could not attach to pid : “75997” Domain: IDEDebugSessionErrorDomain
Code: 3 Failure Reason: attach failed (Not allowed to attach to
process. Look in the console messages (Console.app), near the
debugserver entries, when the attach failed. The subsystem that
denied the attach permission will likely have logged an informative
message about why it was denied.) User Info: {
DVTRadarComponentKey = 855031;
IDERunOperationFailingWorker = DBGLLDBLauncher;
RawUnderlyingErrorMessage = "attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the
debugserver entries, when the attach failed. The subsystem that
denied the attach permission will likely have logged an informative
message about why it was denied.)"; }
Tried with re-installing Xcode and Command line tools, but issue persists.
Steps:
Build and run app with Debug executables true
Simulator gets launched
Error on Xcode and it gets disconnected from simulator
Is there a possibility that it can be blocked by any other app, if so how to identify ?
I solved the issue by doing the steps below:
SOLUTION 1:
Edit the scheme
Select Run
Select Build Configuration "Debug"
Select "Wait for the executable to be launched"
Close
Run the app
see the screenshot here
You will receive an error message when you run the app again.
Close the app.
Edit the scheme again and change "Wait for the executable to be launched" to "Automatically".
Now your simulator will work as expected.
SOLUTION 2:
Delete your app folder in Derived Data
/Users/[your username]/Library/Developer/Xcode/DerivedData/
Search your app name folders and delete them.
SOLUTION 3:
Open the terminal and run:
sudo DevToolsSecurity -enable
This command enables the Developer Mode. After running the command you will receive this message: [Developer mode is now enabled].
Sometimes it's happen, when you are trying to build too fast after a build has started.
First of all, quit your current simulator, delete derived data and clean the project, wait until whole processing is complete. Then do some changes / editing if required (as we clean all data) and try running on a different simulator.
Check certificates in key-chain access, if you found any untrusted certificates in key-chain access remove it.
Also if you are using beta version just make sure it is downloaded from Apple official website.
Came here to share my (strange) solution if anybody crosses the same problem with no answers working. In my case, no solution from this nor other SO answers to similar questions worked (cleaning, rebuilding project, updating, clearing derived data..)
My setup is:
Macbook M1 2022 + Xcode Version 14.2 (14C18)
This Xcode version could not attach to any of my apps (fresh new or previously developed) on different simulators (11, 12, 14) with iOS versions 13.7 - 16.2.
Editing scheme solution from answer above was not working also so I ended up in leaving scheme as:
Build configuration: Release
Debug executable Deselected(!)
Launch Automatically
And magically debugging app in Xcode started working even though it's release version with debug option deselected.. Selecting Debug executable again makes Xcode not possible in attaching to app process
Just to clarify: above steps actually makes app to run as in DEBUG mode - Xcode attaches to pid, I can do console logs and breakpoints. This Xcode version behaves opposite than options selected

How to use iOS debug app on iPhone while disconnected?

I made a flutter app and tried to build on iPhone. It works while debugging is connected. But if I try to exit and relaunch the app or disconnect cable, it would not launch again and keeps crashing.
How can I use the app while Xcode debugging is disconnected?
Run flutter run --release in the terminal and that'll allow you to run a production version app on your iOS device without debugging connected.
If you only Start Debugging after this you can disconnect cable and will work. If you after Restart Debugging after this if you disconnect cable app will be crashing. I think you restart debugging.
From Xcode, you can change the Build Configuration of the Run Schema easily. To do this, click on Runner -> Edit Scheme, then go in the Run tab, choose "Release" in the Build Configuration drop down menu. To install the application, run the configuration again.
See Step 4 in this page for screenshots.
Assuming you can already able to debug with cable.
flutter build ios
connect cable
flutter install , if more than 1 device option is available, terminal will prompt you to choose the device for installation.
now you can disconnect cable

Instrument crash at startup appium

Am trying to run appium tool for testing apps. While starting appium server i finished all setting right way. When appium running the app will start at time but suddently it get crash.
Yes.Am using Xcode 6.0 and Appium 1.3.4
Make sure the .app file you are using is build for simulator if you are running appium for simulator and a different build i.e the build for device if you want to run it into real device....This is one of the cause which causes the instruments to crash at start up.
When I create an new project with XCode then generate the app file, it is working fine - I can open the inspector.
But I have a problem when I use an already developed application and the build is coming from a developer profile : I can't open the inspector and instruments crash on startup.
While running the script please start xcode and go in the settings of the mobile device and find developer options. Make sure UIAutomation is enabled there. If it is not then enable it and after it try to run the script again. Surely it will work.

Build with release configuration but automation tracetemplate launch app from simulator show target app not frontmost

Xcode version is 5.0.2 with latest iOS system.
I changed run's scheme build configuration to release, then click Run to build app, after that:
I open instruments and select automation tracetemplate , select target app
Then add an new script
Click Record button
After app started from simulator, the instruments show an error message: Target app not frontmost;
But when I changed run's scheme build configuration to debug, it works fine.
Note: Code Signing using iOS Developer both debug and release.
In XCode (not in Instruments) select Product > Profile, and after if compiles, choose automation. Wait for the app to start, then stop the track: you should be able to run it from the editor. If not, delete the Instruments and iPhone Simulator folders from the Library and restart Instruments.

debugging xcode 4: says it's running application on device, but nothing actually happens

I can't debug my application on my device with xcode 4. The application builds, links and signs and installs on the device but when xcode 4 says "running on Dev iPad 2" nothing happens on the device.
I've quit and restarted xcode, and restarted the Mac. No difference.
The only warning it gives me is "warning: no debug symbols in executable (-arch armv7)". I'm not sure if that's related to my problem.
If I start the application manually on the device, it works.
I created a small test app. It compiled and ran on the device with no problem.
What could be causing this in my application?
I found this could be fixed by deleting the app from the device, and also deleting the provisioning profile from the device as well.
Check the name of your executable in Build Settings - specifically, make sure that Debug and Release versions have the same name. It may be trying to run an executable that isn't there.
Check the Build settings: Strip Linked Product. In my case I had to set this setting to No. After that the warning was gone.

Resources