Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-8949] Static library swiftmodule is not linked properly causing debugger to not work #4623

Open
swift-ci opened this issue Oct 9, 2018 · 0 comments
Labels
bug Something isn't working LLDB for Swift

Comments

@swift-ci
Copy link

swift-ci commented Oct 9, 2018

Previous ID SR-8949
Radar radar://45123817
Original Reporter BalestraPatrick (JIRA User)
Type Bug

Attachment: Download

Environment
  • Xcode 9.4.1 and Xcode 10
  • Swift 4.1
Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift
Labels Bug
Assignee None
Priority Medium

md5: 56a06762cce132fbb760f75d805c52db

Issue Description:

When trying to po a variable in a static library that contains Swift linked to an Objective-C target, the debugger fails with the following message:

(lldb) po string
error: in auto-import:
failed to get module 'LibraryWithSwift' from AST context

You can find a sample project which reproduces the issue attached. Open the project and set a breakpoint at `NiceSwiftFile.swift:21`. Run the project and when it stops at the breakpoint, follow the instructions in the source file. It was created from scratch and only a few build settings were modified to get it to compile and import Swift correctly:

The main target was modified as follows:

ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
LIBRARY_SEARCH_PATHS = $TOOLCHAIN_DIR/usr/lib/swift/$PLATFORM_NAME;
HEADER_SEARCH_PATHS = $SRCROOT/Output; // Make sure that we can import the Objective-C generated header

Static library target:

DERIVED_FILE_DIR = $SOURCE_ROOT/Output/LibraryWithSwift // produce the generated header in a directory importable by the main target

The Objective-C generated interface header is imported in the AppDelegate.m where a method defined in the Swift static library is invoked. Setting a breakpoint on this method and printing any variable in the Swift context fails in Xcode 9.4.1 and Xcode 10.

A known workaround is to add `-Xlinker -add_ast_path -Xlinker $(BUILT_PRODUCTS_DIR)/LibraryWithSwift.swiftmodule/x86_64.swiftmodulee` to the main app target for every Swift module as suggested in SR-2660.

This bug may be related to the one just mentioned, but I felt that opening a new one makes sense since in this project only one Static library is required to demonstrate the issue.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LLDB for Swift
Projects
None yet
Development

No branches or pull requests

1 participant