Skip to content

Commit 3e35561

Browse files
authored
Update to 7.x and fix some build errors (#6946)
1 parent a1af740 commit 3e35561

8 files changed

+82
-60
lines changed

FirebaseSegmentation.podspec

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseSegmentation'
3-
s.version = '0.1.0'
3+
s.version = '7.1.0-beta'
44
s.summary = 'Firebase Segmentation SDK'
55
s.description = <<-DESC
66
Firebase Segmentation enables you to associate your custom application instance ID with Firebase for user segmentation.
@@ -14,7 +14,7 @@ Firebase Segmentation enables you to associate your custom application instance
1414
:tag => 'Segmentation-' + s.version.to_s
1515
}
1616

17-
s.ios.deployment_target = '8.0'
17+
s.ios.deployment_target = '10.0'
1818
s.cocoapods_version = '>= 1.4.0'
1919
s.static_framework = true
2020
s.prefix_header_file = false
@@ -25,16 +25,15 @@ Firebase Segmentation enables you to associate your custom application instance
2525
]
2626
s.public_header_files = 'FirebaseSegmentation/Sources/Public/*.h'
2727

28-
s.dependency 'FirebaseCore', '~> 6.7'
29-
s.dependency 'FirebaseInstallations', '~> 1.7'
28+
s.dependency 'FirebaseCore', '~> 7.0'
29+
s.dependency 'FirebaseInstallations', '~> 7.0'
3030

3131
header_search_paths = {
3232
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"'
3333
}
3434

3535
s.pod_target_xcconfig = {
36-
'GCC_C_LANGUAGE_STANDARD' => 'c99',
37-
'GCC_PREPROCESSOR_DEFINITIONS' => 'FIRSegmentation_VERSION=' + s.version.to_s
36+
'GCC_C_LANGUAGE_STANDARD' => 'c99'
3837
}.merge(header_search_paths)
3938

4039
s.test_spec 'unit' do |unit_tests|

FirebaseSegmentation/Sources/FIRSegmentationComponent.m

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,10 @@
1616

1717
#import "FirebaseSegmentation/Sources/Private/FIRSegmentationComponent.h"
1818

19-
#import "FirebaseCore/Sources/Private/FIRAppInternal.h"
20-
#import "FirebaseCore/Sources/Private/FIRComponentContainer.h"
21-
#import "FirebaseCore/Sources/Private/FIROptionsInternal.h"
19+
#import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h"
2220
#import "FirebaseSegmentation/Sources/Private/FIRSegmentationInternal.h"
2321
#import "FirebaseSegmentation/Sources/SEGSegmentationConstants.h"
2422

25-
#ifndef FIRSegmentation_VERSION
26-
#error "FIRSegmentation_VERSION is not defined: \
27-
add -DFIRSegmentation_VERSION=... to the build invocation"
28-
#endif
29-
30-
#define STR(x) STR_EXPAND(x)
31-
#define STR_EXPAND(x) #x
32-
3323
@implementation FIRSegmentationComponent
3424

3525
/// Default method for retrieving a Segmentation instance, or creating one if it doesn't exist.
@@ -82,9 +72,7 @@ - (instancetype)initWithApp:(FIRApp *)app {
8272
+ (void)load {
8373
// Register as an internal library to be part of the initialization process. The name comes from
8474
// go/firebase-sdk-platform-info.
85-
[FIRApp registerInternalLibrary:self
86-
withName:@"fire-seg"
87-
withVersion:[NSString stringWithUTF8String:STR(FIRSegmentation_VERSION)]];
75+
[FIRApp registerInternalLibrary:self withName:@"fire-seg"];
8876
}
8977

9078
#pragma mark - Interoperability

FirebaseSegmentation/Sources/SEGContentManager.m

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,24 @@ - (void)associateCustomInstallationIdentiferNamed:(NSString *)customInstallation
6767
// Get the latest installation identifier
6868
FIRInstallations *installation = [self installationForApp:firebaseApp];
6969
if (installation == nil) {
70-
completionHandler(NO, @{kErrorDescription : @"Firebase Installations SDK not available"});
70+
completionHandler(NO, @{kSEGErrorDescription : @"Firebase Installations SDK not available"});
7171
}
7272
__weak SEGContentManager *weakSelf = self;
73-
[installation
74-
installationIDWithCompletion:^(NSString *_Nullable identifier, NSError *_Nullable error) {
75-
SEGContentManager *strongSelf = weakSelf;
76-
if (!strongSelf) {
77-
completionHandler(NO, @{kErrorDescription : @"Internal Error getting installation ID."});
78-
return;
79-
}
80-
81-
[strongSelf associateInstallationWithLatestIdentifier:identifier
82-
installation:installation
83-
customizedIdentifier:customInstallationID
84-
firebaseApp:firebaseApp
85-
error:error
86-
completion:completionHandler];
87-
}];
73+
[installation installationIDWithCompletion:^(NSString *_Nullable identifier,
74+
NSError *_Nullable error) {
75+
SEGContentManager *strongSelf = weakSelf;
76+
if (!strongSelf) {
77+
completionHandler(NO, @{kSEGErrorDescription : @"Internal Error getting installation ID."});
78+
return;
79+
}
80+
81+
[strongSelf associateInstallationWithLatestIdentifier:identifier
82+
installation:installation
83+
customizedIdentifier:customInstallationID
84+
firebaseApp:firebaseApp
85+
error:error
86+
completion:completionHandler];
87+
}];
8888
}
8989

