I am running this on 11.1 MacOS Big Sur with 12.0 XCode.
Additional Detail from JIRA
Votes
0
Component/s
swift-format, SwiftSyntax
Labels
Bug
Assignee
None
Priority
Medium
md5: 2fe2fd02d5afe157f55c9241f621b7e2
Issue Description:
Hi!
I hope this is not a silly question; how do you use this library inside another Swift library? I am maintaining a GraphQL client library that heavily relies on code generation. Since the code is mainly unformatted, I'd like to format it before writing it out on a disk.
I am trying to use `swift-format` (which relies on `swift-syntax`) and I am getting a strange error when using the library.
```
Undefined symbols for architecture x86_64:
"_$s11SwiftFormat0A9FormatterC13configuration16diagnosticEngineAC0aB13Configuration0G0V_0A6Syntax010DiagnosticF0CSgtcfC", referenced from:
_$sSS19SwiftGraphQLCodegenE6formatSSyKF in String+Format.swift.o
"_$s11SwiftFormat0A9FormatterC6format6source15assumingFileURL2toySS_10Foundation0H0VSgxztKs16TextOutputStreamRzlF", referenced from:
_$sSS19SwiftGraphQLCodegenE6formatSSyKF in String+Format.swift.o
"_$s11SwiftFormat0A9FormatterCMa", referenced from:
_$sSS19SwiftGraphQLCodegenE6formatSSyKF in String+Format.swift.o
"_$s24SwiftFormatConfiguration0C0VACycfC", referenced from:
_$sSS19SwiftGraphQLCodegenE6formatSSyKF in String+Format.swift.o
ld: symbol(s) not found for architecture x86_64
```
I've seen the note in swift-syntax's README that talks about linking the library, and I've found a similar issue (and its [fix|SwiftDocOrg/homebrew-formulae@af4cd47),)]), but the other libraries in the examples section in that README don't rely on any such script.
Can you help me? What am I doing wrong? What should I look at to understand the error message?
Looks like SwiftFormat isn't actually in the link line. I just cloned this repo at `next` and the package builds successfully. Have you ensured that you have the proper package dependencies installed? Perhaps trying blowing away your package build directory and resetting package caches to re-pull these dependencies.
It looks like the Package.swift in your next branch points to a different SwiftFormat (a community one, rather than the one at https://github.com/apple/swift-format). But the errors you've pasted above definitely refer to symbols in apple/swift-format and not the other one. Did you switch from one to the other but haven't updated the repo yet?
Since both projects export their API with the module name SwiftFormat, I wonder if somehow your project got into a weird state where it's compiling against the right symbols but somehow failing to find the right thing to link against. I agree with Robert that cleaning and/or resetting package caches is probably the first thing to try here.
Sorry for the trouble with commits. Indeed, we changed it because of the problems. This is the relevent [commit|maticzav/swift-graphql@8e0db37.] Note that the library builds itself. The issue arises when I try running Codegen script - when compiling the StarWars example.
Environment
I am running this on 11.1 MacOS Big Sur with 12.0 XCode.
Additional Detail from JIRA
md5: 2fe2fd02d5afe157f55c9241f621b7e2
Issue Description:
Hi!
I hope this is not a silly question; how do you use this library inside another Swift library? I am maintaining a GraphQL client library that heavily relies on code generation. Since the code is mainly unformatted, I'd like to format it before writing it out on a disk.
I am trying to use `swift-format` (which relies on `swift-syntax`) and I am getting a strange error when using the library.
```
Undefined symbols for architecture x86_64:
"_$s11SwiftFormat0A9FormatterC13configuration16diagnosticEngineAC0aB13Configuration0G0V_0A6Syntax010DiagnosticF0CSgtcfC", referenced from:
_$sSS19SwiftGraphQLCodegenE6formatSSyKF in String+Format.swift.o
"_$s11SwiftFormat0A9FormatterC6format6source15assumingFileURL2toySS_10Foundation0H0VSgxztKs16TextOutputStreamRzlF", referenced from:
_$sSS19SwiftGraphQLCodegenE6formatSSyKF in String+Format.swift.o
"_$s11SwiftFormat0A9FormatterCMa", referenced from:
_$sSS19SwiftGraphQLCodegenE6formatSSyKF in String+Format.swift.o
"_$s24SwiftFormatConfiguration0C0VACycfC", referenced from:
_$sSS19SwiftGraphQLCodegenE6formatSSyKF in String+Format.swift.o
ld: symbol(s) not found for architecture x86_64
```
I've seen the note in swift-syntax's README that talks about linking the library, and I've found a similar issue (and its [fix|SwiftDocOrg/homebrew-formulae@af4cd47),)]), but the other libraries in the examples section in that README don't rely on any such script.
Can you help me? What am I doing wrong? What should I look at to understand the error message?
Thank you!
> I know this is not ideal, but you can find all the code in [SwiftGraphQL|https://github.com/maticzav/swift-graphql/tree/next]'s repo.
The text was updated successfully, but these errors were encountered: