Skip to content

[Objective-C] Add ability to pass objc_class_prefix as an argument vs file option #9469

Closed
@dnkoutso

Description

@dnkoutso

What language does this apply to?
Objective-C

If it's a proto syntax change, is it for proto2 or proto3?
N/A

If it's about generated code change, what programming language?
Objective-C

Describe the problem you are trying to solve.
While the objc_class_prefix file option works for most cases and for a single iOS app, it does not scale well when multiple iOS apps want consume the same .proto file but use a different class prefix throughout their codebase.

Describe the solution you'd like
It would be nice if the objc_class_prefix can be passed as an --objc_opt argument, similar to use_package_as_prefix. This would allow iOS apps to invoke protoc and pass a different prefix to use. Example invocation:

protoc --objc_out=my_proto.proto --objc_opt=objc_class_prefix=SMPL

This would allow different iOS apps to consume the same .proto file and avoid having to sed or somehow edit the .proto file to update the objc_class_prefix prior to protoc invocation.

This option should be honored after the file option but before the use_package_as_prefix option and documentation should state that. We could also error out if both options are passed.

Describe alternatives you've considered
Not many right now, as mentioned above, the current workaround is to edit the .proto file right before the protoc invocation to workaround this issue.

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions