今是昨非

今是昨非

日出江花红胜火,春来江水绿如蓝

MapManagerSDK Integration Record

Background#

Recently, I integrated the MapManager SDK and encountered several issues. I will record them here:

Issue 1:

The integration method of importing the GMObjC algorithm SDK as mentioned in the documentation is as follows. After importing, it fails to compile and prompts: "sm2_plaintext_size" Too many arguments to function call, expected 3, have 4

pod 'GMObjC','3.0.0'

Issue 2:

After importing MapManager, QMUI library or other third-party libraries that were previously working fine now throw compilation errors.

Issue 3:

After solving the above issues, it compiles successfully but crashes immediately upon launch.

Solution:#

The solution to Issue 1 "sm2_plaintext_size" Too many arguments to function call, expected 3, have 4 is simple. Change it to pod 'GMObjC' and install the latest version.

For Issue 2, upon inspection, it was found that the error occurred in properties or methods where debug or release variables were defined. But why didn't it have any issues before? After careful investigation, it was discovered that in the MapManager SDK, in the MapService.h class, the following code exists:


#define debug @"debug"
#define release @"release"

The macros defined here do not have a prefix to differentiate them, causing errors in other parts of the project where debug or release is used. So, modifying it to the following code will solve the issue. Ps: When encapsulating third-party SDKs, if macros that need to be exposed for external use must be handled properly.


#define kDebugStr @"debug"
#define kReleaseStr @"release"

Lastly, for Issue 3, after solving the above issues, it compiles successfully but crashes immediately upon running, indicating a memory leak. After a long investigation, it was initially thought that some dependency libraries were not imported. However, after comparing with the tutorial, it was found that no third-party libraries were missing. Then it was suspected that there might be an issue with MapManager, so MapManager was removed, leaving only GMObjC, and it was found that it still crashed upon running. So, I checked the Github page of GMObjC and found the following statement:

GMObjC relies on OpenSSL 1.1.1 and above. CocoaPods does not support different versions of the same static library. If you encounter OpenSSL conflicts with third-party libraries, for example, Baidu MapKit depends on a lower version of the OpenSSL static library, a dependency conflict will occur.

This means that GMObjC depends on OpenSSL, and some third-party SDKs may also depend on it, causing conflicts, such as Baidu Map SDK. Coincidentally, my project also includes Baidu Map, so could this be the issue? Although conflicts usually result in compilation errors, just in case, I changed the way GMObjC is imported from Pod to Carthage. After compiling and running, it worked... Indeed, it was a conflict with Baidu Map, what a pitfall...

Then I integrated MapManager back, and don't forget to make the modification for Issue 2... After compiling and running, it worked fine.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.