yoasha
(Yoash Adato)
1
I recently added Swift to my existing objective-c static library project and encountering issues when debugging Swift code.
When code stops at a breakpoint and I enter a po command, such as: po title, I get:
error: expression failed to parse:
error: Couldn't realize type of self
Note the following:
- The project is an
objective-c static library with recently added Swift files.
- The error appears only when breakpoint is in a
Swift file. There is no issues while debugging objective-c file (*.m file).
- Xcode version is 14.1
- Project is using
CocoaPods.
- There are no issues with compilation and runtime. The only issue is with debugging.
- When running
swift-healthcheck from breakpoint, there are plenty of errors as follow:
LoadOneModule() -- Missing Swift module or Clang module found for
"Infra", "imported" via SwiftDWARFImporterDelegate. Hint: Register
Swift modules with the linker using -add_ast_path.
While Infra is the name of my static library.
Any suggestions?
edudnyk
(Eugene Dudnyk)
2
The suggestion is the Hint: from the swift health check: you need to use Clang module importer, not DWARF importer. In order to enable Clang importer, you need to add this to OTHER_LDFLAGS:
-Xlinker -add_ast_path -Xlinker '${BUILT_PRODUCTS_DIR}/Infra.swiftmodule/${NATIVE_ARCH}-${LLVM_TARGET_TRIPLE_VENDOR}-${SWIFT_PLATFORM_TARGET_PREFIX}${LLVM_TARGET_TRIPLE_SUFFIX}.swiftmodule'
yoasha
(Yoash Adato)
3
Thank you for your reply. I tried to add the line you suggested (by using copy-paste) but Xcode doesn't treat it as a single command but rather multiple commands separated by spaces... (see screenshot). What am I doing wrong?
edudnyk
(Eugene Dudnyk)
4
That's about right, you're not doing anything wrong. They are joined into single command arguments string when the linker command is called. You should do this on a dynamic binary target that depends on your Infra static library, not on the Infra static library itself (i.e. on App target or on dynamic framework or on app extension target that depends on Infra).
yoasha
(Yoash Adato)
5
Got it. Thank you so much for your reply.
The issue eventually was resolved in a different way: I just added the Swift bridging files to the App target (while previously it was only added to the static library target). I should have thought about this sooner... Sorry for the hassle.