Cocos2d-x v4 cocoapod not working

Getting this error ld: library not found for -lPods- clang: error: linker command failed with exit code 1 (use -v to see invocation)

I did just like what in this documentation says.

Using latest cocoapod and cmake. Tried in 2 computers.

Please help. Anyone managed to successfully integrate cocoapod in V4?

1 Like

We can ask @zhangxm and @coulsonwang to have a look.

Can you describe the issue in more detail?

Hey @coulsonwang,

I followed all these following instructions.

  1. fetch and pull latest v4 branch.
  2. use cmake to generate project.
  3. open new generated project, Select your target in the TARGETS group, go to Build Settings tab
  • add $(inherited) to Other Linker Flags field in the Linking section if no exist.
  • add $(inherited) to Header Search Paths and Library Search Paths fields in the Search Paths if no exist.
  • Add $(inherited) to Preprocessor Macros filed in the Apple Clang - Preprocessing section if no exist.
  1. skip this if you have already install the [CocoaPods](
  2. create a default Podfile
pod init
  1. manage your dependencies in the Podfile.
  2. install the pods.
pod install
  1. open the .xcworkspace and compile it, you will get the following error message, error: ../gamePods/Pods/Target Support Files/Pods-gamePods/Pods-gamePods.debug.xcconfig: unable to open file (in target "gamePods" in project "gamePods") (in target 'gamePods') To fix it, click Pods folder in your game project, and in the right panel you will see its location, click the folder icon, then select the correct path of Pods in the appeared window(Pods path is locate at the same directory as .xcworkspace ).
  2. Compile again, got the new error message, error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation. To fix it, modify the .xcconfig file to move PODS_PODFILE_DIR_PATH and PODS_ROOT from last two lines to first two lines, and set the values to
PODS_ROOT = ${SRCROOT}/"path_of_Pods"/Pods

“path_of_Pods” specifies the path of your Pods folder. Generally it’s your build directory.

I was able to clear all those error listed. But after doing all these step, there is a new error.

Please test in your system if you can @coulsonwang. I tested in 2 mac system.

It seems that the library Pods-DiceCraft can’t be found, you can have a double check to make sure there is a Pods-DiceCraft.
We don’t use CocoaPods to manage the dependency. If you can provide the test demo, we can help to test.


Please check this demo project.

I had download the demo and will test it tomorrow.

1 Like

Here has a fix for this issue. And this PR offers a way to fix path issues with CMake generated projects.

@coulsonwang Thank you. this fix will work for debug/run. but not able to archive. Is there any chance you support old xcode project method(Non CMAKE). Also any plans to release new cocos 3.x version?

For V4, the answer is not.

@minggo will reply you the plans about release new cocos 3.x version

I tried to register ‘CocoaPod’ in the latest ‘HelloWorld’ but it failed.
Have you been successful?

Has anyone gotten V4 / CMAKE to build an XCODE project to work with CocoaPods?

@dargomdev01 @hiphip
CocoaPods latest version(1.9.1) still has a problem with handle project_dir_path attribute for project location(CocoaPods/Xcodeproj#739). As we can see it already merge into the CocoaPods master branch here, maybe soon to be fixed in next release.

In cocos2d-x v4, cocoapod v1.9.3 I fail.
Is success possible in this version?

Anyone managed to successfully integrate cocoapod on V4? Please help

I have sort of managed to do it in a new v.4. project by installing the last repo version of CocoaPods (1.10.0.rc.1) by calling sudo gem install cocoapods --pre ( The cmake paths problem seems to be solved there.

I do still have some linker errors with the Pods. Last night, I somehow managed to get rid of them by playing around with Framework Search Paths/Linker flags/framework embed options/architectures/cleaning and rebuilding project over and over etc. But today somehow it won’t compile again, argh, and since it was REALLY late last night, I can’t even remember the exact solution :/. The linker still doesn’t know the symbol FIRApp (Firebase).

Even if I get it working again, though, I’m still very unsure how to configure everything so that each and every re-run of cmake does not reset all the settings, so painstakingly adjusted :/.

I’m thinking of skipping pods entirely and manually integrating the frameworks. Might turn out to be even more of a hassle than now, though.

I’ll let you know if I manage to develop a reliable solution with deterministic steps :stuck_out_tongue:.

OK it’s super late again so sorry if it’s chaotic. I’m going to describe all the steps I took to get a new v.4. project with Pods working. Not necessarily all working steps.

Starting with: CocoaPods 1.10.0.rc.1 installed, Pods configured in the Podfile, after pod install, and all $(inherited) flags setup as CocoaPods asked.
Error: Framework not found, pointing to some sub-pod framework.

  1. I go to Pods project in the navigator, go to Products, show the libPods-projectName.a in Finder, copy the path and paste it in Framework Search Paths of my project. Ugly, it’s just some Xcode/derivedData location.
  2. Build, the error goes away but another one appears: PBXCp, something like ios-build/bin/ProjectName/Debug/Pods_ProjectName.framework: No such file or directory
  3. Remove the red Pods-projectName.a from my project’s Frameworks group in Project navigator.
  4. It builds! But will crash on startup, saying **dyld: Library not loaded:
  5. go to Podfile, comment out use_frameworks, rerun pod install (or pod update), remove the red thingy from step (3) again, try to build
  6. Fails again complaining about library not found for -lYetAnotherLibrary
  7. cleaning the project and other tricks do not seem to work
  8. copy Framework Search path added in step (1) to Library Search Paths.
  9. voila. compiles, links, runs and does not crash.

I just wonder what new surprises are still waiting for me :D. Will probably wake up in the morning and it won’t build again :laughing:.
My next research will be how to handle all that in an elegant way? So I can at least add these damn Framework and Lib Search Paths in a generic way in cmake, as well as the inherited flags and other stuff that I still haven’t the slightest idea of.

I’m very interested in the cocoa pods, too. I have an existing iOS project using cocos-2d and it might be the easiest way for me to upgrade. I’ve been trying various ways using the cocos tool, but it makes a project that doesn’t build correctly for me if I move the project to another directory. That’s problematic in most git situations, so the cocoa pod would be much better in many ways.