Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

288
Views
What's the solution for "error: Couldn't IRGen expression, no additional error" on Xcode 10.1?

We have a large project with a lot of dependencies brought in through Carthage. Whenever we try to look at a variable in the lldb debugger (p variablename), it gives us an error: error: Couldn't IRGen expression, no additional error

None of the workarounds are very good. We can run carthage with --no-use-binaries to get around it, but it makes builds take a prohibitively long time. We can use fr v on some variables, but not all. People have fixed this in previous versions of Xcode by changing permissions on some Swift directories, but I can't find the corresponding directories in Xcode 10.1. And I saw someone say that changing the build system back and forth helped him, but that hasn't worked for us.

So I'm starting this search for a solution on Xcode 10.1 specifically. Has anyone else found out what's causing this error, and/or a good solution to it?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Someone on my team shared a solution to this that actually works (I don't know if he discovered it or found it elsewhere):

Set a breakpoint on the first line of the AppDelegate didFinishLaunchingWithOptions method. Set the action for this breakpoint to: po application

Now, when your run your application, the debugger will pause at that breakpoint and will display this text in the lldb debugger pane (with your app name instead of Foo):

note: Swift compiler options for Foo conflict with options found in other modules; Switching to a new expression evaluator for Foo, old $R variables are lost.

And then the lldb debugger will work properly, able to p and po variables and expr expressions.

I don't know why it works, but it works, and reliably too!

over 4 years ago · Santiago Trujillo Report

0

A colleague and me found a solution:

Create an Objective-C file in your Swift project. Hit yes when it asks for the Bridging Header.

Test.h

#import <Foundation/Foundation.h>

@interface Test : NSObject

- (id)init;

@end

Test.m

#include "Test.h"

@implementation Test

- (id)init
{
    return self;
}

@end

MyProject-Bridging-Header.h

#include "Test.h"

And now: 🎉 no more error: Couldn't IRGen expression, no additional error and you can debug again.

So I think just adding a bridging header works as a workaround...

But If that doesn't work:

Add a breakpoint in AppDelegate.swift in application: UIApplication, didFinishLaunching like so and hope that this helps:

Breakpoint in Xcode

over 4 years ago · Santiago Trujillo Report

0

There is currently a hard requirement that the version of the swift compiler you use to build your source and the version of lldb you use to debug it must come from the same toolchain. Currently the swift debug information for types is just a serialization of internal swift compiler data structures. It also depends on local path information, which makes it hard to move around.

There is a longer term effort to change that design, but for now you have to rebuild all your binaries every time you update your tools, and you can't use pre-built binaries.

I'm a little surprised this causes a day-to-day problem, however. This full rebuild only needs to happen when you pull new sources from Carthage or update your tools, which shouldn't be that often. If you are triggering rebuilds more frequently than that, maybe dependencies aren't getting tracked properly, so that more files are getting rebuilt than need to be?

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!