Skip to content

Commit

Permalink
Merge pull request #1593 from thomasvl/framework_includes
Browse files Browse the repository at this point in the history
Better support for using the proto library from a framework.
  • Loading branch information
thomasvl committed May 24, 2016
2 parents 173daf1 + 7da023b commit 5d0c2ee
Show file tree
Hide file tree
Showing 28 changed files with 543 additions and 95 deletions.
6 changes: 5 additions & 1 deletion Protobuf.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Pod::Spec.new do |s|
s.homepage = 'https://github.com/google/protobuf'
s.license = 'New BSD'
s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' }
s.cocoapods_version = '>= 1.0'

s.source = { :git => 'https://github.com/google/protobuf.git',
:tag => "v#{s.version}" }
Expand All @@ -32,7 +33,10 @@ Pod::Spec.new do |s|
# The following would cause duplicate symbol definitions. GPBProtocolBuffers is expected to be
# left out, as it's an umbrella implementation file.
s.exclude_files = 'objectivec/GPBProtocolBuffers.m'
s.header_mappings_dir = 'objectivec'

# Set a CPP symbol so the code knows to use framework imports.
s.user_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' }
s.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' }

s.ios.deployment_target = '7.1'
s.osx.deployment_target = '10.9'
Expand Down
39 changes: 29 additions & 10 deletions objectivec/GPBProtocolBuffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,33 @@
#import "GPBWellKnownTypes.h"
#import "GPBWireFormat.h"

// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif

// Well-known proto types
#import "google/protobuf/Any.pbobjc.h"
#import "google/protobuf/Api.pbobjc.h"
#import "google/protobuf/Duration.pbobjc.h"
#import "google/protobuf/Empty.pbobjc.h"
#import "google/protobuf/FieldMask.pbobjc.h"
#import "google/protobuf/SourceContext.pbobjc.h"
#import "google/protobuf/Struct.pbobjc.h"
#import "google/protobuf/Timestamp.pbobjc.h"
#import "google/protobuf/Type.pbobjc.h"
#import "google/protobuf/Wrappers.pbobjc.h"
#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <Protobuf/Any.pbobjc.h>
#import <Protobuf/Api.pbobjc.h>
#import <Protobuf/Duration.pbobjc.h>
#import <Protobuf/Empty.pbobjc.h>
#import <Protobuf/FieldMask.pbobjc.h>
#import <Protobuf/SourceContext.pbobjc.h>
#import <Protobuf/Struct.pbobjc.h>
#import <Protobuf/Timestamp.pbobjc.h>
#import <Protobuf/Type.pbobjc.h>
#import <Protobuf/Wrappers.pbobjc.h>
#else
#import "google/protobuf/Any.pbobjc.h"
#import "google/protobuf/Api.pbobjc.h"
#import "google/protobuf/Duration.pbobjc.h"
#import "google/protobuf/Empty.pbobjc.h"
#import "google/protobuf/FieldMask.pbobjc.h"
#import "google/protobuf/SourceContext.pbobjc.h"
#import "google/protobuf/Struct.pbobjc.h"
#import "google/protobuf/Timestamp.pbobjc.h"
#import "google/protobuf/Type.pbobjc.h"
#import "google/protobuf/Wrappers.pbobjc.h"
#endif
15 changes: 13 additions & 2 deletions objectivec/GPBWellKnownTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,19 @@

#import <Foundation/Foundation.h>

#import "google/protobuf/Duration.pbobjc.h"
#import "google/protobuf/Timestamp.pbobjc.h"
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif

#if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <Protobuf/Duration.pbobjc.h>
#import <Protobuf/Timestamp.pbobjc.h>
#else
#import "google/protobuf/Duration.pbobjc.h"
#import "google/protobuf/Timestamp.pbobjc.h"
#endif

NS_ASSUME_NONNULL_BEGIN

Expand Down
9 changes: 9 additions & 0 deletions objectivec/Tests/unittest_objc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

syntax = "proto2";

import "google/protobuf/any.proto";
import "google/protobuf/unittest.proto";

package protobuf_unittest;
Expand Down Expand Up @@ -447,3 +448,11 @@ message BoolOnlyMessage {
optional bool bool_field_31 = 31;
optional bool bool_field_32 = 32;
}

// Reference to a WKT to test (via generated code inspection), the handling
// of #imports. Within the WKTs, references to each other are just path
// based imports, but when reference from another proto file, they should be
// conditional to support the framework import style.
message WKTRefereceMessage {
optional google.protobuf.Any an_any = 1;
}
12 changes: 11 additions & 1 deletion objectivec/google/protobuf/Any.pbobjc.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions objectivec/google/protobuf/Any.pbobjc.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion objectivec/google/protobuf/Api.pbobjc.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 21 additions & 4 deletions objectivec/google/protobuf/Api.pbobjc.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion objectivec/google/protobuf/Duration.pbobjc.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions objectivec/google/protobuf/Duration.pbobjc.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion objectivec/google/protobuf/Empty.pbobjc.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions objectivec/google/protobuf/Empty.pbobjc.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion objectivec/google/protobuf/FieldMask.pbobjc.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions objectivec/google/protobuf/FieldMask.pbobjc.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion objectivec/google/protobuf/SourceContext.pbobjc.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions objectivec/google/protobuf/SourceContext.pbobjc.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5d0c2ee

Please sign in to comment.