filestack-ios
filestack-ios copied to clipboard
Undefined Symbols when importing with SwiftPM
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
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:
- Add the
FilestackSDK(https://github.com/filestack/filestack-ios.git) dependency explicitly to your target. - Make sure to prefix the
Clientclass with eitherFilestack.orFilestackSDK.depending on whatClientclass 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!
This no longer reproduces with the latest version of the SDK, and Xcode 15.2 (Swift 5.9)