-
Notifications
You must be signed in to change notification settings - Fork 137
Custom compiler options
Alexey Khokhlov edited this page Apr 2, 2015
·
2 revisions
enum AccessControl {
InternalEntities = 0;
PublicEntities = 1;
}
message SwiftFileOptions {
optional string class_prefix = 1;
optional AccessControl entities_access_control = 2 [default = InternalEntities];
optional bool compile_for_framework = 3 [default = true];
}
At now protobuf-swift's compiler is supporting three custom options(file options).
- Class Prefix
- Access Control
- Compile for framework
If you have use custom options, you need to add:
import 'google/protobuf/swift-descriptor.proto';
in your .proto
files.
###Class prefix
This option needs to generate class names with prefix.
Example:
import 'google/protobuf/swift-descriptor.proto';
option (.google.protobuf.swift_file_options).class_prefix = "Proto";
message NameWithPrefix
{
optional string str = 1;
}
Generated class has a name:
final internal class ProtoNameWithPrefix : GeneratedMessage
###Access control
option (.google.protobuf.swift_file_options).entities_access_control = PublicEntities;
All generated classes marks as internal
by default. If you want mark as public
, you can use entities_access_control
option.
option (.google.protobuf.swift_file_options).entities_access_control = PublicEntities;
message MessageWithCustomOption
{
optional string str = 1;
}
Generated class and all fields are marked a public
:
final public class MessageWithCustomOption : GeneratedMessage
###Compile for framework
option (.google.protobuf.swift_file_options).compile_for_framework = false;
This option deletes the string import ProtocolBuffers
of the generated files.
####If you will need some other options, write me. I will add them.