Skip to content

Commit c370f54

Browse files
authored
Fix LogHeartbeatInternal (#628)
When Swig generating "%csmethodmodifiers" code block, instead of keeping all preprocesser directives like "#if FIREBASE_PLATFORM_DESKTOP", it seem to preprocess the block directly and remove codes. In this case, Swig would consider FIREBASE_PLATFORM_DESKTOP never defined and remove the entire block in the generated code. This can be easily verified with ``` python scripts/build_scripts/build_zips.py --platform=macos --apis=auth ```
1 parent e974dd1 commit c370f54

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

app/src/swig/app.i

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@ static App *AppGetOrCreateInstance(const AppOptions *options,
158158
return instance;
159159
}
160160

161+
// Log a heartbeat only if the current platform is desktop platforms.
162+
static void LogHeartbeatForDesktop(App* app) {
163+
#if FIREBASE_PLATFORM_DESKTOP
164+
// Only need to call LogHeartbeat on desktop, since native mobile SDKs
165+
// Will handle heartbeat logging internally.
166+
app->LogHeartbeat();
167+
#endif // FIREBASE_PLATFORM_DESKTOP
168+
}
169+
161170
// Decrease the reference count for the app. When the reference count reaches
162171
// 0, the App will be deleted.
163172
static void AppReleaseReference(App* app) {
@@ -862,11 +871,11 @@ static firebase::AppOptions* AppOptionsLoadFromJsonConfig(const char* config) {
862871
}
863872
// TODO(smiles): Improve error code passing from C++ to C# so that
864873
// we don't need to parse magic strings from the error message.
865-
874+
866875
if (errorMessage.IndexOf("Please verify the AAR") >= 0) {
867876
errorMessage += "\n" + Firebase.ErrorMessages.DependencyNotFoundErrorMessage;
868877
}
869-
878+
870879
// util_android.cc)
871880
throw new Firebase.InitializationException(initResult, errorMessage);
872881
} catch (System.Exception exception) {
@@ -1318,11 +1327,7 @@ namespace callback {
13181327

13191328
%csmethodmodifiers LogHeartbeatInternal(App* app) "internal";
13201329
static void LogHeartbeatInternal(App* app) {
1321-
#if FIREBASE_PLATFORM_DESKTOP
1322-
// Only need to call LogHeartbeat on desktop, since native mobile SDKs
1323-
// Will handle heartbeat logging internally.
1324-
app->LogHeartbeat();
1325-
#endif // FIREBASE_PLATFORM_DESKTOP
1330+
firebase::LogHeartbeatForDesktop(app);
13261331
}
13271332

13281333
%csmethodmodifiers AppSetDefaultConfigPath(const char* path) "internal";

0 commit comments

Comments
 (0)