Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Exclude public headers #998

Closed
keith opened this Issue Apr 24, 2013 · 14 comments

Comments

Projects
None yet
5 participants
Member

keith commented Apr 24, 2013

With the move away from FileList to exclude_files there is an issue with public_header_files. For example I was just messing with 2 specs. The first for MAZeroingWeakRef that (currently) has this:

  s.source_files = FileList.new('Source/MA*.{h,m}')\
    .exclude('Source/main.m')

  s.public_header_files = FileList.new('Source/MA*.h')\
    .exclude('Source/MAZeroingWeakRefNativeZWRNotAllowedTable.h')

With the current tools available to exclude the file from the public_header_files I would have to declare it like:

s.public_header_files = 'Source/{foo,bar,baz}.h'

The other spec was WhirlyGlobe that had something like this:

s.public_header_files = FileList['WhirlyGlobeSrc/{WhirlyGlobeLib,WhirlyGlobe-MaplyComponent}/include/**/*.{h}'].exclude(/private/)

So these also would have to be specified one by one. My thought here is for a more fine grained way to exclude these, for example a exclude_headers attribute that works exactly like exclude_files but just for headers. This attribute could also be used without a public_header_files attribute so the spec could have something like:

s.source_files = '*.{h,m}'
s.exclude_headers = '*Private*.h'

Does this seem resonable?

Owner

fabiopelosin commented Apr 24, 2013

There has been a long debate about this, but nothing conclusive. The alternatives where:

  • Use Ruby to build the full list before pushing the spec (al la Rubygems)
  • Add the private_headers attribute.
  • Add a syntax for negative glob patterns. Like files = 'Classes', '[!] Classes/excluded', where a prefix ([!])denotes the exclude patterns. This would be easy to implement but it is not easy to understand if such a prefix could clash with the rest o the glob syntax.

    Sent from my iPhone

On Wed, Apr 24, 2013 at 8:44 PM, Keith Smiley notifications@github.com
wrote:

With the move away from FileList to exclude_files there is an issue with public_header_files. For example I was just messing with 2 specs. The first for MAZeroingWeakRef that (currently) has this:

  s.source_files = FileList.new('Source/MA*.{h,m}')\
    .exclude('Source/main.m')
  s.public_header_files = FileList.new('Source/MA*.h')\
    .exclude('Source/MAZeroingWeakRefNativeZWRNotAllowedTable.h')

With the current tools available to exclude the file from the public_header_files I would have to declare it like:

s.public_header_files = 'Source/{foo,bar,baz}.h'

The other spec was WhirlyGlobe that had something like this:

s.public_header_files = FileList['WhirlyGlobeSrc/{WhirlyGlobeLib,WhirlyGlobe-MaplyComponent}/include/**/*.{h}'].exclude(/private/)

So these also would have to be specified one by one. My thought here is for a more fine grained way to exclude these, for example a exclude_headers attribute that works exactly like exclude_files but just for headers. This attribute could also be used without a public_header_files attribute so the spec could have something like:

s.source_files = '*.{h,m}'
s.exclude_headers = '*Private*.h'

Does this seem resonable?

Reply to this email directly or view it on GitHub:
#998

Contributor

groue commented Apr 29, 2013

Hi @irrationalfab. @alloy sent me here from #65.

So it looks like the following line won't lint (https://github.com/CocoaPods/Specs/blob/master/GRMustache/6.4.1/GRMustache.podspec#L10):

spec.public_header_files = FileList['src/classes/*.h'].exclude(/_private/)

My two cents on your debate: the people who try to write precise and clean podspecs deserve to be granted with sharp tools. "Use Ruby to build the full list before pushing the spec" does not sound nice, in this regard. After all, even if CocoaPods has never been so trendy, it still needs new and updated specs. Meeting the needs of spec writers can't be a bad move.

[!] could do the trick, even if it looks hackish. If FileList was removed in order to drop a dependency on rake (if I got things well), my move would be to rewrite it.

Owner

fabiopelosin commented Apr 29, 2013

We decided to introduce the private_headers attribute.

[!] could do the trick, even if it looks hackish.

Indeed.

If FileList was removed in order to drop a dependency on rake (if I got things well), my move would be to rewrite it.

We reimplemented the relevant functionality, while adapting it for our usage case. The FileList, is not accessible for people unfamiliar with Ruby.

Contributor

groue commented Apr 29, 2013

Are you suggesting PathList would be given an exclusion feature, and enter the public API?

Contributor

groue commented Apr 29, 2013

Or are you saying, as @keithbsmiley suggests, that the Spec class needs a new accessor, for people unfamiliar with Ruby?

Owner

fabiopelosin commented Apr 29, 2013

PathList already supports an exclusion feature. We plan to add:

spec.private_headers = '*Private*.h'

This directive would store a negative pattern used agains the public_headers (or the source_files if the public headers have not been specified) directive to filter the headers. For the other patterns the common exclude_files should suffice. We looking for a sharp yet concise DSL.

Contributor

groue commented Apr 29, 2013

That would be gorgeous :-)

Sorry if I sounded like I was pushing you: it's obvious you have already put a lot of thought in the issue.

Thank you for all, cocoapods, your dedication, and your insights :-)

Owner

fabiopelosin commented Apr 29, 2013

Sorry if I sounded like I was pushing you

Nothing to be sorry about, users expressing and defending their opinions is the best feedback we can look for 😄

trapps commented Jun 4, 2013

This seems related:

rake aborted!
Invalid `GRMustache.podspec` file: undefined method `private_header_files=' for #<Pod::Specification name="GRMustache">
 #
 #  from /Users/koen/.cocoapods/master/GRMustache/6.7.3/GRMustache.podspec:10
 #  -------------------------------------------
 #    s.source_files = 'src/classes'
 >    s.private_header_files = 'src/classes/*_private.h'
 #    s.framework = 'Foundation'
 #  -------------------------------------------
 #
/Users/koen/.cocoapods/master/GRMustache/6.7.3/GRMustache.podspec:10:in `_eval_podspec'
/Library/Ruby/Gems/1.8/gems/cocoapods-core-0.18.1/lib/cocoapods-core/specification.rb:40:in `initialize'
/Users/koen/.cocoapods/master/GRMustache/6.7.3/GRMustache.podspec:1:in `new'
/Users/koen/.cocoapods/master/GRMustache/6.7.3/GRMustache.podspec:1:in `_eval_podspec'
/Library/Ruby/Gems/1.8/gems/cocoapods-core-0.18.1/lib/cocoapods-core/specification.rb:534:in `eval'
/Library/Ruby/Gems/1.8/gems/cocoapods-core-0.18.1/lib/cocoapods-core/specification.rb:582:in `_eval_podspec'
/Library/Ruby/Gems/1.8/gems/cocoapods-core-0.18.1/lib/cocoapods-core/specification.rb:534:in `from_file'
/Library/Ruby/Gems/1.8/gems/cocoapods-core-0.18.1/lib/cocoapods-core/specification/set.rb:88:in `specification'
/Library/Ruby/Gems/1.8/gems/cocoapods-core-0.18.1/lib/cocoapods-core/source.rb:141:in `search'
/Library/Ruby/Gems/1.8/gems/cocoapods-core-0.18.1/lib/cocoapods-core/specification.rb:582:in `find'
/Library/Ruby/Gems/1.8/gems/cocoapods-core-0.18.1/lib/cocoapods-core/source.rb:136:in `each'
/Library/Ruby/Gems/1.8/gems/cocoapods-core-0.18.1/lib/cocoapods-core/source.rb:136:in `find'
/Library/Ruby/Gems/1.8/gems/cocoapods-core-0.18.1/lib/cocoapods-core/source.rb:136:in `search'
/Library/Ruby/Gems/1.8/gems/cocoapods-core-0.18.1/lib/cocoapods-core/source/aggregate.rb:104:in `search'
/Library/Ruby/Gems/1.8/gems/cocoapods-core-0.18.1/lib/cocoapods-core/source/aggregate.rb:104:in `select'
/Library/Ruby/Gems/1.8/gems/cocoapods-core-0.18.1/lib/cocoapods-core/source/aggregate.rb:104:in `search'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/resolver.rb:188:in `find_cached_set'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/resolver.rb:153:in `find_dependency_specs'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/user_interface.rb:113:in `message'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/resolver.rb:152:in `find_dependency_specs'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/resolver.rb:148:in `each'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/resolver.rb:148:in `find_dependency_specs'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/resolver.rb:164:in `find_dependency_specs'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/user_interface.rb:113:in `message'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/resolver.rb:152:in `find_dependency_specs'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/resolver.rb:148:in `each'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/resolver.rb:148:in `find_dependency_specs'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/resolver.rb:65:in `resolve'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/user_interface.rb:52:in `section'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/resolver.rb:63:in `resolve'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/resolver.rb:62:in `each'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/resolver.rb:62:in `resolve'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/installer/analyzer.rb:290:in `resolve_dependencies'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/user_interface.rb:52:in `section'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/installer/analyzer.rb:288:in `resolve_dependencies'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/installer/analyzer.rb:56:in `analyze'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/installer.rb:157:in `analyze'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/installer.rb:92:in `resolve_dependencies'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/user_interface.rb:52:in `section'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/installer.rb:91:in `resolve_dependencies'
/Library/Ruby/Gems/1.8/gems/cocoapods-0.18.1/lib/cocoapods/installer.rb:84:in `install!'
/Library/Ruby/Gems/1.8/gems/motion-cocoapods-1.3.2/lib/motion/project/cocoapods.rb:115:in `install!'
/Library/Ruby/Gems/1.8/gems/motion-cocoapods-1.3.2/lib/motion/project/cocoapods.rb:50:in `pods'
/Users/koen/Projects/trapps/rubymotion/mapbox-rubymotion-example/Rakefile:12
Contributor

groue commented Jun 4, 2013

@trapps it looks like you should update your cocoapods gem (lastest version is 0.16.4).

trapps commented Jun 4, 2013

Ah, correct it was locked at an older version, my mistake.
Works correctly now!

Owner

fabiopelosin commented Jun 4, 2013

Btw, the last version of CP is 0.20.2.

vkrikun commented Jun 23, 2014

Guys, my project depends on set of C libraries which I want to manage with wonderful CocoaPods. Each library has private headers like ctype.h, errno.h, string.h deep in the structure. I need them to be copied to Pods/Headers, but NOT flattened in the HEADER_SEARCH_PATHS.

As example, I have the following project structure:
mylib/include/mylib.h
mylib/include/core/errno.h
I want all the headers to be copied to the Pod Headers folder, but HEADER_SEARCH_PATHS include "mylib/include" only.

Everything I add through source_files or public_header_files goes to HEADER_SEARCH_PATHS in various Pod .xconfig. If I exclude some headers, they disappear from HEADER_SEARCH_PATHS, but also not copied to Headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment