I am using a component for rich text editing in an iPad app we did for one of our clients. We started using it while it was still in early beta and just pulled the code straight into the project.
Now its a bit more mature, I figured it was time to update to the latest and greatest. Having taken a look at the cocoanetics video to figure out how it should be included as a project reference, instead of just a dump of the source code, I thought I’d write down what I did. It may save someone a bit of time if you dont want to spend an hour watching the video.
- Grab the latest source from the DTRichTextEditor repository. I then exported a copy to my preferred location in my own souce tree. This gives me a clean copy of the code without all the .svn folders lurking around. In my case this was something like ../ThirdParty/DTRichTextEditor
- Open up your project in Xcode and create a Dependencies folder. Right click it and choose Add Files…
- Browse to DTRichTextEditor.xcodeproj and click add. Make sure the ‘copy item into destination folder’ option is not checked.
- Do the same again but this time browse to DTLoupe.xcodeproj and add this. It can be found in DTRichTextEditor/Core/Externals/DTLoupeView
- Click on your build target and go to the build phases tab.
- Add the DTRichTextEditor static library and DTLoupe resource bundle to the target dependencies section.
- In the link binaries with libraries section, add libDTRichTextEditor.a, libXML2.dynlib and CoreText.framework. There may be some others that you need here as well. This project has been kicking around a while so I cant remember what I had to add initially!
- Expand DTLoupe.xcodeproj in the Dependencies folder (or wherever you put it) and drill down into the products folder. You should see a DTLoupe.bundle item. Drag and drop that into the copy bundle resources section.
- Nearly there! Now open the build settings tab and find the search paths section. Double click the header search paths item and add in the path to the source code for DTRichTextEditor. In my case this was ../../../ThirdParty/DTRichTextEditor/Core. Ensure you check the box to the left of the path to make the search recursive.
- Write your code, build and run.
Disclaimer: I dont know if this is the correct way to do it. It maybe that you need to do things slightly different if you are using some features that I’m not. And, as I was adding it to an existing project, there may well have been some additional setup that I have not covered here.
In any case, this guide will prove useful to me when I forget all of this in a few weeks time. Maybe it will help someone else as well?