iOS developing note part1 develop app with CocoaPods(and some tips)

I think I should note down the experiences during these couple of month, in case I need to use them in the future.

It is a really great way to use github to help you setup a new project rapidly, yep, I know you know it. With those intelligent open source code, you might feel you are not fighting on your own, but working in a stronghold. But I think you’re also facing millions of errors or bugs generated by tons of programmers. And this is a critical reason for so many people who love to use cocoapods.

Another problem is, the complex dependences, Tool-Kit A depends on Lib B, Lib B import some thing from framework C, that happens all the time, and the worse thing is, if any part of them get a runtime bug, you might need couples of minutes to solve it, it usually pointed to some irrelevant lines.

The old school way to import 3rd part source is, download the zip file, unzip it, drag them into workplace, over 80%(I guess, could be more) programmer never update the 3rd part code since they dragged them in. Who cares, and who knows what happened subsequently, the author could improve the performance in a new version, they also can developed some amazing new functions, and you don’t know it because you hate to drag the files again.

It is hard to say cocoapods will perfectly solve all the troubles above, but it did help me to gather my mind, and focus on the logical problems, not the low-level errors.

It’s here: http://cocoapods.org/ , you can find every things for getting started about pod.

Despite the fact that you followed all the steps on the official site, you still might get stuck on some places. Here is the most frequently problems I met before.

1 Getting stuck on initialization of cocoapods, I think it was not just happening in my country, for some well known reasons, some parts of services were blocked by firewall, but fortunately, a huge company is holding a monitor service at ruby.taobao.com

What we’re gonna do is switch your gem source to a monitor service(if you have):

$ gem sources --remove https://rubygems.org/
$ gem sources -a http://ruby.taobao.org/
#check the source by this
$ gem sources -l

don’t forget to add sudo before commands, then setup you pod with this:

$ pod setup

2  Get stuck on update pod, “Analyzing dependencies”, if you’d tried step 1, then you may need this:

$ pod repo remove master
$ pod setup
$ pod install

3 ld: library not found for -lPods

YES, it drives me crazy, with several red error notifications! It sucks, in fact I still don’t have a complete way to solve them. But you can try following steps.

  • Make sure you are using .xcworkspace file to run the project.

  • Set “Other Linker Flags” to “$(inherited)”, for both of your project and Pods project. Search “OTHER_LDFLAGS” in project build setting panel, it really works for me.

  • Try to remove pods folder, and “yourApp.xcworkspace” file, upgrade your cocoapods to recently version, then regenerate all files again.

  • build your project with 4s simulator firstly, it’s odd but work it out sometimes.

  • Relaunch Xcode and Simulator.
    4  “Pods-App was rejected as an implicit dependency for ‘libPods-App.a’ because its architectures ‘i386’ didn’t contain all required architectures ‘x86_64’.”  Add this code to your PodFile see if it works.

    post_install do |installer|
    installer.project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ARCHS'] = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"
        end
    end
    end

    I also got some tips to share with everyone.

  • If you can, use Git instead of SVN.

  • Don’t submit pods folder to version control server, let every one run pod install with PodFile by themselves.

  • Upgrade your cocoapods as frequently as you can. Here’s the code:

  • $ sudo gem install cocoapods
  • pod search command makes trying new 3rd libs so easy, and if you want remove it ,just remove ONE line of code in PodFile.
    Well, I am gonna leave and go back home, my families are waiting.