Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lldb error: Couldn't lookup symbols. Swift iOS

With lldb, I want to instantiate a Swift Class in my release iOS build and release dynamic framework.

I attach lldb to my release build, on the Simulator.

Main app - works

(lldb) exp let $c = hello_class()
error: <EXPR>:3:10: error: use of unresolved identifier 'hello_class'
let $c = hello_class()
         ^~~~~~~~~~~
(lldb) expr import My_App
(lldb) exp let $c = hello_class()
(lldb) po $c.hello()
🔸 hello 🔸

dynamic framework - fails

(lldb) dclass -m myframework
Dumping classes
************************************************************
myframework.RustyAppInfo

(lldb) expr import myframework
(lldb) expr let $d = RustyAppInfo()
error: Couldn't lookup symbols:
  __T011myframework12RustyAppInfoCACycfC

Both the app and dynamic framework were built with no optimization.

UPDATE

static framework - fails

Same results when changing - to the Xcode 9 introduced feature - static Swift framework.

Xcode - Dead Code Stripping

by default, with Swift code, Dead Code Stripping is turned ON. I checked to see if that was the issue. No difference to results.

like image 669
rustyMagnet Avatar asked Jul 18 '18 06:07

rustyMagnet


1 Answers

RESOLVED

I found my answer inside of this article:

http://iosbrain.com/blog/2018/01/13/building-swift-4-frameworks-and-including-them-in-your-apps-xcode-9/

I had failed to set public init() on the Swift class that was inside the Framework. Working code that can be invoked by lldb:

// set the Framework class to Public
public class rnHello{  

   // set the initializer to public, otherwise you cannot invoke class
    public init() {  

    }

    // set the function to public, as it defaults to internal
    public static func world() {  
        print("hello from a static method")
    }
}

Now you can access this via your Swift code or with lldb:

(lldb) po rnHello.world()
hello from a static method
like image 165
rustyMagnet Avatar answered Sep 27 '22 18:09

rustyMagnet