Skip to content

Code generation failed with: NSTaskTerminationReason(rawValue: 1) #75

@0xifarouk

Description

@0xifarouk

I am getting this error when running the generate-grpc-code-from-protos plugin:

error: Code generation failed with: NSTaskTerminationReason(rawValue: 1):1.
        Executable: /opt/homebrew/bin/protoc
        Arguments: --plugin=protoc-gen-grpc-swift=/Users/farouk/Downloads/gRPC-Demo/.build/arm64-apple-macosx/debug/protoc-gen-grpc-swift-2-tool --grpc-swift_out=/Users/farouk/Downloads/gRPC-Demo/.build/plugins/generate-grpc-code-from-protos/outputs/ --grpc-swift_opt=Visibility=Internal --grpc-swift_opt=Server=true --grpc-swift_opt=Client=true --grpc-swift_opt=FileNaming=FullPath --grpc-swift_opt=UseAccessLevelOnImports=false
        protoc error output:
        Missing input file.

Here is the Package.swift file for the package:

// swift-tools-version: 6.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
  name: "gRPC-Demo",
  platforms: [.macOS(.v15)],
  products: [
    .library(name: "gRPC-Demo", targets: ["gRPC-Demo"]),
  ],
  dependencies: [
    .package(url: "https://github.com/grpc/grpc-swift-2.git", from: "2.0.0"),
    .package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "2.0.0"),
    .package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "2.0.0"),
  ],
  targets: [
    .target(
      name: "gRPC-Demo",
      dependencies: [
        .product(name: "GRPCCore", package: "grpc-swift-2"),
        .product(name: "GRPCNIOTransportHTTP2", package: "grpc-swift-nio-transport"),
        .product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
      ],
      plugins: [
        .plugin(name: "GRPCProtobufGenerator", package: "grpc-swift-protobuf")
      ]
    ),
  ]
)

grpc-swift-proto-generator-config.json:

{
  "generate": {
    "clients": true,
    "servers": true,
    "messages": true
  },
  "protoc": {
    "executablePath": "/opt/homebrew/bin/protoc"
  }
}

The .proto file:

syntax = "proto3";
package helloworld;

// The greeting service definition.
service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings
message HelloReply {
  string message = 1;
}

Finally here is the folder structure for the SPM:

Image

What am I doing wrong? Nothing is being generated, I even tried to run the hello-world example in the demo and it's failing with the same error!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions