How can I attach to released in the testflight application to debug? - ios

I have XCode, Device with the application installed via testflight, Release IPA, dSym.
Simple attach to process fails.
error: attach by pid '66475' failed -- unable to attach
I want to debug using IDE. Is it possible?

You can't do this. For the debugger to be able to attach to a process, the app binary needs to be signed with a special entitlement (get-task-allow). Otherwise the OS will deny the debugger's ability to attach - as you have seen. The Store doesn't allow you to submit apps that have this entitlement, so you can't debug released versions of your app. OTOH, nor can anyone else, which many folks view to be a good thing...
You can make a "DebugRelease" Configuration that uses the same settings as your release build but adds this entitlement by hand if you need to debug the code that comes from the Release build - in case you have bugs that only show up in the fully optimized build, for instance. You just can't debug the Store version.

Related

Firebase Debug View Live Events from app installed from exported ipa files

What I want?
I want to see live events on Debug View of Firebase Console where the iOS app is to be installed from an exported ipa file. I have only two distribution method options to export my ipa file
Ad-Hoc
Development.
What I did?
I enabled debug mode following https://firebase.google.com/docs/analytics/ios/events#view_events_in_the_xcode_debug_console.
Also edited Run Scheme to Release Build Configuration with Debug executable checked.
What is the result?
I am not able to see any event on Firebase console after testing app installed fromipa exported for Development as well as Ad-Hoc.
My Question:
Is is possible to see live events from an iOS app installed from an ipa file?
If YES, what the exact configuration is to be used while exporting for Ad-Doc and (OR) Development?
I too had to struggle with this and found a solution by setting the -FIRDebugEnabled flag in AppDelegate so that whenever you want to export the build it will not be ignored. I've also added the DEBUG macro so that it will only fire for DEBUG.
#if DEBUG
var newArguments = ProcessInfo.processInfo.arguments
newArguments.append("-FIRDebugEnabled")
ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")
#endif
Also, a very important note is to add these lines of code BEFORE initialising Firebase! e.g. FirebaseApp.configure()
If not, it will fail gracefully. :)
I then exported the .ipa for Development and voila. I haven't tried using the Ad-Hoc option but I think it might work as well.
Also please consult the below link:
How to debug Firebase on iOS AdHoc build
I doubt if it's doable on a non-jailbroken device. When you launch an app from SpringBoard, it doesn't make sense to me that SpringBoard would allow additional parameters, because that's not the way how it's designed. The parameter is likely come from a debugger, which means it's debug only.

Ios share extension does not work when installed by testflight but works installed by xcode

Installed with testflight the application does appear in the list of target applications to share an image with. When I select my application icon in the list I do get a normal Post dialog. After pressing "Post" in the dialog the application does open but nothing else happens.
When the same version of application is installed with xcode the shared file is delivered and the application displays the shared image.
I am not even sure how to debug such an issue as the application installed by testflight does not appear in the list of installed applications in xcode Devices window. Nothing that I can find in device logs either.
Please suggest any approach to troubleshooting the issue.
Update: I found a way to get much more detailed logs from device than the one provided by xcode's "Devices" window: deviceconsole utility. This gives at least some information to approach troubleshooting.
Update 1: It turns out that the application installed through ad hoc ipa file exported from the same archive that was submitted to testflight shows the same problem. This allows much quicker testing turn around.
This answer indicates that the problem can be caused by "Deployment Target" of extension set above the ios version of test device. I did try different combination of this setting in the application and extension, nothing helped thus far.
Update 2: I created code-level support request with apple for this issue and provided full source of the application to them. After few months of apathetic communications they concluded that the problem is due to a bug and suggested to create report Apple Bug Reporter. I did that and after another few months of more apathetic communications the issue was promptly closed on the basis that the application does not crash. Frustrating, but I still need to resolve the problem, now looks like without help from vendor.
If the deployment target is higher than the version number of the actual phone, your code cannot run. So the only choice is reducing the deployment target of the extension to be the same as the app.
I’d check if you have somehow set different deployment targets for debug and release.

Debugging not happening on iOS device XCODE8

I am not able to launch my app on my iphone device and debugg. That is, my debugger does not get attached when I am using my device for debugging. How do I enable that?
The error states could not attach to process...
how do I enable debugger for xcode8 for my device? It is an iPhone iOS 10
If you are getting the "failed to get the task for pid" error, that means that your app does now allow itself to be debugged. On iOS, by default, the debugger is NOT allowed to attach to an iOS app. When you build the debug configuration of your app, Xcode automatically adds the correct entitlement, and the debugger is allowed to attach. The release configuration typically does not add this entitlement, so you generally can't attach to release builds.
For more info on this entitlement, see for instance:
What does get-task-allow do in Xcode?
Without looking at your project it's hard to know what has gone wrong, but this might give you a place to start looking.

