Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ZBarSDK podspec headers and warnings #721

Closed
Zyphrax opened this Issue · 12 comments

2 participants

@Zyphrax

In my project I'm using the ZBarSDK pod. It works fine but it is raising all kinds of warnings in the Pods project which is annoying.

You can find the podspec here:
https://github.com/CocoaPods/Specs/blob/004bcc18c246b0ed151ef81f7669d8a3d393b8e1/ZBarSDK/1.3.1/ZBarSDK.podspec

I was able to fix the basic warnings caused by the C code by adding:
s.compiler_flags = '-w'

Now I have two issues left:

  • There are two files called (different) debug.h and they are both copied as public headers, which results in a "Warning: Multiple build commands for output file" warning
  • The Pods/Headers folder is messy, there isn't a nice folder called ZBarSDK, but there are three folders being generated: zbar, include and iphone.

Do you guys have any ideas how I could resolve these issues?
I've tried some stuff with s.public_header_files, but that doesn't work.

@Zyphrax
  • Removing s.header_mappings_dir = 'zbar' seems to reduce the folder clutter.
  • Still not able to remove the C headers from the Copy headers - public list. The option s.public_header_files does copy the right files to the Headers folder, but the project still adds all of them to the Copy headers - public list
@jinthagerman

I added this post_install script which removes the PBXBuildFile reference for all ZBarSDK/zbar header files which removes it from the copy headers list completely. It could be modified to move them into the Private list, but seeing as the header search paths are setup correctly it shouldn't be necessary. There are probably better ways to do this, but this my first time writing ruby.

def s.post_install(target_installer)
  project = target_installer.project
  project.objects_by_uuid.each do |key, obj|
    if obj.isa.to_s == "PBXBuildFile"
      file_ref = obj.file_ref
      if file_ref.isa.to_s == "PBXFileReference"
        path = file_ref.pathname

        if (path.extname.to_s == ".h" && path.dirname.to_s.include?("ZBarSDK/zbar"))
          project.objects_by_uuid.delete(key)
        end
      end
    end
  end
end
@jinthagerman

I added the compiler_flag and public_header_files options. It seems to be working quite well now.

https://gist.github.com/raw/4678569/004c738044a9cf48f8236620458fcce4c28ee529/ZBarSDK.podspec

@Zyphrax
@Zyphrax

There is one last issue with the podspec.
The line s.header_mappings_dir = 'zbar' is causing a bit of a mess in the Pods/Headers folder. Instead of a nice ZBarSDK folder, there are iphone and include folders.

Simply removing the line from the podspec seems to fix that.
Could you update that? Or is there a real reason for it in the podspec?

Thanks for your help!

@jinthagerman
@Zyphrax

Yeah, I don't know what the option does either, but it somehow removes the ZBarSDK folder level.
I don't know why anyone would ever want that, it just results in a mess and pods possibly mixing code.

More info here: https://github.com/CocoaPods/CocoaPods/wiki/The-podspec-format

@Zyphrax

I have removed the line in my local podspec and haven't had any issues with the pod.
Could you update the public one in the CocoaPods spec library?

Thanks

@jinthagerman
@jinthagerman

Updated the podspec. I believe this option is used when the header folder structure is important (i.e if you have lines like this in your code '#import "include/header.h"'. This isn't the case for ZBar.

@Zyphrax

Awesome, thanks

@Zyphrax Zyphrax closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.