Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] [Triaged]: SwiftCurrent_CLI not building successfully in consuming iOS application #201

Open
1 task done
morganzellers opened this issue Apr 7, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@morganzellers
Copy link
Contributor

What happened?

While testing aspects of the new data-driven workflow feature, I created a brand new SwiftUI Project and added the SwiftCurrent, SwiftCurrent_SwiftUI, and SwiftCurrent_CLI dependencies via SPM.

Building after doing this resulted in 15 build errors in the SwiftCurrent_CLI target stemming from a library called "_InternalSwiftSyntaxParser". Likely due to this bit from the SwiftSyntax README:

Embedding SwiftSyntax in an Application

SwiftSyntax depends on the lib_InternalSwiftSyntaxParser.dylib/.so library which provides a C interface to the underlying Swift C++ parser. When you do swift build SwiftSyntax links and uses the library included in the Swift toolchain. If you are building an application make sure to embed _InternalSwiftSyntaxParser as part of your application's libraries.

You can either copy lib_InternalSwiftSyntaxParser.dylib/.so directly from the toolchain or even build it yourself from the Swift repository, as long as you are matching the same tags or branches in both the SwiftSyntax and Swift repositories. To build it for the host os (macOS/linux) use the following steps:

git clone https://github.com/apple/swift.git
./swift/utils/update-checkout --clone
./swift/utils/build-parser-lib --release --no-assertions --build-dir /tmp/parser-lib-build

Embedding in an iOS Application

You need to build lib_InternalSwiftSyntaxParser.dylib yourself, you cannot copy it from the toolchain. Follow the instructions above and change the invocation of build-parser-lib accordingly:

./swift/utils/build-parser-lib --release --no-assertions --build-dir /tmp/parser-lib-build-iossim --host iphonesimulator --architectures x86_64
./swift/utils/build-parser-lib --release --no-assertions --build-dir /tmp/parser-lib-build-ios --host iphoneos --architectures arm64

Version

SwiftCurrent Version 5.1.3
Xcode Version 13.3
macOS version 12.3

Relevant code sample

No response

Relevant log output

ld: warning: Could not find or use auto-linked library '_InternalSwiftSyntaxParser'
Undefined symbols for architecture x86_64:
  "_swiftparse_syntax_structure_versioning_identifier", referenced from:
      static SwiftSyntax.SyntaxParser.verifyNodeDeclarationHash() -> Swift.Bool in SwiftSyntax.o
  "_swiftparse_diagnostic_get_fixit", referenced from:
      closure #2 (Swift.UInt32) -> SwiftSyntax.FixIt in SwiftSyntax.Diagnostic.init(diag: Swift.UnsafeRawPointer, using: SwiftSyntax.SourceLocationConverter?) -> SwiftSyntax.Diagnostic in SwiftSyntax.o
  "_swiftparse_diagnostic_get_range", referenced from:
      closure #1 (Swift.UInt32) -> SwiftSyntax.SourceRange in SwiftSyntax.Diagnostic.init(diag: Swift.UnsafeRawPointer, using: SwiftSyntax.SourceLocationConverter?) -> SwiftSyntax.Diagnostic in SwiftSyntax.o
  "_swiftparse_diagnostic_get_message", referenced from:
      SwiftSyntax.Diagnostic.Message.init(Swift.UnsafeRawPointer) -> SwiftSyntax.Diagnostic.Message in SwiftSyntax.o
  "_swiftparse_diagnostic_get_range_count", referenced from:
      SwiftSyntax.Diagnostic.init(diag: Swift.UnsafeRawPointer, using: SwiftSyntax.SourceLocationConverter?) -> SwiftSyntax.Diagnostic in SwiftSyntax.o
  "_swiftparse_diagnostic_get_fixit_count", referenced from:
      SwiftSyntax.Diagnostic.init(diag: Swift.UnsafeRawPointer, using: SwiftSyntax.SourceLocationConverter?) -> SwiftSyntax.Diagnostic in SwiftSyntax.o
  "_swiftparse_parse_string", referenced from:
      closure #4 (Swift.UnsafePointer<Swift.Int8>) -> Swift.UnsafeMutableRawPointer? in static SwiftSyntax.SyntaxParser.(parseRaw in _FF480AC1827F0899EF1492D28392D5EA)(Swift.String, SwiftSyntax.IncrementalParseTransition?, Swift.String, SwiftSyntax.DiagnosticEngine?) -> SwiftSyntax.RawSyntax in SwiftSyntax.o
  "_swiftparse_diagnostic_get_source_loc", referenced from:
      SwiftSyntax.Diagnostic.init(diag: Swift.UnsafeRawPointer, using: SwiftSyntax.SourceLocationConverter?) -> SwiftSyntax.Diagnostic in SwiftSyntax.o
  "_swiftparse_diagnostic_get_severity", referenced from:
      closure #3 (Swift.UnsafeRawPointer?) -> () in static SwiftSyntax.SyntaxParser.(parseRaw in _FF480AC1827F0899EF1492D28392D5EA)(Swift.String, SwiftSyntax.IncrementalParseTransition?, Swift.String, SwiftSyntax.DiagnosticEngine?) -> SwiftSyntax.RawSyntax in SwiftSyntax.o
      SwiftSyntax.Diagnostic.Message.init(Swift.UnsafeRawPointer) -> SwiftSyntax.Diagnostic.Message in SwiftSyntax.o
  "_swiftparse_parser_create", referenced from:
      static SwiftSyntax.SyntaxParser.(parseRaw in _FF480AC1827F0899EF1492D28392D5EA)(Swift.String, SwiftSyntax.IncrementalParseTransition?, Swift.String, SwiftSyntax.DiagnosticEngine?) -> SwiftSyntax.RawSyntax in SwiftSyntax.o
  "_swiftparse_parser_set_node_handler", referenced from:
      static SwiftSyntax.SyntaxParser.(parseRaw in _FF480AC1827F0899EF1492D28392D5EA)(Swift.String, SwiftSyntax.IncrementalParseTransition?, Swift.String, SwiftSyntax.DiagnosticEngine?) -> SwiftSyntax.RawSyntax in SwiftSyntax.o
  "_swiftparse_parser_set_node_lookup", referenced from:
      static SwiftSyntax.SyntaxParser.(parseRaw in _FF480AC1827F0899EF1492D28392D5EA)(Swift.String, SwiftSyntax.IncrementalParseTransition?, Swift.String, SwiftSyntax.DiagnosticEngine?) -> SwiftSyntax.RawSyntax in SwiftSyntax.o
  "_swiftparse_parser_dispose", referenced from:
      $defer #1 () -> () in static SwiftSyntax.SyntaxParser.(parseRaw in _FF480AC1827F0899EF1492D28392D5EA)(Swift.String, SwiftSyntax.IncrementalParseTransition?, Swift.String, SwiftSyntax.DiagnosticEngine?) -> SwiftSyntax.RawSyntax in SwiftSyntax.o
  "_swiftparse_parser_set_diagnostic_handler", referenced from:
      static SwiftSyntax.SyntaxParser.(parseRaw in _FF480AC1827F0899EF1492D28392D5EA)(Swift.String, SwiftSyntax.IncrementalParseTransition?, Swift.String, SwiftSyntax.DiagnosticEngine?) -> SwiftSyntax.RawSyntax in SwiftSyntax.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Code of Conduct

  • I agree to follow this project's Code of Conduct
@morganzellers morganzellers added the bug Something isn't working label Apr 7, 2022
@morganzellers morganzellers added this to the Data Driven Workflows milestone Apr 7, 2022
@morganzellers
Copy link
Contributor Author

@Tyler-Keith-Thompson
Copy link
Collaborator

The 5.7 version of Swift-Syntax should do even better at fixing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants