mlyixi's Blog

欲望的唤醒,信仰的坚定
kde4下gtk程序很丑
mac, kde4切换到zsh,打造有git提示的美化shell

xcode子工程及cocoapods管理

mlyixi posted @ 2012年12月04日 19:10 in 未分类 , 5895 阅读

ios应用总会用到很多库,而苹果只允许使用第三方的静态库.所以,开发者不能制作简单的framework供其它开发者调用. 而且,静态库加入到自己的工程也是个比较麻烦的事情,特别是有些工程没有制作静态库的target,这时还要自己制作静态库目标.

好吧,把整体思路理下.

1. 新建自己的工程,git化.

2. 添加子工程: git submodule add git://github.com/gitname/gitname.git. 如果对应的工程有submodule, 同步git时可以用--recurcive

3. 如果子工程没有制作静态库目标,制作:

  • 添加静态库目标,将创建以目标名为名的头文件和实现文件,删除实现文件,可以将子工程的头文件包含进目标头文件中.
  • 在public headers folder中设置include/$(TARGET_NAME)实现 target/target.h的引用. 其实不这样引用也可以.
  • 将头文件加入到外部可见或工程可见(私有可见无意), pch文件亦加入.
  • 将实现文件加入到compile source中.
  • 可以考虑将资源文件加入到copy files中
  • 编译

4. 将工程文件拖入父工程

5. 在父工程中加入静态库目标

6. 在link binary with library中加入.a文件

7.在build setting中更改链接标志 -ObjeC -all_load

8. 在header search paths中添加头文件搜索路径: 也许不知道各个环境变量的值很难搞定这块,但是我会告诉你可以在build phases中加入script打印各环境变量的值么(env)? 注意,TARGET_BUILD_DIR=BUILT_PRODUCTS_DIR. 知道了这些变量值,再查看实际路径值,对应起来就是了.

9. 添加子工程的framework

好了,完成以上步骤,一个子工程就添加完毕了. 要添加多个子工程?重复之

 

 

确实比较麻烦,不过所幸的是有了cocoapods可以管理子工程. cocoapods是用ruby写的,而在ml上的ruby比较老了,所以先安装版本控制器rvm:

 

$ \curl -L https://get.rvm.io | bash -s stable --ruby

安装完后它会提示你运行命令启动新版本.

接着安装新版ruby,如

 

rvm install 1.9.3 --with-gcc=clang

要有option,不然安装cocoapods报错.

 

 

Avatar_small
maid services dubai 说:
2022年1月25日 21:26

Despite the fact that our housekeepers don’t supply following products, we can highly recommend one to your locally-owned small businesses from some of our network for trusted home service providers. Visit getneighborly.com to learn more.With a track record of clean homes and happy customers, DIALAMAID is your best choice for housekeeping services designed to fit your budget and schedule. We work closely with homeowners, rental property owners, and vacation homeowners to build a custom cleaning plan that fits their unique cleaning needs..

Avatar_small
Emma 说:
2022年11月17日 00:45

Accidentally i have come across this website and little bit confused about the details shared here. I think this topic is really good to help Use of Cannabidiol in Fitness computer students. It gives a brief idea regarding the Xcode sub-project and cocoapods management. I am looking here to more updates on that and keep sharing more details here.

Avatar_small
charlly 说:
2022年12月28日 20:31

I stumbled across this website by accident and am a little perplexed by the information provided. I believe that the fitness computing students would benefit much from this material. It provides a brief overview of the management of cocoapods and the Xcode sub-project. I will continue to provide more information engagement rings here and look forward to additional updates on that.

Avatar_small
seo service UK 说:
2024年1月15日 20:11

There’s noticeably a bundle to learn about this. I assume you made certain nice points in features also


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter