App opens then immediately closes - iphone simulator - iphone

When I "run" my app from XCode the simulator comes up and the app attempts to run, it animates to a black screen for a second and then the app closes immediately.
The app was running fine before and now suddenly won't work.
There is no output on the console, no errors or anything and the app isn't crashing (as far as I can tell).
I have tried deleting all my user specific files in the xcodeproj package, but this hasn't changed anything.
Is there any other reason why this would happen? How do I fix this?
Thank you.
ADDITION: NSLog(#"something"); in the application:didFinishLaunchingWithOptions method doesn't show up on the console.

A reboot of my Mac seems to have fixed it. Thanks guys for your help. :)

if you are using a new Xcode(4+) and previously 3, there may be issue. Try setting the Architectures (Target -> Build Settings -> Architectures) to support armv6 too, presently it supports armv7(standard) only. If my memory is not deceiving me I guess I had such an issue.

Related

Xcode 4.6 builds, runs and finishes instantly (simulator iOS 6.1)

In xcode, I tried to add a tap gesture to my app and when I built it, it started a problem with Xcode. It goes from building, 'running on iPhone 6.1 simulator' to 'finished running on iPhone 6.1 simulator'.
If the simulator is closed, it starts up with a black screen and you cannot click the home button etc. If open, nothing happens, the app doesn't install but the simulator doesn't crash.
I have tried the armv6 architecture 'fix' but that didn't work. I have also cleaned the project and project data. I have reset the simulator multiple times as well.
If I add the old files to my new project, it works up to a point (I copy and paste old files into new) but then the same happens.
Thanks for your help in advance!
NOTE:
New blank projects build and run fine.
EDIT: It still didn't work after undoing my previous actions, and the simulator is responding according to Finder, although the screen stays black
–––––––––––––––––––––––––––––––––––––––––
UPDATE
I had a folder named 'resources' in my application, imported as a reference which, following links from the thread #arthan.v supplied me with fixed the problem. What I did was rename the folder to files and reimport it.
Thank you so much, I spent 2 days trying to fix it before now!
Click the Center Button in View on your right hand side of Xcode.
In your Bottom bar, you'll see error: failed to attach to process ID 0.
Check these error: failed to attach to process ID 0 and Xcode compiles my App, but can't run it in the simulator
This sometimes gets fixed by these steps:
iOS Simulator > Reset Content and Settings ... > Reset
Xcode > Build and Run
I experienced the same issue after I had re-organized some code and renamed the workspace and project. Eventually realized there was an old version of my test app on the simulator's homescreen. I delete that and then everything was building fine again.
You might need to add the device to the provisioning profile. I experienced this on Xcode 6 and a real device.

XCode Locks Up When Launching the iOS Simulator

Lately when I have been deploying any iOS application to the simulator (iPad or iPhone), XCode locks up (Not Responding) and the simulator simply displays a black screen. I have to force quit both.
Steps I have taken so far towards a resolution:
Clean
Reset the Simulator
Deleted the simulator folder
Reinstalled XCode from the App Store
Reinstalled XCode from the developer center
Has anyone else encountered this? Any suggestions for a solution?
Other info:
OSX Lion 10.7.3
XCode 4.3.2
Shibboleet
Thanks in advance for any help.
I had this problem and was able to continue by:
1) Edit the run scheme by clicking on the first part of the App name to the right of the "Stop" button to bring down the scheme list and click "Edit Scheme..."
2) Click on the Run item and change the debugger from LLDB to GDB.
3) Run
I think the problem was that I validated the settings and it offered to automatically change the debugger from GDB and LLDB and I clicked "OK" because the advisor message sounded very self-assured.
Enjoy.
Under Scheme, go to edit scheme, and change launch from wait for App.app to launch to automatically under the Info tab.
EDIT: If you upgraded Xcode, make sure the old separate simulator is uninstalled.
hmmm, weird simulator, instruments issue i had once would work when i command-tabbed back and forth. try deleting derived data?

App Icon Won't Change In iPhone Simulator

I had an old app icon in xcode that I had just attached to the program to see how it looked in the simulator. I made changes, deleted the images, and replaced them in Xcode. However, they are still the old ones in the simulator. I tried resetting it and everything. Does it keep a cache somewhere?
EDIT: Solved by cleaning project.
Have you tried cleaning?
From the Xcode "Product" menu, choose "Clean" or "Clean Build Folder" if you hold alt/option.
If "Clean" does not work, try this:
Reboot the device
Kill the app before running it from Xcode.
Those works in my case.

