DocC and cocoapods build fail

I have a project where there are some old cocoapods written in Objective-C. When you start building the documentation, not only the code of the main project is compiled but also the code of the various pods you have. Unfortunately, in my case, this causes the building and subsequent production of the documentation to fail. so I would like to ask: is there a way to exclude the building of cocoapods or have only the main project build?

Hi @rufy, thank you for sharing your question on here. While I don’t have deep experience with Obj-C and DocC I understand it can be frustrating or difficult to find a solution. There may be a workaround if you’ve haven’t found a direct way to exclude the cocoapods. Here are three possible solutions:

Attempt 1. Exclude Pods Target from DocC Build

In your Xcode project, go to the Build Phases tab of the target you want to generate documentation for. Under the “Doc Comments” section, locate the “DocC Catalog Sources” build phase. Expand it, and you should see entries for your project’s source files as well as the Pods project.

Right-click on the Pods project entry and select “Remove” to exclude it from the DocC build process.

Attempt 2. Use DocC Configuration File

Create a DocC configuration file (e.g., docc.json) in your project’s root directory with the following content:

{
  "sources": ["YourProjectName"]
}

Replace "YourProjectName" with the actual name of your project’s target.

Then, in your project’s scheme, go to the “Build” tab, and under the “Doc” section, select the “Generate Documentation” checkbox. In the “DocC Configuration” field, provide the path to your docc.json file (e.g., $(SRCROOT)/docc.json).

This configuration file tells DocC to only include the specified target(s) when generating documentation.

Attempt 3. Use DocC Command Line Tool

You can also use the xcodebuild command-line tool to generate documentation while excluding CocoaPods dependencies. Run the following command from your project’s root directory:

xcodebuild docbuild -scheme YourScheme -destination generic/platform=iOS

Replace YourScheme with the name of your project’s scheme. This command will build the documentation for your main target, excluding any external dependencies like CocoaPods.

I hope one of these methods work out for you. If not, it would seem likely that excluding the cocoapods is not feasible. Good luck and happy coding!

Thank you very much @gdelarosa for your answers, but there are some problems:

I wasn’t able to try the first two attempts because the things you say to look for in the project aren’t there:

in the first attempt you say to look at “Doc Comments” section, locate the “DocC Catalog Sources” build phase. but this “Doc Comments” section does not exist. and I have to do something to make it appear I don’t know how.

in the second attempt you say “in your project’s scheme, go to the “Build” tab, and under the “Doc” section, select the “Generate Documentation” checkbox.” but in the build tab there is no Doc section.

I tried the third attempt but the building fails

Can you help me?