aqavi_paracha
aqavi_paracha

Reputation: 1131

Cocoapod compilation fails when loading .xib file

I've pushed it to trunk. And then I did "pod install" to my own project, all files are downloaded (I can confirm it from Pods in my project). But it doesn't compile, it gives me this error

"Unable to run command 'StripNIB ABPhotoView.nib' - this target might include its own product."

Upvotes: 3

Views: 2462

Answers (4)

Denis Kutlubaev
Denis Kutlubaev

Reputation: 16144

I had the same problem, when podspec file was incorrect. My mistake was that I didn't specify .h and .m extensions for source_files. Because of that .xib files were added twice. This is a correct example:

  s.source_files = 'YourTarget/Classes/**/*.{h,m}'

  s.resources = ['YourTarget/Classes/UIComponents/**/*.xib']

See https://guides.cocoapods.org/syntax/podspec.html#source_files

Upvotes: 1

Martin
Martin

Reputation: 12215

It seems the syntax has evolved, maybe since the new Cocoapods version (1.0)

When you create your pod with the template described here, your .podspec will contain some commented lines to include assets (like .png or .xib)

#  s.resource_bundles = {
#   'MyMarvelousComponent' => ['MyMarvelousComponent/Assets/*.png']
#  }

Just uncomment, change the .png with what you want to include, and move your files to Assets/ folder (because, this is the folder where they should be)

Note Cocoapods will automatically create a .bundle in the Products/ group, so if you need these assets in the example project, you'll need to select the right NSBundle first.

Upvotes: 1

Mike Demidov
Mike Demidov

Reputation: 1127

It's crazy! Used to have the same issue when had such podspec string

s.resources = "Project/**/*.{png,bundle,xib,nib}"

changing to

s.resource = "Project/**/*.{png,bundle,xib,nib}"

has solved the problem.

Upvotes: 1

aqavi_paracha
aqavi_paracha

Reputation: 1131

Have found the solution. Follow below:

rather than adding a reference to the file in the s.source_files, I put it in the s.resources as shown below

s.resources = ["images/*.png", "classes/MyView.xib"]

For more details, https://github.com/bennyguitar/CollapseClick/issues/14

Upvotes: 11

Related Questions