Breakpoints not being hit in Xcode 7 - ios

I have an Xcode project which includes a sub project. After upgrading to Xcode 7 breakpoints in the sub project are not hit nor can I step into functions calls of the sub project. Some breakpoints do get hit but they just show assembly for the call so it seems the sub-project is not being symbolicated correctly. I've checked all the usual sort of things i.e. is generating debug symbols, build configuration on debug is not release and things of this nature shown in Xcode project settings. Anything else I might be missing? In Xcode 6.4 this was not an issue.

This was an issue with not having the correct debug information format set in the hosting project. I resolved by creating a dummy/test Xcode project and comparing the debug file format detailed for each configuration to that in the trouble making project changing the debug information format to match the dummy/test project.

In some case this issue can be related with broken link between the breakpoint and the Project/file.
So try to remove the breakpoint and re adding it.

Related

Breakpoints not hit in Xcode (9.3)

None of my breakpoints are being hit.
I've tried the following:
Deleted Derived Data directory
Cleaned build folder
Deleted the xcuserdata directory
Made sure build configuration is Debug and Debug executable is
ticked
Made sure Generate debug symbols is set to Yes
Changed Optimization level to No optimization
The breakpoints are still not being hit.
Had this exact issue today - breakpoints in Swift projects were failing in XCode 9.3 (objective-c ones were fine).
The following fixed it:
change Optimization level under the Swift Compiler - Code Generation submenu. Move it from -O to -Onone
src: https://www.reddit.com/r/swift/comments/89nht7/breakpoints_not_working_after_updating_to_xcode_93/?st=jftp4n02&sh=49688058
Try below steps
Go to debug (top bar in Xcode)
Debug Workflow
Always show Disassembly - uncheck it
None of the existing answers worked for me so I dug into what was going on. By forcing a breakpoint in code (i.e. an asm("int3;") instruction) I was able to see that the symbols weren't loading. Naturally breakpoints depend on symbol information being loaded.
The code for which my breakpoints weren't working was in a C++ framework and the framework has a build setting called "Strip linked product" which was defaulted to "Yes" for both release and debug builds. By setting this to "No" for the debug build (and doing a full rebuild) my breakpoints now work again.
I had set Deployment Postprocessing to NO in my Build Settings for my target. Setting this to YES made my breakpoints work again.
In my case problem was in the Debug information format setting. It was set to DWARF instead of DWARF with dSYM File. Reseting it to the default value solved the problem.
I was facing the same issue and this solution works for me:
Open project settings
Optimization Level
Under "Swift Complier - Code Generation" Section
Set "Optimization Level" to No Optimization[-Onone]
Refer attached screen shot
Check Preferences > Behaviors > Running > Pauses options.
The Show for navigator and debugger must have ticked.
Select breakpoint tab in XCode delete all the old breakpoints.
Then add new breakpoints. It worked for me.
None of the previous solutions worked for me either. I had an issue where all my breakpoints would work except on a c++ project among other projects in an xcode (9.4.1) workspace. For that project, I noticed that only some breakpoints were working. Digging deeper showed that it was breakpoints made within private methods that did not work.
After a good deal of investigation, I found my particular issue. In my main project, I had declared some static objective-c initializers in a header file. Not entirely sure why, but after I moved these to the implementation file where they were referenced, my broken breakpoints started working again. Hope this saves someone some time.
Setting Build Active Architecture Only to Yes helps me.
Set Deployment Postprocessing to "Yes" in my Build Settings for my target.
Debug -> Debug Workflow -> Always show Disassembly -> Uncheck
Quit Xcode and reopen the Xcode.

Xcode 8 Breakpoint in file not working

