CocoaPodsのアンインストール方法

今回はCocoaPodsで導入したライブラリのアンインストールプロジェクトからCocoaPodsを完全削除CocoaPods自体のアンインストールを紹介していきます。

CocoaPodsで導入したライブラリのアンインストール

ターミナルで対象プロジェクトのフォルダへ移動し、Podfileの編集を行います。

今回は#でコメントアウトしました。

1
2
3
4
5
6
platform :ios, ‘8.0’
use_frameworks!

target ‘test’ do
#  pod ‘Async’
end

ターミナルでpod installを実行、ライブラリが削除されます。

1
2
3
4
5
6
7
8
% pod install
Updating local specs repositories
Analyzing dependencies
Removing Async
Downloading dependencies
Generating Pods project
Integrating client project
Sending stats

プロジェクトからCocoaPodsを完全削除

自動削除する場合

cocoapods-deintegrateをインストール

1
% [sudo] gem install cocoapods-deintegrate

実行結果

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
% pod deintegrate
Deintegrating Palaver.xcodeproj
Deintegrating target Palaver
Deleted 1 'Copy Pods Resources' build phases.
Deleted 1 'Check Pods Manifest.lock' build phases.
Removing Pod libraries from build phase:
- libPods-Palaver.a
Deleting Pod file references from project
- libPods-Palaver.a
- libPods-PalaverTests.a
- Pods-Palaver.debug.xcconfig
- Pods-Palaver.release.xcconfig
- Pods-Palaver.ad hoc.xcconfig
- Pods-PalaverTests.debug.xcconfig
- Pods-PalaverTests.release.xcconfig
- Pods-PalaverTests.ad hoc.xcconfig
Deleted 1 `Pod` groups from project.
Deintegrating target PalaverTests
Deleted 1 'Copy Pods Resources' build phases.
Deleted 1 'Check Pods Manifest.lock' build phases.

Project has been deintegrated. No traces of CocoaPods left in project.
Note: The workspace referencing the Pods project still remains.

Podfile, Podfile.lock, Workspaceが残るので、不要な場合は手動で削除。

手動削除する場合

プロジェクト内に残っているPods関連のファイルをすべて削除したい場合、

幾つかのステップが必要です。

1. ターミナルを開いて、下記のコマンドを入力。

1
2
3
$cd 対象プロジェクト
$rm -rf Podfile Podfile.lock Pods 対象プロジェクト.xcworkspace
$open 対象プロジェクト.xcodeproj/

2. XCode上でPodsのフォルダごと削除

XCode上でPodsのフォルダごと削除

3. Frameworksフォルダの Pods_対象プロジェクト.frameworkの削除

Pods_対象プロジェクト.frameworkの削除

4. 対象プロジェクト→対象ターゲット→Build Phasesに移動し、下記を削除。

Check Pods Manifest.lock

Embed Pods Frameworks

Copy Pods Resources

Build Phases

CocoaPods関連のファイルはすべて削除できました。

削除後、XCodeのビルドが通らない場合

Deriverd Dataを削除してやれば、うまくビルドが通ります。

1
2
3
4
cd ~/Library/Developer/Xcode/DerivedData
rm -rf ./
// もしくは
rm -rf 対象のデータ

CocoaPods自体のアンインストール

1
% gem list --local | grep cocoapods

ローカルのcocoapodsの依存が列挙される

1
2
3
4
5
6
7
8
9
% cocoapods (1.9.0)
% cocoapods-core (1.9.0)
% cocoapods-deintegrate (1.0.4)
% cocoapods-downloader (1.3.0)
% cocoapods-plugins (1.0.0)
% cocoapods-search (1.0.0)
% cocoapods-stats (1.1.0)
% cocoapods-trunk (1.4.1)
% cocoapods-try (1.1.0)

各パッケージの削除

1
2
3
4
5
6
% sudo gem uninstall [cocoapodsのパッケージ]

% sudo gem uninstall cocoapods
% sudo gem uninstall cocoapods-core
% sudo gem uninstall cocoapods-deintegrate
...

cocoapods 隠れフォルダの削除

1
% rm -rf ~/.cocoapods

念のため pod –version で確認します。

1
2
% pod –version
zsh: command not found: pod

無事アンインストールが完了しました。

Licensed under CC BY-NC-SA 4.0
最終更新 Dec 25, 2020 00:00 UTC
comments powered by Disqus
Built with Hugo
テーマ StackJimmy によって設計されています。