Sunday 27 October 2013

Tutorial : How to search a specific string pattern in library files or .a files in your project.

In this post I would like to give you some information about How to search a string pattern in a library file or .a file that you included in your project. Many times we faced this situation when we need to check the library files' content. Similar problem I faced during my validation of project before submitting my app to Apple Apps Store. My application didn't pass the validation test as some of my libraries contain deprecated APIs. When I search for that API in my project in xcode search, I didn't find any class that uses that API.
I was also using some 3rd party libraries in my project like PayPal integration and some more. so after a lot of research, I analysed that the problem may be in 3rd party library but how to search the content of library and confirmed that which library is using the deprecated API was a difficult task. But I search it and finally I came to know the solution which I am going to share it with you.

First step: Open your command line and go to directory where the project is located using command:

cd ~/YOUR_PROJECT_DIRECTORY

Second step: Now search for the 3rd party library files that you are using in your projects using command: 

find . -name "*.a" -print 

Last step: Now if you want to search a specific string pattern in that libraries, use the following command: 

find . | grep "\.a" | grep -v "\.app" | xargs grep “Your Specific String” 

In my project, the paypal library.a is using deprecated API "uniqueIdentifier" and when I updated that library everything's working fine.

Please share this post if you find it worthy and useful. Happy coding..!!!

No comments:

Post a Comment