I have one file,SignInViewController.swift, in my Xcode project that out of nowhere has begun not stopping on breakpoints. I have a breakpoint in viewDidLoad() and a few in viewDidAppear(). I have several print() calls in both functions to make sure they are executing. Breakpoints work fine in other files including AppDelegate.swift.
There was a point when I trying to figure out what was wrong where I noticed that while I was building the project an error would appear saying Invalid redeclaration of 'signInViewController.swift' and then go away before the build finished and the app would run fine, except for the breakpoints in the file. signInViewController.swift is the old name of the file from months ago before I renamed it to SignInViewController.swift. I haven't seen it before until the breakpoint issue occurred and since I have cleaned the project's build folder and Xcode's derived data I have been unable to replicate. I have a feeling that it is factoring into the problem but I am not sure how/why.
Anyways, here is things I've tried already. Most of them are just for breakpoints not working in general but I figure I should list them anyways even though that is not the case:
Clean Project
Clean Build Folder
Clear Xcode's DerivedData
Making sure breakpoints are enabled (Cmd Y)
Build Settings are set to Debug
Always Show Disassembly enabled and disabled
Debugging enabled in run config
Any help would be very much appreciated.
UPDATE 1 (still no luck):
Tried deleting the Xcode preference as suggested by neprocker's answer here
UPDATE 2:
I have isolated the breakpoint issue to just viewDidLoad() and viewDidAppear() breakpoints elsewhere in the file are working.
UPDATE 3:
Isolated to a specific block of code in viewDidLoad(). viewDidAppear() still not working though.
I had the same problem with an old project. Select Product(located at top menu bar) -> Scheme -> EditScheme and I solved this issue by clicking on "Debug Executable", as shown in Picture. Maybe this will help someone else too.
In my case breakpoint was not hit in just one callback, so I changed "Swift Compiler" "Optimization Level" to "No optimization" in project target build settings for debug, and it started working in Xcode 9.3 as well as AppCode.
Below patch is work for me. From the menu bar, select Product -> Scheme -> Edit Scheme -> Select Profile -> Set Build Configuration to BUILD. Please review below-attached screenshot.
I was also dealing with the same issue in xcode 9.
I resolved the issue in below ways:
Remove XCode defaults Using below terminal command
defaults delete com.apple.dt.Xcode.LSSharedFileList
defaults delete com.apple.dt.Xcode
Clear(or delete) Xcode's DerivedData from
/Users/[Your Mac Username]/Library/Developer/Xcode/DerivedData
Delete(or uninstall) Xcode.app from Applications and then restart PC
Install fresh copy of Xcode 9
[Mandatory] Set user permission to your app project like
chmod -R 777 "/Users/[Your Mac Username]/Desktop/TestApp/"
[where TestApp is the app project keeping on Desktop]
Open the project and check Build Settings are set to Debug
Make sure breakpoints are enabled and set debug point in your code
I'm not really sure how this ended up fixing it but I isolated the issue to a specific block of code in viewDidLoad(). Then I commented out that code and built and ran the project. Then I uncommented the code and built and ran it again and the breakpoints worked.
What helped for me was deleting the file Breakpoints_v2.xcbkptlist which is located under the project directory (*.xcodeproj) in the directory: xcuserdata/Fred.xcuserdatad/xcdebugger (replace "Fred" with your username). Use a terminal program to go there.
I solved this by going to my Xcode project's 'Build Settings' and setting 'Generate Debug Symbols' to 'Yes'
Sometimes the values may have changed in Xcode userdefaults itself,
At times, I had similar issue with debugger stopping at stacktrace
Few ways to clear this
1.Delete the Xcode preference
defaults delete com.apple.dt.Xcode
Other Issue could be the optimization level for the target, changing it to none will stop at the debugger
In my case, it turns out that the Dev build configuration is not configured properly.
The Dev configuration should be copied from Debug, not Release.
You can search with word debug in your Build settings to see the differences.
For example:
Hope this helps.
Open viewController.swift file for initial view in the standard editor and print something inside viewDidLoad and run application.. if the print is working properly, now make sure you have selected viewController.swift file correctly in the assistant editor.
Building up on what #neprocker said, I had "Optimize for Speed" for both debug/release. Simply changed the value for debug and I was good to go.

Xcode 6 ignoring breakpoints - Swift