How do you debug an issue with a release mode build in iOS?

I am working on an iOS app and I have noticed a bug that is only reproducible when the app is built in release mode. The only way I have found to run a release mode app that I have built is by building an archive, signing it with my debug profile, and doing an ad-hoc deployment to my device. Using this method however I can't attach with a debugger, and I'm not even sure if I could attach it if it would work well after the release build had run the optimizer on the code.
Does anyone know of a good way to debug an issue that is only reproducible when an app is build in release mode?
Normally Debug builds have optimisation disabled (-O0) to make debugging easier, whereas Release builds have optimisation enabled (-O3 or -Os), which makes the code run much faster, but also makes debugging harder (but not impossible). You can just go into the build settings in Xcode in the Debug configuration and temporarily turn up the optimisation level - this will keep all the other debug goodies (symbols etc) but hopefully also flush out the Release mode bug. (Don't forget to reset the optimisation level to -O0 in the Debug configuration when you're done!)
Go to "Project" command in an Xcode application menu and chose "Edit Scheme"(Shortcut: ⌘< )
Select "Run Project name" in left pane
In right pane, under "Info" tab change "Build Configuration" to "Release"
You can not run an app in release mode while have having debugging turned on. That is not intended.
When running an app in release mode you have to find a different way to observe the behaviour of your app (e.g. using alerts).
Additionally you will have to trust the distribution profile on your device. Xcode will notify and guide you with an alert message on the first run.
To debug an iOS application in release mode modify the settings:
Build Settings -> Deployment -> Deployment Post Processing -> Release -> set value as "NO"
Set 'Deployment Post Processing: Release' value as 'No'
I had to briefly turn on automatic signing in order to accomplish this. You aren't able to build directly on device with an iOS Distribution certificate (you need an iOS Development certificate) and you can't release to the App Store with an iOS Development certificate (you need an iOS Distribution certificate).
My debug mode was configured to use an iOS Development certificate to build directly on device. My release mode was configured to use an iOS Distribution certificate to allow the app to be installed on all devices. In order to run in release mode on device I switched to automatic code signing briefly to test. Once I was done testing, I used git to revert to the previous Xcode configuration.
Not the most elegant way, but it got the job done.

Ad Hoc test install failing

I have a project I can successfully build/install using developer/debug to a device or simulator.
When I make an ad hoc build i can build-run onto the simulator, but not onto the device.
I'm trying to perform a direct install because the ad hoc installed app is crashing (nil added to array) where the debug version is not.
I also have tried to attach to the running ad hoc installed app. The app will run indefinitely (but crash if i perform a particular use case.) But if I attempt to attach to the running app, it will crash.
It happens to be a Box2d/Cocos2d application - but i don't have any reason to think they are the cause. Xcode 4.3.2, iPhone4 iOS 5.1
the message when build-and-run is attempted:
error: failed to launch '/Users/bshirley/Library/Developer/Xcode/DerivedData/foo-bar-evrbckppmbsspqhezhleaxkmymxn/Build/Products/Adhoc-iphoneos/foo-bar.app/foo-bar' -- failed to get the task for process 6892
Anyone have some insight into the problem or tracking it down?
Edit, I thought I'd add some key words so searches might be more likely to find:
One issue with diagnosing the post-mortem crash was that the stack trace was not symbolized in the Device Logs of the Organizer in Xcode. That left me with 6+ deep stack trace w/i my code and no real reason to determine where it actually was.
If it is a release build, the app will (in a default setup) have a flag preventing outside processes from hooking into it (for security reasons). This includes the debugger. If you try, you will get the exact error message you indicate.
EDIT Sorry, small error. A release build alone will not cause this. A build with an adhoc certificate will cause this, because it is meant for final install on a device (not debugging).
If borrrden is correct (and it seems reasonable that he is, connecting one app to a signed running app would be a security issue), I can't actively debug the adhoc app.
The most useful thing i found for tracking down this issue, is Build Settings -> Symbols Hidden by Default - this value is only NO for debug. Setting it for NO on adhoc allowed me to see the entire stack trace when inspecting the Device Logs in the Xcode Organizer.
That led me to the particular method that was invoking the crash causing issue. Which led to the question why wasn't it crashing in the debug build. Didn't have time to diagnose that, just fix the problem.

Resources