Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 4.5 doesn't run / load app on simulators or device

I'm running Xcode 4.5 on OS X Lion 10.7.5 on a Mid 2007 Mac Mini. I've run into this problem before where the simulators as well as actual devices don't run the app when I build. I'm writing a couple of different applications using Phonegap 2.1, HTML, JS, Jquery Mobile. I've reinstalled Xcode 2-3x after following the instructions from OSX Daily and SO How to fully remove Xcode 4. This worked for a while, but then my 300gb SSD drive died & I had to reinstall the OEM 120 GB hard drive & reinstall Xcode & Phonegap (both had revved versions since the drive had been uninstalled). Now I'm unable to get Xcode to start the simulators or download to my iPhone 4 again. I completely uninstalled Xcode again yesterday & reinstalled. The first time I tried to build, it took a long time downloading the 5.1 simulators (* see edit below), but finally "finished", but still didn't run them. Tried downloading to my phone, again nothing.

Since this is the third or fourth time that this has happened, I'm wondering what I'm doing wrong. Obviously I'm missing something because I don't see this problem being screamed about on the various support forums like here, Google, or Apple, only bits & pieces here and there.

As a test, I created a bare bones PhoneGap app that has nothing in it but whatever PG creates, and it doesn't run the simulators or download to my phone. This same method used to work just to test the system, but no longer. It builds fine, and darkens the square "running" button for a few seconds, and then the button lightens again like you've stopped the app, and that's it. No error messages, no build faults, nothing.

Intel is replacing my SSD drive, so I'm going to have to go through this all over again when it gets here, unless I can get a working copy running on the hard drive, then clone it with Carbon Copy Cloner so I can just copy that onto the new drive.

Any help would be greatly appreciated, I'd really like to not have to deal with this on an ongoing basis.

*Edit: I originally deleted this question because I thought I'd done something stupid, I realized I'd downloaded the documentation for the simulators, but not the actual simulators. I've since downloaded the 5.1 simulators and I'm still experiencing the same problems.

like image 300
delliottg Avatar asked Sep 26 '12 20:09

delliottg


People also ask

How do I run an iOS app in a real device from Xcode?

You may connect a real device to your Mac using a cable, or for iOS or tvOS apps, connect it over Wi-Fi after you pair it with Xcode. For macOS apps, choose a scheme, then click the Run button in the toolbar. You can also run SwiftUI apps in the simulator or on a device using the controls in the preview.

Which command is used to run the app on iOS simulator?

If you wish to run your app on an iPhone SE (2nd generation), run npx react-native run-ios --simulator='iPhone SE (2nd generation)' . The device names correspond to the list of devices available in Xcode. You can check your available devices by running xcrun simctl list devices from the console.

How do I run Xcode on simulator?

Open Xcode and click Menu > Xcode > Preferences > Select Components, and then choose the simulator version you want to download. When a simulator is opened from AppStudio, AppStudio Player automatically installs (if necessary) and opens in it.

How do I change generic iOS device to simulator Xcode?

Open Xcode, Goto Preferences, Select Component. Click on Simulators of your choice then it will start the process of download & installing the simulators.


3 Answers

I had a similar situation happen when I was trying to run my first HelloWorld app for Phone Gap iOS.

It turned out for me the executable was missing from Edit schema dialog. Very odd since it ran fine a few times and then it stopped working until I found this dialog.

You can find this dialog in Product -> Edit Scheme --> Info --> Executable (make sure it is not empty).

Although, you found your solution this is a quick check that may help others.

like image 193
Ronbo Avatar answered Oct 12 '22 22:10

Ronbo


before follow please read my edited comments below

  1. Quit XCode
  2. Quit Simulator
  3. go to all the path in the image and delete all these folders enter image description here

  4. Open simulator and in iOS Simulator menu Reset content and settings. Reset it

Start XCode and you should not worry now.

EDIT

I again got issue few days after the error so I tried the steps above but nothing happened :(, 2nd time i reinstalled the xcode after deleting everything related to xcode and simulator and made a new project. For a clean project application run well but again copying all files from older project in same manner, again faced the same issue. So how i fixed that?

You might still need to follow the steps above, not sure these works or not. But i tried to find that the issue starts at the time when i was copying files from old project.

While adding files to the new project a dialog box appears to ask location of existing files and if you see folders option with 2 radio buttons then by default Create group of any added folder (if needed) is selected. Everything went well until i did not touch these options.

Green: Default, Red: user selected

copying existing files to xcode project

But problem started appearing again when for a Resources folder I used the 2nd radio button that says, Create folder references for any added folder. When I removed this folder reference and cleaned project, application ran well. Adding same folder with Create group of any added folder (if needed) option worked also well. Whenever I chose 1st radio button, application showed same issue.

Create group of any added folder (if needed)

and

Create folder references for any added folder

I believe you understand difference between these 2 options i.e. folder colors to yellow and folder colors to blue! Hope this helps all other people also but it is really frustrating and i request apple to fix this bug ASAP :( :(

like image 36
Vaibhav Saran Avatar answered Oct 12 '22 23:10

Vaibhav Saran


So, I'm not sure this is the actual answer, but I seem to have found a procedural sequence that works.

First: I completely deleted Xcode (again), reinstalled it from scratch (again), and updated all the simulators except 4.3 as well as the command line tools (Xcode > Preferences > Download > Components > All simulators except 4.3 & the command line tools) again.

Second: I also reinstalled PhoneGap 2.1, but I'm not sure this was necessary, it was more of a scorched earth campaign. The problem in Xcode seemed to stem from the Scheme, I kept getting Schemes named "CordovaLib" instead of my project names. If you click on "CordovaLib" on the Scheme/Simulator buttons (the top left hand side is where the available schemes & simulartors are listed, right next to the build & stop buttons), and change the scheme to the project name that helps.

Third: You need to make sure that the location for your app is set to "unique". Do this at Xcode > Preferences > Locations > Locations (not Source Trees) > Derived Data > Advanced > Build Location == Unique > Done.

It seems to help to open the projects in Xcode instead of launching them from Finder, but I'm not convinced that's true, it just seemed to work better, but I could be imagining it.

If I do this on projects I used to have problems on, I can now download them to the simulators & my phone.

This didn't get any responses, but maybe someone else will find it useful.

like image 33
delliottg Avatar answered Oct 13 '22 00:10

delliottg