Adding a subproject makes it easier to make changes to your subproject, and then see those changes instantly reflected in the parent project. To add a subproject, you subproject must first be a static library (unless it’s an app extension).

But once you’ve got a static library subproject, here’s how you add it.

Drag the subproject in via finder

Skärmavbild 2016-12-23 kl. 9.30.53 fm.png

Then select the Main project -> MainApp Target -> Build Phases -> Target Dependency

 

Skärmavbild 2016-12-23 kl. 9.34.47 fm.png

Then add the Link Binary with Libraries

Skärmavbild 2016-12-23 kl. 9.36.28 fm.png

If you have setup your staticlibrary like I explained here you now need to tell the main project where it can find the public header.

Under Build Settings search for User Header Search Paths and add $(CONFIGURATION_BUILD_DIR) (non-recursive)

Skärmavbild 2016-12-23 kl. 7.59.50 fm.png

With that done, you should now be able to import the static library header and use it in your main app.

Skärmavbild 2016-12-23 kl. 8.02.29 fm.png

Links that help

https://www.cocoanetics.com/2011/12/sub-projects-in-xcode/
https://www.cocoanetics.com/2012/01/helping-xcode-find-library-headers/

Advertisement