【记录】给一个支持Carthage和Cocoapods的iOS项目改名

【背景】

对于已有的一个项目:

existed ios project carthage cocoapods

 

为了打造成项目模版

想要把项目改名为:

SwiftProjectTemplate

注意其中包含了Cocoapods和Carthage

但是不知道会有其他什么影响

 

【折腾过程】

1.搜:

ios project change name

参考:

iphone – How can I change the name of my iOS project? – Stack Overflow

iphone – how to change Xcode Project name – Stack Overflow

How to rename project in Xcode

Xcode 6.1: Renaming Projects — Swift + iOS Developer Training

Renaming Your CocoaPods iOS Project | h4ckish

去安装,用于卸载Cocoapods的工具:

CocoaPods/cocoapods-deintegrate: A CocoaPods plugin to remove and de-integrate CocoaPods from your project.

去执行:

sudo gem install cocoapods-deintegrate

licrifandeMacBook-Pro:QorosSales crifan$ gem install cocoapods-deintegrate
Fetching: cocoapods-deintegrate-1.0.0.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
licrifandeMacBook-Pro:QorosSales crifan$ sudo gem install cocoapods-deintegrate
Password:
Successfully installed cocoapods-deintegrate-1.0.0
Parsing documentation for cocoapods-deintegrate-1.0.0
1 gem installed

然后再去用:

先切换到对应的,包含xxx.xcodeproj和xxx.xcworkspace的目录下:

pod deintegrate

 

licrifandeMacBook-Pro:QorosSales crifan$ pod deintegrate
Deintegrating `QorosSales.xcodeproj`
Deleted 1 'Copy Pods Resources' build phases.
Deleted 1 'Check Pods Manifest.lock' build phases.
Deleted 1 'Embed Pods Frameworks' build phases.
- Pods_QorosSales.framework
- Pods-QorosSales.debug.xcconfig
- Pods-QorosSales.release.xcconfig
Deleted 1 'Copy Pods Resources' build phases.
Deleted 1 'Check Pods Manifest.lock' build phases.
Deleted 1 'Embed Pods Frameworks' build phases.
- Pods_QorosSalesTests.framework
- Pods-QorosSalesTests.debug.xcconfig
- Pods-QorosSalesTests.release.xcconfig
Deleted 1 'Copy Pods Resources' build phases.
Deleted 1 'Check Pods Manifest.lock' build phases.
- Pods_QorosSalesUITests.framework
- Pods-QorosSalesUITests.debug.xcconfig
- Pods-QorosSalesUITests.release.xcconfig
Deleting Pod file references from project
- Pods_QorosSales.framework
- Pods_QorosSalesTests.framework
- Pods_QorosSalesUITests.framework
Deleted 1 empty `Pods` groups from project.
Removing `Pods` directory.

Project has been deintegrated. No traces of CocoaPods left in project.
Note: The workspace referencing the Pods project still remains.
licrifandeMacBook-Pro:QorosSales crifan$ ls -la
total 57424
drwxr-xr-x  15 crifan  staff       510  5 20 14:53 .
drwxr-xr-x   5 crifan  staff       170  5 20 14:52 ..
-rw-r--r--@  1 crifan  staff     10244  5 20 14:53 .DS_Store
-rw-r--r--   1 crifan  staff        18  5 14 16:28 .gitignore
-rw-r--r--   1 crifan  staff       232  5 19 15:09 Cartfile
-rw-r--r--@  1 crifan  staff       238  5 19 15:48 Cartfile.resolved
drwxr-xr-x   4 crifan  staff       136  5 14 15:16 Carthage
-rw-r--r--   1 crifan  staff  29364293  5 14 23:10 Charts.framework.zip
-rw-r--r--   1 crifan  staff       294  5 19 15:08 Podfile
-rw-r--r--   1 crifan  staff       338  5 19 15:09 Podfile.lock
drwxr-xr-x  23 crifan  staff       782  5 20 10:46 QorosSales
drwxr-xr-x@  5 crifan  staff       170  5 20 14:53 QorosSales.xcodeproj
drwxr-xr-x   4 crifan  staff       136  5 12 16:15 QorosSales.xcworkspace
drwxr-xr-x   4 crifan  staff       136  5 12 15:40 QorosSalesTests
drwxr-xr-x   4 crifan  staff       136  5 12 15:40 QorosSalesUITests

pod deintegrate之后,果然只剩:Podfile和Podfile.lock了

但是还残留了xcworkspace:

去删除掉:

右击-》移除到废纸篓

 

然后就可以打开原先的项目:QorosSales.xcodeproj了。

可以看到,Xcode发现缺少了,之前通过cocoapods安装的那些库:

open xcodeproj project will lack some of lib

暂时先不理会

 

2.然后选中项目名,Enter键,去重命名,输入新项目名:

enter rename input new project name

输入Enter键后,Xcode会弹出,指导你改名的对话框:

xcode show window to rename project

 

可见,对应的项目名,和一些相关的项,是改变了:

changed name of ios project

 

但是项目内部的文件夹,还是没有改变的

3.所以要去自己手动改:

输入之前的项目名,可以找到30处:

old project name stilled remain in project

然后自己一点点的去手动改。

然后经过一堆的改动后

包括对应的文件夹的改动:

also changed the folder for ios project

关闭项目再重启

最终,项目无法正常编译了:

after change folder ios project can not build

 

[总结]

1.如果想要让项目只是改个名字的话,确保项目仍然可以正常继续编译

那么对于带了Cocoapods的项目,用pod deintegrate去掉cocoapods

然后重新去命名项目,根据提示,确定即可。

这时的项目,还是可以正常编译。继续使用的。

2.但是项目其他地方,比如注释,文件夹部分,项目的test部分等等

如果把项目中部分内容,尤其是test部分,项目的所在的Finder中的文件夹部分等等,全部都把旧的项目名改为新的项目名字,则会导致项目出错,无法编译。

主要是找不到对应的info.plist文件,相关的配置文件,从而报错的。

->

想要重新命名,彻底的改名的话,最好还是重新创建一个项目。。。



发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量