Can't make Xcode 4 run a barely empty project using SDK 4.2 (runs fine in 4.3)

I created a blank NavBar project and only touched a couple lines or so on one of the view controllers. I tested it fine in the 4.3 iPad and iPhone emulator but can't make it work for 4.2 at all. I get an error saying:
The selected run destination is not valid for this action.
This is what I have on my project settings:
Usually in XCode 3 that was all I needed to change but I guess I'm missing some setting in XCode 4.
What could this be?
#pokstad, you are right. I was looking at the wrong place indeed!
Choosing the target and changing the SDk there did the trick.
Thanks!
I really had troubles with this and none of the hints helped.
Finally I got an error message that pointed to an old file in the build folder, in the end a simple clean did resolve my issues (shift+cmd+K). It compiled fine. So remember to clean your current build after you changed the build settings in Xcode4.
This may be obvious, but at that moment it wasn't obvious to me.

How do I type using my keyboard on the iphone simulator?

I used to be able to type with my real mac keyboard after launching the iPhone Simulator. Typing with the on-screen simulator keyboard is just horrible when testing with large amounts of text.
No matter what I do, I can't get my keyboard to type anymore inside the simulator. Even if I have "Simulate Hardware Keyboard" switched ON, it just won't type anything. Can someone please tell me what I'm doing wrong? Is there no way to type using the real keyboard anymore?
Try trashing the iPhone Simulator preferences file. When my iPhone Simulator stopped responding to keystrokes, this fixed it.
Quit the simulator.
Go to finder and press (command+shift+G) then navigate ~/Library/Preferences.
Move com.apple.iphonesimulator.plist to the trash.
Try launching your iPhone app in the simulator again.
Deleting com.apple.iphonesimulator.plist did not help me under Xcode 6.0.1.
Probably, it worked in old Xcode.
But, what works perfectly for me under Xcode 6.0.1, it is new hot Keys in iOS Simulator:
Shift-Command-K Connect/Disconnect Hardware Keyboard
Command-K Toggle (Show/Hide) Software Keyboard
And, you know, I really suffered for last 2 months, until found it, and it is very convenient now))
Don't trash the iPhone simulator preference files. There's no need to do this.
Look in the simulator's menu Hardware ➔ Keyboard. The menu options are:
iOS Uses Same Layout as OS X
Connect Hardware Keyboard ⇧⌘K
Toggle Software Keyboard ⌘K
Ensure option 2 is checked.
If it's already checked, uncheck it then check it again (you'll probably want to learn the keyboard shortcuts).
If you find that this hides the on screen keyboard, but you also want this to show, use option 3 to toggle it back on.
If rotating the simulator seems to stop the keyboard working, toggle option two off then back on – this seems to resolve it.
I am using iOS Simulator Version 7.0. While the simulator was running I went to iOS Simulator->Reset Contents and Settings... and reset the simulator from there. That seemed to have done the trick for me. Hope that helps.
This is because you have used changing the orientation of simulator using keyboard shortcuts. Just press cmd on the mac keyboard then start typing.
All I needed to do was quit the simulator and launch it again
MY PROBLEM WAS KEYBOARD IS SHOWING AND KEYSTROKES NOT DETECTING. AND I FOUND THE SOLUTION:
You don't need to quit the keyboard.
Try Hardware->Keyboard->Connect Hardware Keyboard directly
Removing com.apple.iphonesimulator.plist worked for me too, but I had to locate it inside the hidden folder /Users/[yourusername]/Library/Preferences/
Shell / Command-Line / Jenkins / CI:
sh "plutil -replace DevicePreferences.${deviceID}.ConnectHardwareKeyboard -bool NO $HOME/Library/Preferences/com.apple.iphonesimulator.plist"
sh "plutil -extract DevicePreferences.${deviceID} xml1 -o - $HOME/Library/Preferences/com.apple.iphonesimulator.plist"
The Device ID can be found via xcrun / simctl, based on the devoce name:
xcrun simctl list | grep ${simulatorDeviceName} | sed 's/).*(.*//;s/.*(//'
I encountered the same problem and tried a lot of different ways which worked mostly but never for sure. Ultimately, I found this. https://stackoverflow.com/a/26057011/1463604
If you are developing a React Native app and you cannot refresh (⌘R) or enable remote debugging (⌘D) from the iOS simulator, while other keyboard inputs work, make sure you are running a debug build configuration. You can check this with:
Product -> Scheme -> Edit Scheme -> Run -> Info -> Build Configuration -> Debug"
I got this tip from here.
Just restart Simulator (close and open the app).