Xcode 6 is completely ignoring my breakpoints. I saw a post here from 2008, but the answers are outdated, and don't seem to work.
EDIT:
This is happening only with projects that I start. All my downloaded open source projects work perfectly fine, as well as projects I started a few months ago.
UPDATE:
This is what I get when I create a brand new project and set a breakpoint in viewDidLoad
After trying many different things, I ran
defaults delete com.apple.dt.Xcode
This reset my Xcode settings. Now when I create a new project, breakpoints work fine.
I realized that the problem happened when I added Cocoapods to the project. B/c right after I ran pod install, breakpoints stopped working. I'm not sure why.
Hope this helps anyone with the same problem
I had a similar issue when I added a target to my project. Breakpoints placed in that target were ignored.
The solution was to set "Debug Information Format" in the new target's build settings to "DWARF with dysm"
In XCode 7.1 it defaulted to DWARF
There can be various culprits for this, a common one being setting the build scheme to Release instead of Debug.
For me it was the Debug Optimization Level set to -O0 in my target's build settings. Changing it to "Fast [-O, O1]" makes Xcode breakpoint-respectful again.
There is an interesting post about it here:
http://blog.credland.net/2014/03/xcode-debugger-why-do-you-stop-working.html
Close Xcode and remove the derived data and then reopen Xcode it will work

Xcode Cannot Run on the Selected Destination

