Skip to content

Commit 77f92cd

Browse files
authored
Stop using built-in CMake Framework support (#5316)
* Fix previously unknown warnings These become visible once flags are handled uniformly across all Firestore targets in an upcoming build change. * Stop using built-in CMake Framework support CMake has built-in support for building Framework bundles (briefly: bundles of libraries, associated headers, and resources) but this doesn't work well for our needs. 1. In CMake 3.5.1 (our earliest supported CMake version) it doesn't copy headers properly at build time. 2. Even up to CMake 3.15.5, CMake doesn't handle link-line multiplicity correctly. CMake passes the static library location within the framework and this seems to cause the linker to mishandle Objective-C metaclass information resulting in duplicate symbols. Building with `-framework` flags works correctly. Previously we partially worked around the latter problem by building some frameworks as shared instead of static frameworks, but this is problematic because this mode of operation isn't actually intended and is unsupported as far as the rest of Firebase is concerned. This turned out to be fragile though and while refactoring libraries this workaround broke. Rather than piling on additional workarounds, this change converts the frameworks to simple library targets and emulates framework imports through include paths. Additionally, this starts refactoring our cmake helper functions to make them more like built-in functions. This makes it possible to freely use different CMake features that were made difficult by trying to wrap everything up in a single CMake command. * style.sh generated changes * Review feedback * More review feedback
1 parent a60a0e2 commit 77f92cd

21 files changed

+222
-257
lines changed

FirebaseCore/CMakeLists.txt

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,29 @@ if(NOT APPLE)
1616
return()
1717
endif()
1818

19-
file(GLOB sources Sources/*.m)
2019
file(GLOB headers Sources/Private/*.h Sources/Public/*.h)
20+
file(GLOB sources Sources/*.m)
2121

2222
podspec_version(version ${PROJECT_SOURCE_DIR}/FirebaseCore.podspec)
23-
firebase_version(firebase_ios_version ${PROJECT_SOURCE_DIR}/FirebaseCore.podspec)
24-
25-
firebase_ios_objc_framework(
26-
FirebaseCore
27-
SOURCES ${sources}
28-
HEADERS ${headers}
29-
VERSION ${version}
30-
DEFINES
31-
FIRCore_VERSION=${version}
32-
Firebase_VERSION=${firebase_ios_version}
33-
INCLUDES
34-
${PROJECT_SOURCE_DIR}
35-
DEPENDS
36-
FirebaseCoreDiagnosticsInterop
37-
GoogleUtilities
38-
"-framework Foundation"
39-
DISABLE_STRICT_WARNINGS
40-
EXCLUDE_FROM_ALL
23+
firebase_version(firebase_version ${PROJECT_SOURCE_DIR}/FirebaseCore.podspec)
24+
25+
firebase_ios_add_framework(
26+
FirebaseCore DISABLE_STRICT_WARNINGS EXCLUDE_FROM_ALL ${headers} ${sources}
27+
)
28+
29+
firebase_ios_framework_public_headers(FirebaseCore ${headers})
30+
31+
target_compile_definitions(
32+
FirebaseCore PRIVATE
33+
FIRCore_VERSION=${version}
34+
Firebase_VERSION=${firebase_version}
35+
)
36+
37+
target_link_libraries(
38+
FirebaseCore PRIVATE
39+
"-framework Foundation"
40+
FirebaseCoreDiagnosticsInterop
41+
GoogleUtilities
4142
)
4243

4344
if(IOS)

Firestore/Example/Benchmarks/remote_document_cache_benchmark.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
void WaitForPendingWrites(FIRFirestore* db) {
9191
dispatch_semaphore_t done = dispatch_semaphore_create(0);
92-
[db waitForPendingWritesWithCompletion:^(NSError* error) {
92+
[db waitForPendingWritesWithCompletion:^(NSError*) {
9393
dispatch_semaphore_signal(done);
9494
}];
9595
dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
@@ -107,7 +107,7 @@ void WriteDocs(FIRCollectionReference* collection, int64_t count, bool match) {
107107

108108
void Shutdown(FIRFirestore* db) {
109109
dispatch_semaphore_t done = dispatch_semaphore_create(0);
110-
[db terminateWithCompletion:^(NSError* error) {
110+
[db terminateWithCompletion:^(NSError*) {
111111
dispatch_semaphore_signal(done);
112112
}];
113113
dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);

Firestore/Example/Tests/Integration/API/FIRListenerRegistrationTests.mm

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ - (void)testCanBeRemoved {
3131
FIRDocumentReference *docRef = [collectionRef documentWithAutoID];
3232

3333
__block int callbacks = 0;
34-
id<FIRListenerRegistration> one = [collectionRef
35-
addSnapshotListener:^(FIRQuerySnapshot *_Nullable snapshot, NSError *_Nullable error) {
34+
id<FIRListenerRegistration> one =
35+
[collectionRef addSnapshotListener:^(FIRQuerySnapshot *, NSError *_Nullable error) {
3636
XCTAssertNil(error);
3737
callbacks++;
3838
}];
3939

40-
id<FIRListenerRegistration> two = [collectionRef
41-
addSnapshotListener:^(FIRQuerySnapshot *_Nullable snapshot, NSError *_Nullable error) {
40+
id<FIRListenerRegistration> two =
41+
[collectionRef addSnapshotListener:^(FIRQuerySnapshot *, NSError *_Nullable error) {
4242
XCTAssertNil(error);
4343
callbacks++;
4444
}];
@@ -68,12 +68,11 @@ - (void)testCanBeRemovedTwice {
6868
FIRCollectionReference *collectionRef = [self collectionRef];
6969
FIRDocumentReference *docRef = [collectionRef documentWithAutoID];
7070

71-
id<FIRListenerRegistration> one = [collectionRef
72-
addSnapshotListener:^(FIRQuerySnapshot *_Nullable snapshot, NSError *_Nullable error){
73-
}];
74-
id<FIRListenerRegistration> two = [docRef
75-
addSnapshotListener:^(FIRDocumentSnapshot *_Nullable snapshot, NSError *_Nullable error){
71+
id<FIRListenerRegistration> one =
72+
[collectionRef addSnapshotListener:^(FIRQuerySnapshot *, NSError *){
7673
}];
74+
id<FIRListenerRegistration> two = [docRef addSnapshotListener:^(FIRDocumentSnapshot *, NSError *){
75+
}];
7776

7877
[one remove];
7978
[one remove];
@@ -88,14 +87,14 @@ - (void)testCanBeRemovedIndependently {
8887

8988
__block int callbacksOne = 0;
9089
__block int callbacksTwo = 0;
91-
id<FIRListenerRegistration> one = [collectionRef
92-
addSnapshotListener:^(FIRQuerySnapshot *_Nullable snapshot, NSError *_Nullable error) {
90+
id<FIRListenerRegistration> one =
91+
[collectionRef addSnapshotListener:^(FIRQuerySnapshot *, NSError *_Nullable error) {
9392
XCTAssertNil(error);
9493
callbacksOne++;
9594
}];
9695

97-
id<FIRListenerRegistration> two = [collectionRef
98-
addSnapshotListener:^(FIRQuerySnapshot *_Nullable snapshot, NSError *_Nullable error) {
96+
id<FIRListenerRegistration> two =
97+
[collectionRef addSnapshotListener:^(FIRQuerySnapshot *, NSError *_Nullable error) {
9998
XCTAssertNil(error);
10099
callbacksTwo++;
101100
}];
@@ -137,7 +136,7 @@ - (void)testCanOutliveDocumentReference {
137136
@autoreleasepool {
138137
FIRDocumentReference *docRef = [collectionRef documentWithAutoID];
139138
documentID = docRef.documentID;
140-
registration = [docRef addSnapshotListener:^(FIRDocumentSnapshot *snapshot, NSError *error) {
139+
registration = [docRef addSnapshotListener:^(FIRDocumentSnapshot *snapshot, NSError *) {
141140
if (snapshot.exists) {
142141
[seen fulfill];
143142
}

Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ - (void)verifySnapshotWithResolvedTimestamps:(FIRDocumentSnapshot *)snapshot {
137137
- (void)runTransactionBlock:(void (^)(FIRTransaction *transaction))transactionBlock {
138138
XCTestExpectation *expectation = [self expectationWithDescription:@"transaction complete"];
139139
[_docRef.firestore
140-
runTransactionWithBlock:^id(FIRTransaction *transaction, NSError **pError) {
140+
runTransactionWithBlock:^id(FIRTransaction *transaction, NSError **) {
141141
transactionBlock(transaction);
142142
return nil;
143143
}
144-
completion:^(id result, NSError *error) {
144+
completion:^(id, NSError *error) {
145145
XCTAssertNil(error);
146146
[expectation fulfill];
147147
}];
@@ -298,11 +298,11 @@ - (void)testServerTimestampsFailViaUpdateOnNonexistentDocument {
298298
- (void)testServerTimestampsFailViaTransactionUpdateOnNonexistentDocument {
299299
XCTestExpectation *expectation = [self expectationWithDescription:@"transaction complete"];
300300
[_docRef.firestore
301-
runTransactionWithBlock:^id(FIRTransaction *transaction, NSError **pError) {
301+
runTransactionWithBlock:^id(FIRTransaction *transaction, NSError **) {
302302
[transaction updateData:self->_updateData forDocument:self->_docRef];
303303
return nil;
304304
}
305-
completion:^(id result, NSError *error) {
305+
completion:^(id, NSError *error) {
306306
XCTAssertNotNil(error);
307307
XCTAssertEqualObjects(error.domain, FIRFirestoreErrorDomain);
308308
XCTAssertEqual(error.code, FIRFirestoreErrorCodeNotFound);

Firestore/Example/Tests/Integration/FSTSmokeTests.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ - (void)testCanReadAWrittenDocument {
4242
}
4343

4444
- (void)testObservesExistingDocument {
45-
[self readerAndWriterOnDocumentRef:^(NSString *path, FIRDocumentReference *readerRef,
45+
[self readerAndWriterOnDocumentRef:^(NSString *, FIRDocumentReference *readerRef,
4646
FIRDocumentReference *writerRef) {
4747
NSDictionary<NSString *, id> *data = [self chatMessage];
4848
[self writeDocumentRef:writerRef data:data];
@@ -59,7 +59,7 @@ - (void)testObservesExistingDocument {
5959
}
6060

6161
- (void)testObservesNewDocument {
62-
[self readerAndWriterOnDocumentRef:^(NSString *path, FIRDocumentReference *readerRef,
62+
[self readerAndWriterOnDocumentRef:^(NSString *, FIRDocumentReference *readerRef,
6363
FIRDocumentReference *writerRef) {
6464
id<FIRListenerRegistration> listenerRegistration =
6565
[readerRef addSnapshotListener:self.eventAccumulator.valueEventHandler];

Firestore/Example/Tests/Util/FSTEventAccumulator.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ - (BOOL)hasPendingWrites:(id)event {
9797
}
9898

9999
- (void (^)(id _Nullable, NSError *_Nullable))valueEventHandler {
100-
return ^void(id _Nullable value, NSError *_Nullable error) {
100+
return ^void(id _Nullable value, NSError *) {
101101
// We can't store nil in the _events array, but these are still interesting to tests so store
102102
// NSNull instead.
103103
id event = value ? value : [NSNull null];

Firestore/Example/Tests/Util/FSTHelpers.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ PatchMutation FSTTestPatchMutation(const absl::string_view path,
142142

143143
__block ObjectValue objectValue = ObjectValue::Empty();
144144
__block std::set<FieldPath> fieldMaskPaths;
145-
[values enumerateKeysAndObjectsUsingBlock:^(NSString *key, id value, BOOL *stop) {
145+
[values enumerateKeysAndObjectsUsingBlock:^(NSString *key, id value, BOOL *) {
146146
const FieldPath path = testutil::Field(util::MakeString(key));
147147
fieldMaskPaths.insert(path);
148148
if (![value isEqual:kDeleteSentinel]) {

Firestore/Source/API/FIRCollectionReference.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ - (instancetype)initWithPath:(ResourcePath)path
5454

5555
// Override the designated initializer from the super class.
5656
- (instancetype)initWithQuery:(api::Query &&)query {
57+
(void)query;
58+
5759
HARD_FAIL("Use FIRCollectionReference initWithPath: initializer.");
5860
}
5961

Firestore/Source/API/FIRFieldPath.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ + (instancetype)pathWithDotSeparatedString:(NSString *)path {
7474
}
7575

7676
- (id)copyWithZone:(NSZone *__nullable)zone {
77+
(void)zone;
7778
return [[[self class] alloc] initPrivate:_internalValue];
7879
}
7980

Firestore/Source/API/FIRFirestore.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ - (void)terminateWithCompletion:(nullable void (^)(NSError *_Nullable error))com
350350

351351
- (id<FIRListenerRegistration>)addSnapshotsInSyncListener:(void (^)(void))listener {
352352
std::unique_ptr<core::EventListener<Empty>> eventListener =
353-
core::EventListener<Empty>::Create([listener](const StatusOr<Empty> &v) { listener(); });
353+
core::EventListener<Empty>::Create([listener](const StatusOr<Empty> &) { listener(); });
354354
std::unique_ptr<ListenerRegistration> result =
355355
_firestore->AddSnapshotsInSyncListener(std::move(eventListener));
356356
return [[FSTListenerRegistration alloc] initWithRegistration:std::move(result)];

0 commit comments

Comments
 (0)