Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

possible to have a CocoaPods have a search path that includes the main app

Tags:

ios

cocoapods

This is my first time writing my own Cocoapod so this might be a really simple quedstion but ....

I am trying to use Cocoapods to distribute common code for a series of apps used within our company (the CocoaPod is called CommonHex with a prefix of HEX so HEXItem.h/m). However, we have a config file specific to each app called HOSTConfig.h/m. Is there any way to access this HOSTConfig.h/m from within our CommonHex pod?

It would seem like I should bOe able to have for example a config file which will have it's own values but would pull in for HOSTConfig.h/m if it exists? And would probably have to extend the search path or something.

So I have like:

MainApp
\-MainApp
   \-HOSTConfig.h/m

CommonHex
\-Classes
   \-HEXItem.h/m
   \-HEXItemViewController.h/m  

I would like this to be able to access HOSTConfig.h/m perhaps via another class where if HOSTConfig.h/m exists in the hosting app, it uses those values else it uses values in our CocoaPod

edit #1

so in CommonHex.podspec, I have the following but this doesn't seem to work:

  s.source_files  = "Classes", "Classes/**/*.{h,m}", "$(PROJECT_DIR)/HOSTConfig.{h,m}"
like image 405
timpone Avatar asked Jan 27 '15 05:01

timpone


1 Answers

If what you are looking for is a way to access some header file(for config data) in your MainApp project from any Pod project, than the issue is just about providing proper path variable in pods project.

Just add

"$(PROJECT_DIR)/.."

along with the quotes to the User Header Search Paths entry build settings, and don't forget to select recursive.

This will allow the header search visibility of Pod to be extend to main project without changing the podfile.

Sample: enter image description here

like image 54
bllakjakk Avatar answered Oct 29 '22 07:10

bllakjakk