Asked  7 Months ago    Answers:  5   Viewed   52 times

What's the right way of removing CocoaPods from a project? I want to remove the whole CocoaPod. Due to some limitations imposed by my client I can't use it. I need to have just one xcodeproj instead of an xcworkspace.

 Answers

12

Removing CocoaPods from a project is possible, but not currently automated by the CLI. First thing, if the only issue you have is not being able to use an xcworkspace you can use CocoaPods with just xcodeprojs by using the --no-integrate flag which will produce the Pods.xcodeproj but not a workspace. Then you can add this xcodeproj as a subproject to your main xcodeproj.

If you really want to remove all CocoaPods integration you need to do a few things:

NOTE editing some of these things if done incorrectly could break your main project. I strongly encourage you to check your projects into source control just in case. Also these instructions are for CocoaPods version 0.39.0, they could change with new versions.

  1. Delete the standalone files (Podfile Podfile.lock and your Pods directory)
  2. Delete the generated xcworkspace
  3. Open your xcodeproj file, delete the references to Pods.xcconfig and libPods.a (in the Frameworks group)
  4. Under your Build Phases delete the Copy Pods Resources, Embed Pods Frameworks and Check Pods Manifest.lock phases.
  5. This may seem obvious but you'll need to integrate the 3rd party libraries some other way or remove references to them from your code.

After those steps you should be set with a single xcodeproj that existed before you integrated CocoaPods. If I missed anything let me know and I will edit this.

Also we're always looking for suggestions for how to improve CocoaPods so if you have an issues please submit them in our issue tracker so we can come up with a way to fix them!

EDIT

As shown by Jack Wu in the comments there is a third party CocoaPods plugin that can automate these steps for you. It can be found here. Note that it is a third party plugin and might not always be updated when CocoaPods is. Also note that it is made by a CocoaPods core team member so that problem won't be a problem.

Tuesday, June 1, 2021
 
Trott
answered 7 Months ago
45

It seems that the process is similar to the one described in Mix and Match section of Using Swift with Cocoa and Objective-C documentation.

  1. Create your Podfile and run pod install.
  2. Create a new Objective-C header file, Example-Bridging-Header.h, and add it to the project.
  3. Add import statement to the bridge header.
  4. Set Objective-C Bridging Header for your target:

enter image description here

Now you can use your library, in that case, MKUnits, in your Swift file:

let kilograms = NSNumber.mass_kilogram(2)()
let pounds = NSNumber.mass_pound(10)()
let result = kilograms.add(pounds)
println(result)

More here: Integrating Cocoapods with a Swift project

Friday, July 9, 2021
 
EnTee
answered 5 Months ago
100

First line of defense: (Quit Xcode first, which is part of the strategy) :

rm -rf Pods/ Podfile.lock ; pod install

Defensive approach: verify your Podfile. Is it coherent? How about your tools versions? What happens if you create a new Podfile with pod init? Do you have all targets as expected?

Drastic measure: Rebuild xcworkspace entirely:

  1. quit Xcode
  2. mv project.xcworkspace to a backup location
  3. sudo gem install cocoapods (get latest)
  4. rm -rf Pods/ Podfile.lock ; pod install

Note:

Notice the use of rm -rf Pods/ Podfile.lock ; pod install instead of pod update.

Tuesday, August 17, 2021
 
hohner
answered 4 Months ago
77

Typically this can happen sometimes when one of your pod dependencies is accidentally added to the Build Phases pane under "Link Binary With Libraries" of your Targets settings.

Removing the library ".a" file from the Build Phase should do the trick.

Tuesday, August 24, 2021
 
huhushow
answered 4 Months ago
72

A collegue who has more in-depth knowledge of maven told me the answer:

The trick is not to remove the source module from the intellij project but to remove it from maven (in the maven projects tab in intellij). Intellij will ask then to remove the source module also from the intellij project and its finally gone.

Right click on the maven project -> remove projects

Would not have guessed this makes such a difference.

Friday, October 29, 2021
 
Farnabaz
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share