I was running my app this morning and now all of a sudden I am getting the following error when I try to run on the iPhone 5.1 simulator.
Cannot run on the selected destination
The destination does not support the architecture for which the selected software is built. Switch to a destination that supports that architecture in order to run the selected software.
I deleted the schemes but still no solution.
I am using Mountain Lion. I am using xCode 4.4 (Recently upgraded to Mountain Lion and xCode 4.4)
UPDATE 1: Here is the view of my build settings:
UPDATE: Here is the actual error which prevents from it running.
You might follow the steps:
Quit Xcode and iPhone simulator
Unplug your devices
Goto /Users/your_usr_name/Library/Developer/Xcode/DerivedData/
Delete all data under this folder
Start Xcode again and run your project
Hope this will solve your problem.
I had this issue after updating from Facebook SDK 3.1 to Facebook SDK 3.1.1. My fault, I guess.
Inside "resources" folder, now there is a totally useless but dangerous info.plist that, if imported, may break your project file. Don't know why they included it but I believe few of us made the same mistake recently.
I found this problem with the version of Xcode 4.4. And finally I solved it this way:
Find the "Info.plist" in your project, then unselect the target membership plus on the right side view of window, it works for me.
You might also want to check if the project uses a supported compiler in the project settings
Its just duplicated Info.plist file
just use 1 Info.plist file in files then restart xcode
its fixed for me
I have just encountered this error in Xcode 4.5.1, and the error went away after I take all non-alpha characters out of the Product Name build setting.
I believe this may be a current unlisted bug with Xcode 4.4+. I have/had the very same issue with my project. I deleted all versions of Xcode and restarted with 4.4, opened my project and had the error again.
I then started a new project with a template with a different name. Did not have the issue.
I then renamed my old project, started a new empty project with the same name and built/ran and got the error again. This new project was nothing more than a view controller that didn't do anything. I should have gotten a blank screen but got the same error you did.
Frustrated I shut down for the day and re-ran the old project and it worked. I had not changed anything. Currently I have the error again and neither rebooting or restarting Xcode fixes it.
So in summary, a project can have absolutely no changes made, sometimes it builds and runs fine, sometimes you get this error. For the record I did not get this error running Xcode 4.3.
My issue did not show up until I upgraded to Mountain Lion and Xcode 4.4 which happened to be on the same day. Now I can not get back to a 100 percent workable configuration.
Committing my files to SVN and checking out the project in a new directory fixed this for me.
Look at both the project and target build settings, at that Architectures, and see if anything has changed. When first going from Xcode 3 to 4, it use to wreck havoc in a hidden way, giving the same error, and in the end you had to add i386 to the "Valid Architectures" line. I just looked at my big project started in Xcode 4.1, and it shows nothing about i386 etc, but I have other newer projects where I get this grayed out thing in that line $(ARCHS_STANDARD_32_BIT).
EDIT: I took a relook at this with a guru friend. Neither of us can find a linkage to i386 in our projects - Xcode is using some magic. That said, I did get a hit to i386 in a binary plist within the project, which leads me to another suggestion.
In your build settings, insure that ALL "Architectures" are $(ARCHS_STANDARD_32_BIT).
If that does not work, we suggest that you look at the compile and ld lines of your build when you select iPhone 5.1 Simulator in the scheme menu - to see if in fact its i386,
Another idea - move all your schemes and user settings to a save folder somewhere (with the project closed), then reopen and recreate a scheme. Now try again. There is no reference to i386 in any of my project.pbxproj files, so our suspicion is that this is somehow related to the scheme setting for the target device.
Good luck!
I've solved changing in both the project and target build settings the key "Build variants" from "armv7" to "normal"
in addition to deleting all the files in this directory
Users/your_usr_name/Library/Developer/Xcode/DerivedData/
i restarted my mac and it worked fine (restarting xcode and the simulator didn't cut it for me)
I was running into this same problem. In my case, it appeared to be that I had changed the Bundle Name for my multi-target project instead of the Product Name. Once I corrected that by editing the Project Name correctly and then setting the Bundle Name back to ${PRODUCT_NAME} it would run in the simulator again.
This may not be the answer for everyone, but it does appear that product naming errors (special characters, spaces, etc.) are a contributor for many, and that's what drove me to review the renaming that I had one.
I was facing the same issue with my project. Here's a brief explanation of the situation and my resolution. This may or may not work in your case.
I work at a place which has multiple iOS projects going. I recently had my system upgrade to Mac OSX 10.8 and Xcode 4.4.1. I was working on a project that was originally built on Xcode 4.1 for iOS 4. Since Xcode had iOS 4 simulators until 4.3, the project built and ran fine on all simulators. In Xcode 4.4.1 however, I did not find iOS 4 simulators and there is no easy way to install them either, which is why I was getting the "Cannot run on selected destination" error. Here's how I got my project to run.
Check under Build Settings > Architectures and set Architectures to Standard (armv7) or ${ARCHS_STANDARD_32_BIT} for all your profiles.
Set Base SDK to Latest iOS(<ios version #>) 5.1 in my case.
Set Build Active Architecture Only to NO for all profiles.
Set Valid Architectures to armv6 armv7 for all profiles. You may have to add either depending on what is already available.
Set iOS Deployment Target to iOS 5.1 (in my case) .
Make sure you have the same target under Deployment Target under the Summary tab of your project.
Clean and Run and cross fingers !!
In my case, the problem occurs after removing whole Resources folder, copying Resources folder from other or old project over current one then adding back that folder.
I solve the problem with the help from Analyse tool: after analysing, it warms me about Info.plist inside "Copy Bundle Resources".
Simply go to Copy Bundle Resource (at Build Phrase tab) delete Info.plist, then restart Xcode, clean and build. My project is back to normal.
Hope that help someones :)
I think a lot of these solutions force a full rebuild, which is what solved this for me.
I did Product => Clean, and the problem went away.
For me this worked:- Check all you product references are consistent in the settings and plists. Also check the product name does not contain any SPACE or other "illegal" characters.
try to rename your project. I solved by this way.
Judging from the responses this type of error has many potential sources, so here is my own (admittedly careless) version of the mistake (and simple solution):
XCode project Build Settings can be set at two levels: Project level, and Target level. For those less familiar, target level is where you have your executable app, and often other items like a dynamic library build.
In Linking section of Build Settings there is a option for Mach-O Type, where you can set Executable, Dynamic Library, Static Library, etc..
I was having trouble preparing a dynamic library, was scanning over the build settings for the project and saw Mach-O was blank. So I set to dynamic library. I then went on and reviewed a few more things and forgot I'd made this change. But I didn't realize I was at the overall Project Level, not the Target level for the actual dynamic library. This changed all target Mach-O settings to dynamic library.
And of course the executable target didn't like being treated as a dynamic library, and I got the OP's error message.
Setting the executable back to executable Mach-O at its target-level build settings fixed everything. Annoyingly the project-level setting still said dynamic library, but with correct target-level settings all worked fine.
Silly I know, but since a couple of the more drastic solutions listed above would have indirectly solved for this error I thought I'd share in case someone else had made the same mistake!
The way I solved this error was by a adding dummy function to my project. My issue was my app had no code of its own, only linked-in code.
I have an unusual situation with two projects: one "App" parent and one "Engine" child. All the compilable code is in the child and the parent simply links with the child, copying a ton of App-specific resources into the project.
Apparently this saddens Xcode, resulting in the above error.
My solution is adding this C function / file to the App project:
int workaround_for_xcode_reporting_cannot_run_on_selected_destination(){return 0;}
I restore the data from the time machine. Notice this is the exact same data that has been stored just 1 hour ago. The problem started yesterday. So it should be the EXACT same data.\
Yet it works.
I tried everything metioned here. Nothing worked. It seems that I somehow imported the Info.plist twice. To fix it I selected the project and pressed the "Validate Settings" button. Afterwards it works for me.
After a half day of experimenting, I think this means that the debugger can't find your executable to launch. I think this is an important distinction from the prior answers because its an underlying cause, that can have a lot of symptoms. In my case it couldn't reconcile the apps Info.plist for a custom build where we were copying the plist for the build. I changed the build setting to the Alt-Info.plist for AltDebug and that fixed it. Also meant no more copying.
Your underlying cause might be different, so the key takeaway is think about why Xcode might not be able to find your built app.
You'll be happy to know this problem has a very simple solution. Select Info.plist in your project navigator tree and make sure it is not assigned to a target. I have confirmed this is the correct solution. If building for iOS 6 or earlier you may also need to add armv6 to supported architectures
I had this issue after upgrading to Mountain Lion and XCode 4.4.1 for an OSX project.
To resolve it, I had to upgrade my deployment target to 10.5 or higher; it was set to 10.4 and up.
You have to find in the "Activity Monitor" the Xcode process and kill it! I just did it to solve a similar problem!
I've got this problem after accidentally removing the Resources folder, when I added it again to the project, Bam !
I'm also running Mountain Lion and XCode 4.4 !
trying to find out what's causing this, but it seems to be reproduced when you delete then add the info.plist file ! can someone confirm that ?
I had the same problem after two things happened:
I upgraded to Facebook SDK 3.1
I updated my OSX (with a minor version update)
The only fix worked from me was adding armv7s (mind the "s" in the end!!!)
Like was suggested here:
https://stackoverflow.com/a/12540654/531527
Yet another variant solution: after trying just about everything in the list above, I fixed this by addressing a warning that the TestFlightSDK1 path could not be found. To do so, I deleted the relevant path from Header Search Paths (Build Settings>Search Paths) and removed the TestFlightSDK, and now things run just fine.
I had this from beginning and it looks like it is a problem that the emulator can not handle virtual smartcards. Unfortunately I ended up just using my Android phone connected via USB.
Remove Info.plist from the Copy Bundle Resource build phase.That worked for me!

iOS framework project breakpoints not working

I've created an iOS framework project using the famous (and excellent) iOS Universal Framework Xcode template.
But now I've encountered an annoying problem that I can't seem to fix which is that I have an iOS application project that references the framework project and when I run that and have breakpoints set in the framework they don't get it. It seems GDB doesn't have the debug symbols for the framework.
I've made sure that debug symbols are not stripped from the framework and the type is set to "DWARF with dSYM file".
Anyone have any ideas what might be wrong and how to fix it?
My setup:
Xcode 4.2.1
iOS SDK 5.0
I ran into this issue while linking a dynamic framework to a test application in Xcode 7. I was able to avoid the error by ensuring the following in the build settings of my dynamic framework:
"Generate Debug Symbol" - 'Yes'
"Strip Debug Symbols During Copy" - 'No'
Several things comes to my mind regarding your problem. Give them a try and see which ones work for you:
Make sure to have the "Other Linker Flags" on the "Linking" section of the framework's "Build" Info.
Make sure that you have the framework's built in the correct configuration (ie, if you compiled the framework's in Release and are using it with your project set to Debug you might get issues)
Make sure you added the correct framework .a file to your project (actually two issues here: you can have added the Release version - so no debug symbols in there - AND you have to make sure that your projec is not pointing to some old build version)
Check that both the framework's and your project have the "Level of Debug Symbols" on the "Code Generation" section of the "Build" Info set to "All Symbols [full, -gstabs+ -fno-eliminate-unused-debug-symbols]"
If all alse fails try to empty the XCode caches and remove the framework reference from your project. Then clean and rebuild the framework (all configs: device-debug, device-release, simulator-debug, simulator-release, ...) and add it again to you project. Clean and rebuild your project and cross your fingers... :-)
I have also experienced this issue. One way that I have been able to work around this by merging both projects into a single workspace.
Instructions on how to do this can be found at http://developer.apple.com/library/ios/#recipes/xcode_help-structure_navigator/articles/adding_a_project_to_a_workspace.html.
NOTE: I have also experienced a bug adding projects to workspaces where there appears to be no files in the recently added project to the workspace. I have found this is easily remedied by restarting Xcode after all of the projects have been added to the workspace.

Resources