Lines Matching refs:Swift
1 # Protocol Buffers in Swift
6 proto2 and proto3 messages in Apple’s Swift programming language.
11 and Swift code in the same application should use the existing Objective-C proto
13 messages that uses features specific to Swift—optional types, algebraic
19 * By convention, both typical protobuf message names and Swift structs/classes
25 in Swift they are `lowerCamelCase` (as of the Swift 3 API design
26 guidelines). We will transform the names to match Swift convention, using
31 Swift they are `lowerCamelCase`. We will transform the names to match
32 Swift convention by removing the underscores and uppercasing the subsequent
35 ## Swift reserved words
37 Swift has a large set of reserved words—some always reserved and some
39 where they would not be confused). As of Swift 2.2, the set of always-reserved
67 While the backtick feature may not be widely known by all Swift developers, a
79 and proto3) map to features in Swift—what the code generated from a proto will
84 Modules are the main form of namespacing in Swift, but they are not declared
87 Swift, declarations in a Swift Package Manager manifest). They also do not
89 Swift does not yet provide a way to define submodules).
99 When present, this will cause `typealias`es to be added to the generated Swift
112 would generate the following Swift source:
133 instead of classes. Users will benefit from Swift’s built-in behavior with
142 and whose values are the value of the field with that number (up-cast to Swift’s
155 by non-optional properties in Swift, but this presents some problems/concerns.
175 not explicitly set, the user expects to get that value. This makes Swift
178 usage (Swift’s use of type inference and its lack of implicit conversions would
182 generated for a field of type `int32` would have Swift type `Int32!`. These
206 types is implemented in Swift, the language automatically handles the
209 copies are only made by the Swift runtime when mutation occurs. For example,
219 The following Swift code would act as commented, where setting deeply nested
243 relationships to backfill the appropriate properties on mutation. Swift provides
248 Proto scalar value fields will map to Swift types in the following way:
250 .proto Type | Swift Type
268 The proto spec defines a number of integral types that map to the same Swift
276 Swift’s lack of implicit conversions among types will make it slightly annoying
293 would be represented in Swift as
319 use the simple raw-value enum syntax provided by Swift. So the following enum in
329 would become this Swift enum:
348 accomplish this in Swift by using a case with an associated value for unknowns.
358 would become this Swift enum:
390 raw `Int32` type; Swift does not allow an enum with a raw type to have cases
398 Swift compiler considers it an error if switch statements are not exhaustive.
460 resettable properties will be added to Swift that eliminates this inconsistency.
471 The `allow_alias` option in protobuf slightly complicates the use of Swift enums
473 Swift lets us define static variables in an enum that alias actual cases. For
484 will be represented in Swift as:
509 Swift code.
514 Swift enums with associated values (algebraic types). These fields can also be
519 Taking all this into account, we can represent a `oneof` in Swift with two sets
527 Swift-idiomatic way of simultaneously checking which field is set and accessing
543 In Swift, we would generate an enum, a property for that enum, and properties
600 We will not include reflection or descriptors in the first version of the Swift
611 ### Each package is its own Swift module
613 Each proto package could be declared as its own Swift module, replacing dots
618 **This solution is simply not possible, however.** Swift modules cannot
623 long as there is no import cycle. If these packages were generated as Swift
629 We can “fake” namespaces in Swift by declaring empty structs with private
631 syntactic constructs, and because there is no pure Swift way to define
636 Types can be added to those intermediate package structs using Swift extensions.
637 For example, a message `Baz` in package `foo.bar` could be represented in Swift
660 Each of these constructs would actually be defined in a separate file; Swift
666 build targets contain Swift sources generated from different messages in the