24

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
Abdullah Umer
  • 4,234
  • 5
  • 36
  • 65

8 Answers8

4

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

Allan Weir
  • 628
  • 5
  • 12
  • Followed this procedure to fix the same problem in Xcode 8 beta 6 and it worked. Thanks! I didn't need to do a clean build. – user3717478 Aug 26 '16 at 08:05
1

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

Mostafa Abdellateef
  • 1,145
  • 14
  • 12
  • how is that an answer for the OP? He has a valid bridging header or else he cannot compile, debugging is done with a break point and a 'po'. – Yohst Feb 25 '16 at 23:20
  • You are absolutely amazing ! it really showed me 9 errors, which was causing auto completion problem and debug details wasn't showing. – Nata Mio Mar 31 '16 at 13:15
  • My app is built and running. But this way has shown me that I have issues importing Firebase frameworks. – malhobayyeb Oct 25 '16 at 08:38
0

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

Breek
  • 1,431
  • 13
  • 24
0

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.

matts
  • 298
  • 2
  • 6
0

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.

Gent
  • 6,215
  • 1
  • 37
  • 40
-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.

  • Removing Obj-C frameworks is not an option. My project is very old and more than 80% in Obj-C. While any new features are written in Swift. – Abdullah Umer Aug 23 '15 at 12:11
-1

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

Mayur Rathod
  • 42
  • 1
  • 1
  • 4
-2

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.

rjb101
  • 514
  • 5
  • 14
  • I take that back. I do see some things in the debugger but its almost worse than no values. (lldb) po iCloudFileName error: Couldn't materialize: size of variable iCloudFileName (24) disagrees with the ValueObject's size (8) Errored out in Execute, couldn't PrepareToExecuteJITExpression – rjb101 Aug 24 '15 at 05:38