Skip to content

Commit 412e759

Browse files
author
Greg Soltis
authored
Expose library version, move it out of options (#588)
* slight cleanup * Use -D defines for versions * Undo FIROptionsTest change * Drop failed macro attempt * Add correct version to podspec * Add newline * Shuffle files around * Bring back log change * Fix change * Fix space
1 parent 1ede1c9 commit 412e759

File tree

5 files changed

+68
-1
lines changed

5 files changed

+68
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ Podfile.lock
5757

5858
# CMake
5959
.downloads
60+
.idea/

Firebase/Core/FIRLogger.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#import "Private/FIRLogger.h"
1616

1717
#import "FIRLoggerLevel.h"
18+
#import "FIRVersion.h"
1819
#import "third_party/FIRAppEnvironmentUtil.h"
1920

2021
#include <asl.h>
@@ -229,7 +230,7 @@ void FIRLogBasic(FIRLoggerLevel level,
229230
NSCAssert(numberOfMatches == 1, @"Incorrect message code format.");
230231
#endif
231232
NSString *logMsg = [[NSString alloc] initWithFormat:message arguments:args_ptr];
232-
logMsg = [NSString stringWithFormat:@"%@[%@] %@", service, messageCode, logMsg];
233+
logMsg = [NSString stringWithFormat:@"%s - %@[%@] %@", FirebaseVersionString, service, messageCode, logMsg];
233234
dispatch_async(sFIRClientQueue, ^{
234235
asl_log(sFIRLoggerClient, NULL, level, "%s", logMsg.UTF8String);
235236
});

Firebase/Core/FIRVersion.m

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2017 Google
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+
18+
19+
#ifndef Firebase_VERSION
20+
#error "Firebase_VERSION is not defined: add -DFirebase_VERSION=... to the build invocation"
21+
#endif
22+
23+
#ifndef FIRCore_VERSION
24+
#error "FIRCore_VERSION is not defined: add -DFIRCore_VERSION=... to the build invocation"
25+
#endif
26+
27+
28+
// The following two macros supply the incantation so that the C
29+
// preprocessor does not try to parse the version as a floating
30+
// point number. See
31+
// https://www.guyrutenberg.com/2008/12/20/expanding-macros-into-string-constants-in-c/
32+
#define STR(x) STR_EXPAND(x)
33+
#define STR_EXPAND(x) #x
34+
35+
const unsigned char *const FirebaseVersionString =
36+
(const unsigned char *const)STR(Firebase_VERSION);
37+
38+
const unsigned char *const FirebaseCoreVersionString =
39+
(const unsigned char *const)STR(FIRCore_VERSION);

Firebase/Core/Private/FIRVersion.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2017 Google
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 <Foundation/Foundation.h>
18+
19+
/** The version of the Firebase SDK. */
20+
FOUNDATION_EXPORT const unsigned char *const FirebaseVersionString;
21+
22+
/** The version of the FirebaseCore Component. */
23+
FOUNDATION_EXPORT const unsigned char *const FirebaseCoreVersionString;

FirebaseCore.podspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ Firebase Core includes FIRApp and FIROptions which provide central configuration
2828
s.private_header_files = 'Firebase/Core/Private/*.h'
2929
s.framework = 'SystemConfiguration'
3030
s.dependency 'GoogleToolboxForMac/NSData+zlib', '~> 2.1'
31+
s.pod_target_xcconfig = {
32+
'OTHER_CFLAGS' => '-DFIRCore_VERSION=' + s.version.to_s + ' -DFirebase_VERSION=4.8.0'
33+
}
3134
end

0 commit comments

Comments
 (0)