创建:2012.09.19Using 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).
+++++