Is Xcode & iPhone the best way to reuse code in multiple projects?

What is the best way to reuse code in projects?

Let's say I implemented a user interface element, and I want it to be used in both my iphone application and ipad without having to copy the code and have 2 copies of it.

+6
source share
2 answers

Just create a project that includes all of your shared code in Xcode and references that project in your iPhone and iPad app project. Simple and simple.

+5
source

For me, I would make a static library project that contains common code (the UI element in your example) in Xcode.

Then, when I need to use the library in the iPhone or iPad application project, I can just reference the static library project by dragging the project into the Project Navigator and setting the correct dependency, the library used and the header search path, Thus, you always have one source source library code to simplify maintenance and modification.

Of course, you can compile the static library into a binary file and link it to your project, but it is not too flexible when you find errors in your static library and you need to switch to another project to fix the error, and then compile and copy the file binary library.

I just wrote an article (link below) on how to link a static library project with an iOS project on Xcode 4.3.2. It may be useful for you to solve a problem that you did not find. I hope for this help.

http://vicidi.wordpress.com/2012/04/11/linking-an-ios-static-library-project-in-another-project-in-xcode-4-3-2/

+2
source

Source: https://habr.com/ru/post/892066/


All Articles