Error: Couldn't Irgen Expression, No Additional Error

LLDB: Couldn't IRGen expression

If you are using CocoaPods, this may apply to you. There are two things to make sure of.

Gotcha 1: Make sure you have not added pod dependencies to your Test target(s) in your Podfile:

target 'MyApp' do
project 'MyApp'

pod 'Alamofire'
# ... other pods ...

end

target 'MyAppTests' do
project 'MyApp'
inherit! :search_paths
# Do not add your main app pods here
# You can use pods for writing your test cases though (e.g. mocks)
end

In my case I had quite a few frameworks and at least one of them was using binaries and caused LLDB to freak out if I added it to my test target.

As a side note/tip, if you need to use any dependencies from within your app, you need to change the runtime behavior of your main app via launch arguments instead of doing things in your testing code. (This is where I strayed from the path and it caused me problems.) You can do this by adding this to your test file:

# When you launch your app (e.g. in `setUpWithError()`)
let app = XCUIApplication()
app.launchArguments = ["testing-enabled"]
app.launch()

and then in your main app code (e.g. in AppDelegate or SceneDelegate):

#if DEBUG
if CommandLine.arguments.contains("testing-enabled") {
configureAppForTesting()
}
#endif

The #if DEBUG is not necessary but it's good practice to not ship code that will not be executed in the published app.

Gotcha 2: If you have custom build configurations, make sure your tests run in Debug mode.

For example, if we have created a build config called App Store based on Release and a test config based on Debug, then we need to do the following in our Podfile:

target 'MyApp' do # do it for MyAppTests also!
project 'MyApp', 'App Store' => :release, 'Test' => :debug

# ... pod dependencies, etc.
end

Without this setting, your dependencies will be built using the default iOS config which is a Release type of configuration (with compiler optimizations for both Swift and GCC that the debugger won't like).

Finally, make sure that your scheme's Test mode is set to use the proper build configuration (in this case Test) as in the screenshot below.

Xcode scheme config screen

Issues to debug my code in my Xcode Framework

Removing carthage folder and running

carthage bootstrap --platform ios --cache-builds --no-use-binaries --new-resolver

made it to work.

Xcode debugger doesn't print objects and shows nil, when they aren't

Are you sure you are not in "Release mode"?

If you want to see variable values you have to be in "Debug mode" (click on your project name on the top left corner near start/stop buttons, then "Edit scheme...", then "Run" settings, then "Info" tab, then "Build Configuration". Here set "Debug". If it was on "Release" that's the matter you saw all nils).



Related Topics



Leave a reply



Submit