可能有一个CocoaPods有一个包含主应用程序的搜索路径 [英] possible to have a CocoaPods have a search path that includes the main app

查看:134
本文介绍了可能有一个CocoaPods有一个包含主应用程序的搜索路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次写自己的Cocoapod所以这可能是一个非常简单的quedstion但....



我正在尝试使用Cocoapods来分发公共代码对于我们公司内部使用的一系列应用程序(CocoaPod称为CommonHex,前缀为HEX,因此HEXItem.h / m)。但是,我们有一个特定于每个应用程序的配置文件,名为HOSTConfig.h / m。有没有办法从我们的CommonHex pod中访问这个HOSTConfig.h / m?



看起来我应该能够拥有一个配置文件拥有它自己的值但是如果它存在的话会引入HOSTConfig.h / m?并且可能需要扩展搜索路径等。



所以我喜欢:

  MainApp 
\-MainApp
\-HOSTConfig.h / m

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

我想要这可以通过另一个类来访问HOSTConfig.h / m,如果HOSTConfig.h / m存在于托管应用程序中,它使用那些值,否则它使用我们的CocoaPod中的值



编辑#1



所以在CommonHex.podspec中,我有以下内容,但这似乎不起作用:

  s.source_files =Classes,Classes / ** / *。{h,m},$(PROJECT_DIR)/ HOSTConfig。{h,m }


解决方案

如果您正在寻找的是一种方式从任何Pod项目访问MainApp项目中的某些头文件(用于配置数据),问题只是提供正确的路径pods项目中的变量。



只需添加

 $(PROJECT_DIR )/ ..

以及用户标题搜索路径条目的引用构建设置,不要忘记选择递归。



这将允许Pod的标题搜索可见性扩展到主项目而不更改podfile。 / p>

示例:


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}"

解决方案

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:

这篇关于可能有一个CocoaPods有一个包含主应用程序的搜索路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