filestack-ios icon indicating copy to clipboard operation
filestack-ios copied to clipboard

Undefined Symbols when importing with SwiftPM

Open Mordil opened this issue 4 years ago • 1 comments

Xcode 2.5 (12E262) Swift 5.4 SwiftPM - Xcode's Bundled version Project Minimum iOS Version: 13

filestack-ios: 2.7.2

When importing the library using Xcode's UI for adding Swift Packages to our iOS Target, we add the following code:

import Filestack
import FilestackSDK

extension ViewController {
  private func doSomething() {
    let client = Client(apiKey: "")
    print(client)
  }
}

when we build, Xcode gives us the following errors:

Undefined symbols for architecture arm64:
  "type metadata accessor for FilestackSDK.Client", referenced from:
      Peek_Pro.PKViewOrderViewController.(doSomething in _0192BE462E8B9F880CB09CA425A161D1)() -> () in PKViewOrderViewController.o
  "FilestackSDK.Client.__allocating_init(apiKey: Swift.String, security: FilestackSDK.Security?) -> FilestackSDK.Client", referenced from:
      Peek_Pro.PKViewOrderViewController.(doSomething in _0192BE462E8B9F880CB09CA425A161D1)() -> () in PKViewOrderViewController.o
ld: symbol(s) not found for architecture arm64

Undefined symbol: type metadata accessor for FilestackSDK.Client
Undefined symbol: FilestackSDK.Client.__allocating_init(apiKey: Swift.String, security: FilestackSDK.Security?) -> FilestackSDK.Client

I've narrowed it down to only receiving build errors when importing FilestackSDK, importing Filestack itself is fine

Mordil avatar Jun 30 '21 20:06 Mordil

Hmm, I see what's going on:

BothFilestackSDK and Filestack define the symbol Client and because both Filestack and FilestackSDK are being imported in your code, Client is being resolved to FilestackSDK.Client and it is failing to build since your target is not linking explicitly against FilestackSDK.

To resolve this issue, you may want to:

  1. Add the FilestackSDK (https://github.com/filestack/filestack-ios.git) dependency explicitly to your target.
  2. Make sure to prefix the Client class with either Filestack. or FilestackSDK. depending on what Client class you intend to use.

Let me know if this works for you and we'll add this extra step to our SPM installation procedure in the README.md.

Thanks!

rnine avatar Jul 01 '21 07:07 rnine

This no longer reproduces with the latest version of the SDK, and Xcode 15.2 (Swift 5.9)

Mordil avatar Jun 20 '24 17:06 Mordil