46

I upgraded my project to Swift 2 in Xcode 7 beta (7A120f) and get this error when trying to po self at the lldb prompt:

warning: Swift error in module myApp:

Swift had fatal errors constructing the ast context for this module: cannot load underlying module for 'UIKit' Debug info from this module will be unavailable in the debugger.

I'm then left with a crippled debugger (no values). This happens regardless of where I place a breakpoint. I've tried:

  • clearing derived data
  • Product > Clean
  • restarting xcode
  • restarting mac

I'm able to create a new project and see debug output in it, so this probably has something to do with how my project was migrated by xcode.

What is the ast context and how can I correct it?

Edit: ast is 'Abstract Syntax Tree'. Still no idea how to fix it though.

Community
  • 1
  • 1
Fook
  • 5,320
  • 7
  • 35
  • 57
  • 2
    Currently trying to resolve the same or similar issue where debugger is broken when importing a custom framework. http://stackoverflow.com/questions/31219422/swift-debugger-does-not-show-variable-values-when-importing-objc-framework – CodeSmile Jul 04 '15 at 10:54
  • 7
    The same problem with `Crashlytics` – Bartłomiej Semańczyk Jul 09 '15 at 08:40
  • Can you post a sample project with this issue or maybe put the critical part into a playground? – Tommie C. Aug 03 '15 at 00:51
  • @BartłomiejSemańczyk updating to Crashtlytics 3.1.0 fixed the issue for me on XCode 7 beta 5 – apouche Aug 07 '15 at 12:47
  • Had the same issue with the Facebook iOS SDK. Resolved when upgraded to latest v4.5.0 release and also put the frameworks in a subfolder just in case so it is not in the same folder as the project. Using Xcode 7 Beta 5 – harryhorn Aug 11 '15 at 06:59

4 Answers4

5

I'm having the same issue in my project. The error that lldb spits out when attempting to po an object highlights the issue:

(lldb)po fileURL
warning: Swift error in module <APP_NAME>:
    Swift had fatal errors constructing the ast context for this module: <module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/Crashlytics.h"
        ^
<APP_PATH>/Pods/Crashlytics/Crashlytics.framework/Headers/Crashlytics.h:10:9: error: include of non-modular header inside framework module 'Crashlytics'
#import <Fabric/FABAttributes.h>
        ^

The Crashlytics.h umbrella header in Crashlytics.framework is importing Fabric/FABAttributes.h, which is not part of the Crashlytics module (i.e. not in its module.modulemap). This is Crashlytics 3.1.0 installed using CocoaPods.

Why Xcode 7 treats this as a fatal error is beyond me (it was just a warning in 6). In Xcode 6 you could work around this sort of "non-modular header include" by enabling the "Allow Non-modular includes in Framework Modules" (CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES) build setting in your application target.

I've had no luck getting the Xcode 7 betas to honor the above flag (rdar://22044453 <-- please dup).

The only solution I've found to get the debugger working is to remove the Crashlytics pod. I comment out the Crashlytics and Fabric pods, run pod install, resume debugging and then reinstall the pods before a release.

I really hope this is fixed in Xcode 7 by the time it comes out of beta.

phatblat
  • 3,804
  • 3
  • 33
  • 31
2

Check your bridging header and if you have

@import Crashlytics;

(or any other frameworks that cause the error. In my case it was GoogleMobileAds)

try replacing with

#import <Crashlytics/Crashlytics.h>

Dmitry
  • 2,837
  • 1
  • 30
  • 48
2

I had the same issue. In the most cases this issues appears when you use objective-c frameworks or libraries in Swift project.

The issue was fixed by importing objective-c frameworks or libraries in Bridging-Header only.

#import <SampleFramework/SampleFramework.h>

and remove all imports of this framework from Swift files

import SampleFramework // <-- Remove it

Then Clean and Build.

Make sure that you did this procedure for all objective-c frameworks or libraries in your projects.

Hope this helps!

got2b_ae
  • 113
  • 1
  • 1
  • 6
1

To fix this I manually migrated all my files and settings to a new xcode project. Nothing else worked. There is probably a better fix but I couldn't spend any more time looking for it.

Fook
  • 5,320
  • 7
  • 35
  • 57