How to use gmock with xcode?

I want to use gmock (Google Mock) as a fake framework for a C ++ project in Xcode. Therefore, I need to compile gmock as gmock.framework . Unfortunately, the project does not come with a dedicated Xcode project (it has one gtest in it).

Creating a Framework project in Xcode and creating it with an error with multiple errors (mostly empty paths used in the headers look wrong).

So (and sorry for the general question), how to compile gmock as a Framework to be able to use it in other Xcode projects?

+5
source share
1 answer

I managed to get GMock to work in Xcode by following these steps:

  • Download this repo somewhere on your computer:

https://github.com/macmade/gmock-xcode

  1. Open the supplied Xcode project, build all the goals by clicking the play button, then close the project.

  2. Add the GMock Xcode project to the Xcode project as a subproject (you can drag the GoogleMock.xcodeproj file into the project browser from the Finder).

  3. In the test target under Build Phases, add the GoogleMock, gmock, and gtest framework in the Target Dependencies section:

enter image description here

  1. Add the following line to your test files to start using GMock:

     #include <GoogleMock/GoogleMock.h> 
+2
source

Source: https://habr.com/ru/post/1207142/


All Articles