When using cocoapods, what is the best way to change the PRODUCT_NAME?

不想你离开。 提交于 2019-12-03 12:32:09

问题


I created an app with name "ABC". Months later I decided to change the name to "ABCD". I believe the way I changed it, was in my Podfile, I changed target "ABC" do to target "ABCD" do. However, I recall going through quite a few issues/errors afterward in my workspace that caused a lot of stress. It was so long ago that I can't quite recall though.

Now I'm ready to submit, and I want to change the name one last time. I've changed the name in iTunes Connect, but now I want to change my PRODUCT_NAME, and my bundle identifier to match.

What is the best way to do this? Should I change the target fields in my Podfile? Or should I leave them, and just change something else in Xcode? Or do I need to change both or more than one thing?


回答1:


When you have a Pod file the .xcworkspace and Pods.xcodeproj is generated dynamically by the pod install process.

So one way to deal with this is

  1. Change your product name
  2. Close the project in Xcode
  3. Discard the existing .xcworkspace, Pods folder & Podfile.lock
  4. Run pod install again.

The cocoapods engine will regenerate its project, pull the Pods from its cache and recreate its Pods.xcodeproj with the new project settings.

This might be a little more complex in the case where you have other dependancies besides your main project and the Pods project in your workspace.

You'll probably want to have everything committed to source control before you do this so you can revert if it goes wrong.




回答2:


I solved if for my project with this steps.

  1. I install cocoapods-deintegrate

    [sudo] gem install cocoapods-deintegrate

    and call pod deintegrate on my project.

  2. open XCode, click on project name and click again with delay to rename, follow xcode instructions

  3. run pod install again on your project.

  4. NOTE: if you are just Capitalising, or Uppercassing project name do it with other temp name: for me locdel->aaa->Locdel.




回答3:


I've been scouting the internet to no avail looking for an answer to this. While editing the podfile and running pod install again fixes the renaming problem, in my case it broke my application as those pods had evolved while my app had stayed the same. If you have concerns about backwards compatibility and don't want to reinstall your dependencies I suggest you do as I did and edit directly the .xcworkspace and .xcodeproj files using a text editor.



来源:https://stackoverflow.com/questions/31120403/when-using-cocoapods-what-is-the-best-way-to-change-the-product-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!