Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell (at runtime) if a library was linked using cocoapods or not?

I know this probably is impossible, but is there any footprint left by cocoapods that can point out (at runtime) if a library was installed using cocoapods or not?

I am currently able to find out if CocoaPods was used or not by getting the list of classes names and then looking for a class with the PodsDummy_Pods_ prefix. But I have no way of knowing if a given library was or not linked using CocoaPods.

Edit

As clarification: I have access to the library source code, but I have no control over the final project. The library is distributed as a binary (static library), and we would like to know if the users installed it using CocoaPods or not.

like image 945
JP Illanes Avatar asked Oct 18 '22 12:10

JP Illanes


1 Answers

I guess this mainly depends on whether you have control of the library.

If you don't, no not really. Those PodsDummy- classes exist at a target level, so they just indicate that CocoaPods has been used. However, it won't tell you if a specific library used CocoaPods.

For source code libraries, CocoaPods can add additional build flags which can expose additional APIs or strings which you can lookup in the same way. There is already a "COCOAPODS" build flag added, so it could use that.

For a binary library, it's possible but a bit tricky. In theory: you could add a symbol to the lib/framework that can be discovered in the runtime, then in the Podspec's prepare_command that could be removed. I don't know what command would do that, but maybe ar, strip or lipo.

like image 97
orta Avatar answered Oct 21 '22 11:10

orta