Abdullah Umer
Abdullah Umer

Reputation: 4624

Xcode 7 beta debugger not showing values of variable at breakpoint for Swift code

I have tried the answers from question here but none of them helped :(

I have installed Xcode 7 beta 5 and the debugger will not show values of variables when debugging swift code. It works fine in Obj-C code.

I have tried changing the Compiler Optimisation level to None and it had not effect.

enter image description here

Upvotes: 24

Views: 6295

Answers (8)

Gent
Gent

Reputation: 6415

I had the same issue. I solved it from this link here:

Swift debugger does not show variable values when importing ObjC framework

First try to move in subfolder all .framework, as Author of this post says:

I got a message from an Apple developer stating that they've observed this problem, and that it could be fixed by moving the .framework to a subfolder of the project. Apparently the module .. was built in directory error appears only if the .framework is in the same folder as the .xcodeproj aka $(PROJECT_DIR).

But in my case, the main issue was OpenTok framework. After I add action in the breakpoint

po self 

Log shows up the message:

warning: Swift error in module myapp: Swift had fatal errors constructing the ast context for this module: :1:9: note: in file included from :1: #import "/Users/me/Developer/myapp-ios/Pods/OpenTok/OpenTok.framework/Headers/OpenTok.h"

And finally I added these lines of codes in Podfile:

post_install do |installer|
  `find Pods -regex 'Pods/OpenTok.*\\.h' -print0 | xargs -0 sed -i '' 's/\\(<\\)OpenTok\\/\\(.*\\)\\(>\\)/\\"\\2\\"/'`
end

After that finally, pod install.

Upvotes: 0

Mayur Rathod
Mayur Rathod

Reputation: 42

Goto Project -> Targets -> Build Setting -> Optimisation Level -> Debug and set value to whatever u want

Upvotes: -1

Mostafa Abdellateef
Mostafa Abdellateef

Reputation: 1155

This may be due to a problem in the bridging file between Swift and Objective-C, e.g the file {projectName}-Bridging-Header.h . To make sure about that:

1- add a breakpoint at the place you want to debug.

2- After the breakpoint is reached, write the lldb command po on any object in the xCode debugging output window. for example :

po self.view

If there is a problem you should see it's log and hopefully you can go and fix it

Upvotes: 1

Allan Weir
Allan Weir

Reputation: 628

I was still finding this an issue in the final release of XCode 7.0. It turns out my bridging header needed updating as one of the references was no longer needed in it.

I found that out by using 'po' in the debugger for one of the variables, e.g. 'po self.views'. The debugger then listed all the errors in the bridging header for me. Weird way to find out the problem but it worked.

EDIT: And just in case do a clean build after fixing any issues

Upvotes: 4

matts
matts

Reputation: 298

The thread that @Breek linked to contains the solution - Twitter has released a fix for this. Upgrading Crashlytics from 3.1.x to 3.2 fixed the debugger for me on the Xcode 7 GM seed. If for some reason you cannot upgrade Crashlytics, you should be able to edit their header files as indicated in the thread as a temporary workaround; that is, changing #import <Fabric/FABAttributes.h> in Crashlytics.h to @import Fabric; instead.

Upvotes: 0

Breek
Breek

Reputation: 1441

Apple fixed this problem in Xcode 7 Beta 6

And there is a link about the problem from Twitter Developer: https://twittercommunity.com/t/xcode-7-debugger/50792

Upvotes: 0

rjb101
rjb101

Reputation: 514

Removing Fabric/Crashlytics did it for me. I can say for sure not ALL ObjC imports cause this problem. I'm still using some others in my Swift project but for some reason Crashlytics causes some issues in the latest beta. I got a compiler error early on too and I had to turn off bitcode for the project to even compile.

Upvotes: -2

Jin Wang
Jin Wang

Reputation: 1

I had the same problem. The reason is because I'm using Crashlytics which is a ObjC framework.

Try to remove some of the ObjC frameworks and then shift + cmd + k to clean your project and rebuild it again.

It should work after that.

Upvotes: -1

Related Questions