Import framework into REPL: Couldn't lookup symbols


(Jonas Vautherin) #1

I am trying to import a framework into the Swift REPL, with the following syntax:

$ swift -F path/to/my/Build/Products/Debug

Where testFramework.framework is in Build/Products/Debug.

Then I can successfully import it, like so:

1> import testFramework

But when I try to use it (say here I instantiate an object called Action), I get a "Couldn't lookup symbols" error:

2> let action = Action(address: "localhost", port: 50051) 
action: testFramework.Action = <extracting data from value failed>

error: Couldn't lookup symbols:
  __T013testFramework6ActionCACSS7address_Si4porttcfC
  __T013testFramework6ActionCMa

However, if I nm testFramework/testFramework, I can find this symbol:

00000000001d8990 T __T013testFramework6ActionCACSS7address_Si4porttcfC

Why is that? testFramework looks like this:

├── Headers -> Versions/Current/Headers
├── Modules -> Versions/Current/Modules
├── Resources -> Versions/Current/Resources
├── Versions
│   ├── A
│   │   ├── Headers
│   │   │   ├── testFramework-Swift.h
│   │   │   └── testFramework.h
│   │   ├── Modules
│   │   │   ├── module.modulemap
│   │   │   └── testFramework.swiftmodule
│   │   │       ├── x86_64.swiftdoc
│   │   │       └── x86_64.swiftmodule
│   │   ├── Resources
│   │   │   └── Info.plist
│   │   ├── _CodeSignature
│   │   │   └── CodeResources
│   │   └── testFramework
│   └── Current -> A
└── testFramework -> Versions/Current/testFramework

(Ankit Aggarwal) #2

Use -F instead of -I


(Jonas Vautherin) #3

Thanks for the answer!

My mistake, I am actually using -F already, as -I doesn't work. I will edit the question above.


(Ankit Aggarwal) #4

hmm, it should autolink but try adding -framework <name>


(Jonas Vautherin) #5

Exact same error with:

$ swift -F path/to/my/Build/Products/Debug -framework testFramework

(Jordan Rose) #6

I'm not sure the REPL actually handles search paths right now (see SR-1619). @Jim_Ingham?


(Ankit Aggarwal) #7

I have done this before by adding -I and -L to SwiftPM's build dir, not sure why -F isn't working.

Edit: Just tried this locally with a new framework project, -F is also working for me.


(Jim Ingham) #8

All the extra options that are passed to the REPL from the swift driver get passed straight to the compiler instance we make for evaluating REPL expressions. I'm pretty sure that's all we ever did with these options, I don't think we poked at them ourselves.