OLD | NEW |
1 Protocol Buffers - Google's data interchange format | 1 Protocol Buffers - Google's data interchange format |
2 =================================================== | 2 =================================================== |
3 | 3 |
4 [![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https
://travis-ci.org/google/protobuf) | 4 [![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https
://travis-ci.org/google/protobuf) |
5 | 5 |
6 Copyright 2008 Google Inc. | 6 Copyright 2008 Google Inc. |
7 | 7 |
8 This directory contains the Objective C Protocol Buffers runtime library. | 8 This directory contains the Objective C Protocol Buffers runtime library. |
9 | 9 |
10 Requirements | 10 Requirements |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 *or* | 38 *or* |
39 | 39 |
40 Add `objectivec/\*.h` & `objectivec/\*.m` except for | 40 Add `objectivec/\*.h` & `objectivec/\*.m` except for |
41 `objectivec/GPBProtocolBuffers.m` to your project. | 41 `objectivec/GPBProtocolBuffers.m` to your project. |
42 | 42 |
43 | 43 |
44 If the target is using ARC, remember to turn off ARC (`-fno-objc-arc`) for the | 44 If the target is using ARC, remember to turn off ARC (`-fno-objc-arc`) for the |
45 `.m` files. | 45 `.m` files. |
46 | 46 |
47 The files generated by `protoc` for the `*.proto` files (`\*.pbobjc.h` and | 47 The files generated by `protoc` for the `*.proto` files (`\*.pbobjc.h' and |
48 `\*.pbobjc.m`) are then also added to the target. | 48 `\*.pbobjc.m`) are then also added to the target. |
49 | 49 |
50 Usage | 50 Usage |
51 ----- | 51 ----- |
52 | 52 |
53 The objects generated for messages should work like any other Objective C | 53 The objects generated for messages should work like any other Objective C |
54 object. They are mutable objects, but if you don't change them, they are safe | 54 object. They are mutable objects, but if you don't change them, they are safe |
55 to share between threads (similar to passing an NSMutableDictionary between | 55 to share between threads (similar to passing an NSMutableDictionary between |
56 threads/queues; as long as no one mutates it, things are fine). | 56 threads/queues; as long as no one mutates it, things are fine). |
57 | 57 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 having an *explicit* and *default* value. You can always get the value of the | 116 having an *explicit* and *default* value. You can always get the value of the |
117 property. In the case that it hasn't been set you will get the default. In | 117 property. In the case that it hasn't been set you will get the default. In |
118 cases where you need to know whether it was set explicitly or you are just | 118 cases where you need to know whether it was set explicitly or you are just |
119 getting the default, you can use the `has\[NAME\]` property. If the value has | 119 getting the default, you can use the `has\[NAME\]` property. If the value has |
120 been set, and you want to clear it, you can set the `has\[NAME\]` to `NO`. | 120 been set, and you want to clear it, you can set the `has\[NAME\]` to `NO`. |
121 *proto3* syntax messages do away with this concept, thus the default values are | 121 *proto3* syntax messages do away with this concept, thus the default values are |
122 never included when the message is encoded. | 122 never included when the message is encoded. |
123 | 123 |
124 The Objective C classes/enums can be used from Swift code. | 124 The Objective C classes/enums can be used from Swift code. |
125 | 125 |
126 Objective C Generator Proto File Options | 126 Objective C Generator Options |
127 ---------------------------------------- | 127 ----------------------------- |
128 | 128 |
129 **objc_class_prefix=\<prefix\>** (no default) | 129 **objc_class_prefix=\<prefix\>** (no default) |
130 | 130 |
131 Since Objective C uses a global namespace for all of its classes, there can | 131 Since Objective C uses a global namespace for all of its classes, there can |
132 be collisions. This option provides a prefix that will be added to the Enums | 132 be collisions. This option provides a prefix that will be added to the Enums |
133 and Objects (for messages) generated from the proto. Convention is to base | 133 and Objects (for messages) generated from the proto. Convention is to base |
134 the prefix on the package the proto is in. | 134 the prefix on the package the proto is in. |
135 | 135 |
136 Objective C Generator `protoc` Options | |
137 -------------------------------------- | |
138 | |
139 When generating Objective C code, `protoc` supports a `--objc_opt` argument; the | |
140 argument is comma-delimited name/value pairs (_key=value,key2=value2_). The | |
141 _keys_ are used to change the behavior during generation. The currently | |
142 supported keys are: | |
143 | |
144 * `generate_for_named_framework`: The `value` used for this key will be used | |
145 when generating the `#import` statements in the generated code. Instead | |
146 of being plain `#import "some/path/file.pbobjc.h"` lines, they will be | |
147 framework based, i.e. - `#import <VALUE/file.pbobjc.h>`. | |
148 | |
149 _NOTE:_ If this is used with `named_framework_to_proto_path_mappings_path`, | |
150 then this is effectively the _default_ to use for everything that wasn't | |
151 mapped by the other. | |
152 | |
153 * `named_framework_to_proto_path_mappings_path`: The `value` used for this key | |
154 is a path to a file containing the listing of framework names and proto | |
155 files. The generator uses this to decide if another proto file referenced | |
156 should use a framework style import vs. a user level import | |
157 (`#import <FRAMEWORK/file.pbobjc.h>` vs `#import "dir/file.pbobjc.h"`). | |
158 | |
159 The format of the file is: | |
160 * An entry is a line of `frameworkName: file.proto, dir/file2.proto`. | |
161 * Comments start with `#`. | |
162 * A comment can go on a line after an entry. | |
163 (i.e. - `frameworkName: file.proto # comment`) | |
164 | |
165 Any number of files can be listed for a framework, just separate them with | |
166 commas. | |
167 | |
168 There can be multiple lines listing the same frameworkName incase it has a | |
169 lot of proto files included in it; and having multiple lines makes things | |
170 easier to read. | |
171 | |
172 Contributing | 136 Contributing |
173 ------------ | 137 ------------ |
174 | 138 |
175 Please make updates to the tests along with changes. If just changing the | 139 Please make updates to the tests along with changes. If just changing the |
176 runtime, the Xcode projects can be used to build and run tests. If your change | 140 runtime, the Xcode projects can be used to build and run tests. If your change |
177 also requires changes to the generated code, | 141 also requires changes to the generated code, |
178 `objectivec/DevTools/full_mac_build.sh` can be used to easily rebuild and test | 142 `objectivec/DevTools/full_mac_build.sh` can be used to easily rebuild and test |
179 changes. Passing `-h` to the script will show the addition options that could | 143 changes. Passing `-h` to the script will show the addition options that could |
180 be useful. | 144 be useful. |
181 | 145 |
182 Documentation | 146 Documentation |
183 ------------- | 147 ------------- |
184 | 148 |
185 The complete documentation for Protocol Buffers is available via the | 149 The complete documentation for Protocol Buffers is available via the |
186 web at: | 150 web at: |
187 | 151 |
188 https://developers.google.com/protocol-buffers/ | 152 https://developers.google.com/protocol-buffers/ |
OLD | NEW |