佳为好友

转:在非ARC工程中使用ARC的framework

创建:2012.09.19
转:https://github.com/Cocoanetics/DTCoreText/wiki/Using-DTCoreText-in-Non-ARC-Projects

Using DTCoreText in Non ARC Projects

You have two options in adding ARC based code to your non-ARC project:

1) DIRECTLY ADDING FILES TO YOUR PROJECT

  • add the DTCoreText files to your project

  • in the Xcode project view, click on your target(s), Build Phases, Compile Sources category.

  • for each of the DT files, you MUST paste this to the Compile Flags:

    -fobjc-arc

2) CREATE AN ARC-LIBRARY (for DTCoreText and any other files needing ARC)

  • Create a New project within your main Xcode 4 workspace with type "Cocoa Touch Static Library", lets call it libArc.a

  • insure that this project uses the same settings as the primary (SDK, arm types, has the same Configurations (if you added some specials to your primary duplicate them in this library project)

  • add all the DT files to this library project

  • set to "YES" the Build Settings flag under the LLVM 3.0 category that says "ObjectiveC Automatic Reference Counting"

Now the tricky part. In your primary project:

  • open the project settings, select your Target, select Build Phases: a) add a dependency to your libarc.a library (you drag it over from the left pane I think) b) in the Link section, make sure that there is a libarc.a there too.

  • now select your Project, and paste the following into the Other Link Flags section

    -force_load $(BUILT_PRODUCTS_DIR)/libarc.a

IF YOU DO NOT GET A DEPENDENCY TO THE LIBRARY YOU WILL NEVER COMPILE UPDATES! If you do not add the forceload command, everything will appear to compile and run, but when you go to use DTCoreText your app will crash (categories do not get loaded without the force load line).

+++++

posted on 2012-12-29 10:46 佳为好友 阅读(401) 评论(0)  编辑 收藏 引用 所属分类: 非UITool


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理


导航

<2012年12月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

留言簿(1)

随笔分类

搜索

最新评论

评论排行榜