9090
- (void)associateInstallationWithLatestIdentifier:(NSString *_Nullable)identifier
@@ -98,7 +98,7 @@ - (void)associateInstallationWithLatestIdentifier:(NSString *_Nullable)identifie
9898
if (error) {
9999
errorMessage = [errorMessage stringByAppendingString:error.description];
100100
}
101-
NSDictionary *errorDictionary = @{kErrorDescription : errorMessage};
101+
NSDictionary *errorDictionary = @{kSEGErrorDescription : errorMessage};
102102
completionHandler(NO, errorDictionary);
103103
return;
104104
}
@@ -125,7 +125,7 @@ - (void)associateInstallationWithToken:(FIRInstallationsAuthTokenResult *_Nullab
125125
if (error) {
126126
errorMessage = [errorMessage stringByAppendingString:error.description];
127127
}
128-
NSDictionary *errorDictionary = @{kErrorDescription : errorMessage};
128+
NSDictionary *errorDictionary = @{kSEGErrorDescription : errorMessage};
129129
completionHandler(NO, errorDictionary);
130130
return;
131131
}

FirebaseSegmentation/Sources/SEGDatabaseManager.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ - (void)createOrOpenDatabaseWithCompletion:(SEGRequestCompletion)completionHandl
137137
FIRLogError(kFIRLoggerSegmentation, @"I-SEG00006", @"Failed to create table.");
138138
// Create a new database if existing database file is corrupted.
139139
if (!SEGCreateFilePathIfNotExist(dbPath)) {
140-
completionHandler(
141-
NO,
142-
@{kSEGErrorDescription : @"Could not recreate database file at path: %@", dbpath});
140+
NSString *description =
141+
[NSString stringWithFormat:@"Could not recreate database file at path: %@", dbPath];
142+
completionHandler(NO, @{kSEGErrorDescription : description});
143143
return;
144144
}
145145
// Try to open the database with the new file.
@@ -361,7 +361,7 @@ - (BOOL)bindStringsToStatement:(sqlite3_stmt *)statement stringArray:(NSArray *)
361361
int index = 1;
362362
for (NSString *param in array) {
363363
if (![self bindStringToStatement:statement index:index string:param]) {
364-
return [self logErrorWithSQL:sql finalizeStatement:statement returnValue:NO];
364+
return [self logErrorWithSQL:nil finalizeStatement:statement returnValue:NO];
365365
}
366366
index++;
367367
}

FirebaseSegmentation/Sources/SEGSegmentationConstants.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,22 @@
2727
} while (0);
2828
#endif
2929

30-
static NSString* const kFIRLoggerSegmentation = @"[Firebase/Segmentation]";
30+
extern NSString* const kFIRLoggerSegmentation;
3131

3232
/// Keys for values stored in the Segmentation SDK.
33-
static NSString* const kSEGFirebaseApplicationIdentifierKey = @"firebase_app_identifier";
34-
static NSString* const kSEGCustomInstallationIdentifierKey = @"custom_installation_identifier";
35-
static NSString* const kSEGFirebaseInstallationIdentifierKey = @"firebase_installation_identifier";
36-
static NSString* const kSEGAssociationStatusKey = @"association_status";
33+
extern NSString* const kSEGFirebaseApplicationIdentifierKey;
34+
extern NSString* const kSEGCustomInstallationIdentifierKey;
35+
extern NSString* const kSEGFirebaseInstallationIdentifierKey;
36+
extern NSString* const kSEGAssociationStatusKey;
3737
/// Association Status
38-
static NSString* const kSEGAssociationStatusPending = @"PENDING";
39-
static NSString* const kSEGAssociationStatusAssociated = @"ASSOCIATED";
38+
extern NSString* const kSEGAssociationStatusPending;
39+
extern NSString* const kSEGAssociationStatusAssociated;
4040

4141
/// Segmentation error domain when logging errors.
42-
kFirebaseSegmentationErrorDomain = @"com.firebase.segmentation";
43-
44-
/// Segmentation FIRLogger domain.
45-
static NSString* const kFIRLoggerSegmentation = @"[Firebase/Segmentation]";
42+
extern NSString* const kFirebaseSegmentationErrorDomain;
4643

4744
/// Used for reporting generic internal Segmentation errors.
48-
NSString* const kSEGErrorDescription = @"SEGErrorDescription";
45+
extern NSString* const kSEGErrorDescription;
4946

5047
/// Segmentation Request Completion callback.
5148
/// @param success Decide whether the network operation succeeds.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import "FirebaseSegmentation/Sources/SEGSegmentationConstants.h"
18+
19+
NSString* const kFIRLoggerSegmentation = @"[Firebase/Segmentation]";
20+
21+
/// Keys for values stored in the Segmentation SDK.
22+
NSString* const kSEGFirebaseApplicationIdentifierKey = @"firebase_app_identifier";
23+
NSString* const kSEGCustomInstallationIdentifierKey = @"custom_installation_identifier";
24+
NSString* const kSEGFirebaseInstallationIdentifierKey = @"firebase_installation_identifier";
25+
NSString* const kSEGAssociationStatusKey = @"association_status";
26+
/// Association Status
27+
NSString* const kSEGAssociationStatusPending = @"PENDING";
28+
NSString* const kSEGAssociationStatusAssociated = @"ASSOCIATED";
29+
30+
/// Segmentation error domain when logging errors.
31+
NSString* const kFirebaseSegmentationErrorDomain = @"com.firebase.segmentation";
32+
33+
/// Used for reporting generic internal Segmentation errors.
34+
NSString* const kSEGErrorDescription = @"SEGErrorDescription";
35+
36+
/// Segmentation Request Completion callback.
37+
/// @param success Decide whether the network operation succeeds.
38+
/// @param result Return operation result data.
39+
typedef void (^SEGRequestCompletion)(BOOL success, NSDictionary<NSString*, id>* result);

FirebaseSegmentation/Tests/Unit/SEGContentManagerTests.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ - (void)setUp {
7171
authTokenWithCompletion:([OCMArg invokeBlockWithArgs:FISToken, [NSNull null], nil])]);
7272

7373
// Mock the network manager.
74-
FIROptions *options = [[FIROptions alloc] init];
75-
options.projectID = @"test-project-id";
76-
options.APIKey = @"AIzaSy-ApiKeyWithValidFormat_0123456789";
7774
self.networkManagerMock = OCMClassMock([SEGNetworkManager class]);
7875
OCMStub([self.networkManagerMock
7976
makeAssociationRequestToBackendWithData:[OCMArg any]

FirebaseSegmentation/Tests/Unit/SEGInitializationTests.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
#import <XCTest/XCTest.h>
1616

17-
#import "FirebaseCore/Sources/Public/FirebaseCore/FIRApp.h"
18-
#import "FirebaseCore/Sources/Public/FirebaseCore/FIROptions.h"
17+
#import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h"
1918
#import "FirebaseSegmentation/Sources/Public/FIRSegmentation.h"
2019

2120
@interface FIRSegmentation (ForTest)
@@ -31,7 +30,10 @@ @interface SEGInitializationTests : XCTestCase {
3130
@implementation SEGInitializationTests
3231

3332
- (void)setUp {
34-
FIROptions *options = [[FIROptions alloc] init];
33+
FIROptions *options = [[FIROptions alloc] initInternalWithOptionsDictionary:@{
34+
@"API_KEY" : @"AIzaSy-ApiKeyWithValidFormat_0123456789",
35+
@"PROJECT_ID" : @"test-firebase-project-id",
36+
}];
3537
options.APIKey = @"AIzaSy-ApiKeyWithValidFormat_0123456789";
3638
options.projectID = @"test-firebase-project-id";
3739
_segmentation = [[FIRSegmentation alloc] initWithAppName:@"test-firebase-app-name"

0 commit comments

Comments
 (0)