App crashed in Beta on the device, but not in debug - iphone

I've created a Beta ad hoc delivery profile, and when I press 'build and run' on the device in beta mode, my app crashes after I press a button.
However, when I use the app in debug mode (on the device) it works fine. It also works fine in the simulator and on the device in beta mode (when it's not connected to XCode)
Any ideas what's up here? It doesn't bother me too much since I can debug in debug mode...but I'm wondering when it comes to the submission process, if this will be a problem?
Thanks!
EDIT: Would this happen to be because I've got an entitlements file (dist.plist) with the option 'get-task-allow' unchecked? I tried checking this box but got an error "The executable was signed with invalid arguments"

There are many areas that can be the culprit. You may have an #if or #ifdef DEBUG, or you could have (more likely) some source or xib that is not included in the Beta Target.
You should be looking in the log, whether during its run via Xcode or after when you plug the device back into your Mac and look at the log file using the Organizer window, for more details of the crash. If it is related to clicking on a button, look at the path between the the button's actions set in the xib and the selector in your code. Sprinkle some NSLogs in there to help you out.

I have experienced this with applications that interact with other systems where timing is critical and debug mode affects the timing of the interaction with the other systems. Specifically when screen scraping an IBM mainframe but any time critical application may experience this.

Related

Are logs made with NSLog or CCLog stored in the iPhone? Can I retrieve them?

When testing my iOS application on a device connected to Xcode, logs from NSLog or CCLog appear in the console, which is very useful for me to debug.
When the device is not connected to Xcode, obviously I don't get such logs. And when it crashes, I simply don't know why.
Because of this, I made a question here: Is there an output log like Xcode's available locally in my iPhone?. But I have noticed that those "Device Logs" are not the logs I expected. In fact, they are greatly different from the logs I see in my Xcode console, and none of them reflects a NSLog or CCLog I have done in my project. So I guess I was looking in the wrong place.
Are NSLogs or CCLogs stored somewhere I can retrieve? I don't really understand the "Device Logs", but they really don't seem to tell me anything useful or specific.
Connect your device to your computer and in XCode, windows Organizer, you can see the devices. You can select your device and then click on Console. It should show you all the NSLog statements
Your crashes are logged in your device so you can retrieve them when you connect your phone to the XCode.
1 - Plug it in
2 - Open you XCode and go to Organizer (cmd + shift + 2)
3 - Click on Devices and then on the upper left click on Device Logs.
To add something to the other (pretty standard) answers, here's a solution for which you don't need Xcode: the idevicesyslog utility from the libimobiledevice library can also display all logs.
Bonus: if you have a jailbroken phone, you can install syslogd from Cydia and all your syslog will be saved to a file named /var/log/syslog.
Best option is to run your app from Xcode connected to a real device and look at console output (Shift-Command-Y to display/hide console view by default).
Second best option is to connect device afterwards to your mac and use iPhone Configuration Utility to view your app specific console log.
Third best option is to use some 3rd party iPhone app, which can read console log in the device (when you're on field trip or something). Warning: I made the "Console On Device" app just for this purpose, needed to debug crashes while travelling. It can display app specific logs and allows emailing them.
In my experience, most users never look at logs, so they are useless and just waste time, space, and battery. Some people look at the logs and get worried for no good reason at all, give you bad reviews ("I looked at the logs and there are lots of bugs in the code"), all with no benefit to anyone.
So get rid of the NSLogs. Best to define a macro that does NSLog in a debug build and nothing in a release build. There shouldn't be any NSLog in your source code except for that macro.

Finished Running on iPhone

I am trying to test my app on an iPhone 4S. When I build and run from Xcode, the project is successfully compiled but after that Xcode says:
Finished running MyApp.app on MyiPhone
The app perfectly work on the simulator and the provisioning profile works correctly (I tried to load an empty app and it works).
If I try to manually load the app I get this message:
The Info.plist for application at
/Users/*/Documents/App/AppName/DerivedData/AppName/Build/Products/Release-iphoneos/AppName.app
specifies a CFBundleExecutable of AppName, which does not exist.
Where is the problem?
The connection that XCode creates with the device is rather fragile, and can easily be corrupted if anything goes amiss in the debugging test, most commonly if the developer stops a build, while it is being moved to the device.
I have a routine of things I go through, when this occurs. If one doesn't work, I go further down the list.
Check your signing certificates
: This error can occur if you mess around with the certificates too much. Make sure your current scheme uses the Debug signing when making a debug build, and check in your application settings if the current debug signing certificate is a debug certificate. (Not AppStore, AdHoc or Enterprise).
Reestablish connection with the device
: Look under devices in your Organizer. Check if the device you are using is present and marked with a green bullet. If orange or grey, reconnect the device with the USB. For precaution, wait a couple of seconds from taking the cable out before you insert it. It should make no difference if you eject the cable from your mac, or the part connecting your iDevice.
Reactivate development on the iDevice
: Being unaware why this happends, some devices revert to a non-development stage from time to time. Clicking the "Enable development" under Organizer > Devices seems to clear this off.
Flushing XCode device connections
: Something that often is needed, you can simply shut down XCode (and to be safe, close the iPhone simulator as well) and start it up anew. Deleting the debug application present on the iDevice is also a good idea.
Restart your iDevice
: Tedious as it might seem, restarting your iDevice is sometimes needed, since the pipe held on the device might be corrupted.
Restarting your developer machine
: If everything else fails, a restart of your mac is often required. I have never experienced this error without having it fixed by now.
I hope this checklist will help you through.
Try cleaning the project.
SHIFT+CMD+K
Found the same bug in XCode 9 while running the project on iPhone 5s. Clean the project and it will work.
Clean.
Build.
Run.
It's work for me.
I had similar issue. When I run program on iPad2 it compiles and installs app on device, wait for some time, and display an alert. Then I followed steps below
1) Removed that application from device.
2) Disconnected iPad and tried again.
Then it successfully run in device. If this not resolved your issue, do
Rename your application to some thing else and try to run. It will run. Lastly you can make an "ipa" file with Ad Hod distribution and can test on device.
Looks like you are trying to run a release product on the device. You are probably signing it with production key. Run it as debug.
Maybe I'm totally off with this guess but the last time I got the same message was when I had some required hardware capabilities set in the Info.plist which the target device didn't comply with. (E.g. requiring a camera and trying to run the app on an iPad1.)
I've just finished chasing down a similar problem.
An app that worked on the device (iPad 1) and on the simulator stopped loading on the iPad but continued to function as before on the simulator. When "run" with the device as target, it compiles and then goes immediately to "Finished Running...".
I did all the usual bits - removed the app from the device, ran Product/Clean, removed derived data, shut computer and device down cold, but with no luck. Other development apps loaded and ran fine.
This app uses GameKit. When I removed the gameKit requirement from Info.plist, the app loaded and ran correctly on the device again - including the GameKit functionality (no kidding). When I added gameKit back in, it failed again. When I added the gameKit requirement to other apps, they failed to load to the device as well. It appears that something has happened to the gameKit setting on the device, although gameKit is there and functions as always. I'm suspicious that this one has to do with the state of the sandbox.
I've got to make a few changes to get the app running on the iPhone and I'll test that as well. I'll repost if I sort it out.
Si it seems that XCode build, ran and finished but the app failed to be deployed and was not even copied to the device.
In fact, there should be something in the XCode project that is broken. This is easily corrupted. The best move is to build a new project from scratch. Don't forget to add armv6 support if needed.
It works well for me!
Check the device log
It may occur, that you are using a provisioning profile, which does not allow one of the entitlements, listed for your target.
For example
entitlement 'entitlement-name' has value not permitted by provisioning profile 'Your Profile Name'
For me, the usual culprit is that I have an app store build already on my device.
Different/same version numbers might make things worse. I haven't looked into it too deeply since deleting the version that is already on my device usually fixes the issue.

error from debugger: the program being debugged is not being run

i have run my application in device but application is crashed and print following message
error from debugger: the program being debugged is not being run.
so please tell me what to do?
my application gonna launch properly but not not debugging first time (gonna crash) than from second time i start application work proper without crashing
my application install in device. we can`t debug in device...
The first thing i do when i get that is a Clean All usually solves that. If you don't see the Clean All button right click your Xcode toolbar, customize, and drag the Clean All button to your toolbar from there.
-Check that the provisioning profile installed on your device haven't expired (would see a red dot in the organizer - Window->Organizer).
-Try restarting XCode.
Do you mean device? If so then it could mean the device is not launching the application correctly. Make sure your developer profile and everything in the build settings is correctly set. This may sound obvious but also make sure the device is unlocked and open.

ad hoc version exits immediately when try to load the app to memory

I have an app, it worked well on simulator, but the ad hoc version always exit after Default.png launched and started to run on my ipod.
I try to check if there is any problem concerns
• Case sensitivity.
• Read/write bundle files.
• Memory Leak
But everything look likes Ok. The app occupies memory no more than 800K.
I set the breakpoints anywhere but it still exits before debugger reaches them.
No crash reported.
There is an interest thing if I set 1 or more NSAlertView and show in viewDidLoad of rootController(UITabBarController), it will work correctly!
It is my first time to use UITabBarController, I always construct my self's multi viewcontrollers.
I am not sure if this problem relates to the usage of UITabBarController.
My Xcode 3.1.4
os x is 10.6.5
I have sticked on for 3,4 days.
Welcome any comment
Thanks
interdev
This sounds like a provisioning issue. It will do this exactly if there is a certificate problem - display the load screen - then just abort. This happens, for example, if the certificates are expired.
It will however tell you that this is happening on the console. Run with your iDevice connected - open the Organizer - view the console - try running. See if it complains about the certificate on launch.
If not - the console will probably tell you something...
Usually your Ad-hoc build settings will specify an Entitlements.plist file which disables debugging via the get-task-allow setting. This is to stop your users from being able to debug/inspect memory etc. while they are testing your app. If the app works with your Debug build then this is the most likely explanation.

iPhone Device Debugging

Is it possible to actually use the Xcode debugger when running an iPhone app on the device rather than the simulator? i.e., can I have the device stop at breakpoints that I set in my code and step through the code as it runs on the device?
EDIT: I should mention that I am a registered developer with Apple and have a valid certificate. In fact, I can build and run iPhone applications on my device just fine. However, even in Debug mode, my application will not stop on breakpoints or output to the console when I run it on my device. If it helps, my application will function normally in debug mode (e.g., stopping at breakpoints) when I run in the simulator.
EDIT 2: I've tried resetting my phone, completely removing and reinstalling Xcode, creating a new project, changing all the settings mentioned in the answers on this page (as well as others), cleaning and building my project, Build and Debug... If I click Pause, it says "Error from Debugger: Quit". :( Maybe I'll try to debug on this device using Xcode on another computer and see what happens.
EDIT 3: Well, I tried using another computer using a fresh install of Xcode in a new project, and I still can't get device debugging to work. I have a suspicion that it's my iPhone or cable perhaps? I'd like to think that I'm not so incompetent that I've missed something so embarrassingly obvious, but I've double- and triple-checked all of the suggestions mentioned here.
EDIT 4: FINALLY got device debugging to work. I have a feeling that something low-level on my device was causing issues...nothing I did worked on my system. However, I installed Xcode on another system and device debugging on the same device (with the same cable) worked flawlessly. Directly after that, device debugging began working on my original machine, leading me to believe that some strange hardware flag was screwed up and somehow "reset" on the second machine. In any case, it works now... Thanks for all the help. :)
Also, I'm unsure if it's better to leave this question unanswered or pick the most "helpful" answer...
Yes -- just use a device build. You have to get certificates and provision it.
This is a good description:
http://boga.wordpress.com/2008/07/16/debugging-ipod-provision-profilescertificates/
Make sure to start debugging by pressing "Cmd-Y"... and not "Cmd-R" :-)
You may try last trick in case nothing can help.
If your application launched successful on your device from XCode but did not stop at breakpoints - try press "pause" button after start in debug mode. If you will see application paused properly (do not react to user's action) add new breakpoint then press "run" to continue application execution. In some cases it may helps to stop at new breakpoint.
Yes, just set your project to build for the Device.
If you need to setup debugging for jailbroken iPhone (up to 2.2.1) (not pay 99 to Apple yet) follow next steps:
Install MobileInstallationPatch for your iPhone via Cydia (use Search Tab)
Switch off PROVISIONING_PROFILE at XCode: Go to /Developer/Platforms/iPhoneOS.platform/Info.plist, add next keys:
<key>PROVISIONING_PROFILE_ALLOWED</key>
<string>NO</string>
<key>PROVISIONING_PROFILE_REQUIRED</key>
<string>NO</string>
You may also add these keys to any
project particularly at XCode, Project
Build Settings, User-Defined
variables.
Add key to your project Info.plist at XCode
SignerIdentity = Apple iPhone OS Application Signing
Don't forget to install and add to your project settings self-signing certificate from Apple
http://developer.apple.com/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html#//apple_ref/doc/uid/TP40005929-CH4-SW2
"Build and Go", you can connect iPhone and start debugging.
Important! You may need to install and launch at least one legal app (any free one) from App Store first (before "Build and Go" step). Otherwise your application will be successfully installed by XCode to your device but may not be launched. Try this troubleshoot first in case of problem with app launching.
Yes. Debugger and performance tools work fine on the device. That's where I do most of my debugging.
Xcode>preferences>debugging uncheck load symbols lazily
fixed the breakpoints not holding in device problem for me.