nanopb crashing iOS app with extensions

362 views
Skip to first unread message

André Crabb

unread,
Feb 16, 2021, 10:51:20 AM2/16/21
to nanopb
Hello hello,

We're running into an issue instantiating our GPB commands in our iOS app.

Error
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Class GPBFileOptions not defined'

More Info
I received the .proto files from another of our teams, and I generated the ObjC files myself. We're using GPB 3.11.4
I'm using CocoaPod "Protobuf" on version 3.11.4 (https://cocoapods.org/pods/Protobuf)


Its true, this Pod doesn't have a file `GPBFileOptions`. Should it?


Call Stack
(Items 28 & 29 are ours, initiating a message.)
Screen Shot 2021-02-16 at 7.17.49 AM.png


These lines are in the bottom of our `nanopb.proto` file...

```
extend google.protobuf.FileOptions {
    optional NanoPBOptions nanopb_fileopt = 1010;
}

extend google.protobuf.MessageOptions {
    optional NanoPBOptions nanopb_msgopt = 1010;
}

extend google.protobuf.EnumOptions {
    optional NanoPBOptions nanopb_enumopt = 1010;
}

extend google.protobuf.FieldOptions {
    optional NanoPBOptions nanopb = 1010;
}
```
...and it looks like `MessageOptions`, `EnumOptions`, and `FieldOptions` are NOT part of the Protobuf Pod either.

Are extensions not supported in the ObjC version of GPB?


All help is appreciated :)
Cheers

Petteri Aimonen

unread,
Feb 16, 2021, 11:40:51 AM2/16/21
to nan...@googlegroups.com
Hi,

Sounds like the library you are using cannot handle the "options" syntax
of .proto files for some reason. It's part of standard protobuf so it
should, but it is a quite rarely used feature so might be missing for
that reason.

You could just remove anything nanopb-specific from your .proto file,
as they only affect nanopb and not other libraries. If you want to keep
the same .proto file in all your projects, nanopb can also read the
options from a separate .options file.

--
Petteri

On Tue, Feb 16, 2021 at 07:51:20AM -0800, André Crabb wrote:
> Hello hello,
>
> We're running into an issue instantiating our GPB commands in our iOS app.
>
> *Error*
> *** Terminating app due to uncaught exception
> 'NSInternalInconsistencyException', reason: 'Class GPBFileOptions not
> defined'
>
> *More Info*
> I received the .proto files from another of our teams, and I generated the
> ObjC files myself. We're using GPB 3.11.4
> I'm using CocoaPod "Protobuf" on version 3.11.4 (
> https://cocoapods.org/pods/Protobuf)
>
>
> Its true, this Pod doesn't have a file `GPBFileOptions`. Should it?
>
>
> *Call Stack*
> (Items 28 & 29 are ours, initiating a message.)
> [image: Screen Shot 2021-02-16 at 7.17.49 AM.png]
>
>
> These lines are in the bottom of our `nanopb.proto` file...
>
> ```
> extend google.protobuf.FileOptions {
> optional NanoPBOptions nanopb_fileopt = 1010;
> }
>
> extend google.protobuf.MessageOptions {
> optional NanoPBOptions nanopb_msgopt = 1010;
> }
>
> extend google.protobuf.EnumOptions {
> optional NanoPBOptions nanopb_enumopt = 1010;
> }
>
> extend google.protobuf.FieldOptions {
> optional NanoPBOptions nanopb = 1010;
> }
> ```
> ...and it looks like `MessageOptions`, `EnumOptions`, and `FieldOptions`
> are NOT part of the Protobuf Pod either.
>
> Are extensions not supported in the ObjC version of GPB?
>
>
> All help is appreciated :)
> Cheers
>
> --
> You received this message because you are subscribed to the Google Groups "nanopb" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nanopb+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/nanopb/8424c15f-a88a-4269-bb34-c46af3fe9b53n%40googlegroups.com.


André Crabb

unread,
Feb 16, 2021, 11:59:16 AM2/16/21
to nanopb
Hm, trying to re-run the `protoc` command to regenerate the files gives me these errors, which looks very similar to what's happening at runtime.
Am I missing some files at generation time?

```

└─> protoc --proto_path=. --objc_out=generated nanopb.proto 

nanopb.proto:155:8: "google.protobuf.FileOptions" is not defined.

nanopb.proto:159:8: "google.protobuf.MessageOptions" is not defined.

nanopb.proto:163:8: "google.protobuf.EnumOptions" is not defined.

nanopb.proto:167:8: "google.protobuf.FieldOptions" is not defined.

```

Reply all
Reply to author
Forward
0 new messages