Cocoapods: Specs using resource_bundle broken on CocoaPods 1.0.0.beta.6

Created on 15 Mar 2016  Â·  33Comments  Â·  Source: CocoaPods/CocoaPods

The documentation for the usage of resource bundles suggests that Spec files use a format like so:

spec.resource_bundles = {
    'MapBox' => ['MapView/Map/Resources/*.png'],
    'OtherResources' => ['MapView/Map/OtherResources/*.png']
  }

When this declaration is done cocoapods generates a new target for the copy resources phase of the bundle. It looks like the path for this bundle is incorrect as it now ends up in Pod/Pod/Pod.bundle where the expected path from the copy script phase is Pod/Pod.bundle.

Changing the spec to use spec.resource = 'Path/To/Bundle.bundle' resolves the issue and removes the extra target.

What did you do?

Created a simple podfile under CocoaPods 1.0.0.beta.2 -> 1.0.0.beta.6 using a Spec that uses resource_bundle. Ran pod install and then attempt to build the resulting project.

What did you expected to happen?

The project to build and a happy simulator to open up with the app running.

What happened instead?

The copy bundle resources phase fails to identify the bundle and the bundle is also not present in the project structure.

It seems as though I should find a .bundle under the specific pods directory but instead I see a folder structure of POD_NAME/Assets/ios/{Resources that should be in a bundle but are now clearly visible}

Interestingly enough Specs that use the resources tag and specify bundles work normally. As an example the GoogleAppIndexing pod works fine and one will see the .bundle in the correct location.

My suspicion is that this is a regression of #4762 ?

Podfile

use_frameworks!

target 'NYTPhotoViewerFun' do
    pod 'NYTPhotoViewer'
end

Working Spec

I forked 'NYTPhotoViewer' [https://github.com/danielgalasko/NYTPhotoViewer/blob/danielgalasko-cocoapods-1.0.0/NYTPhotoViewer.podspec#L19] and this works

Failing Spec

The original Spec that was working on CocoaPods 0.39.0 can be found here

confirmed defect ★

Most helpful comment

@benasher44: Thanks for the hint. Yes, this is a regression.
Sorry y'all for breaking that (again). In face of that I opened #5048. Contributions in that direction would be really welcome!

All 33 comments

Could also be related to #4963

I confirm I have the same issue, this used to work on beta5.

I've been able to fix this issue locally by modifing bundle pod target, where I change CONFIGURATION_BUILD_DIR from: $CONFIGURATION_BUILD_DIR/BUNDLE_NAME to $CONFIGURATION_BUILD_DIR

I have the same Issue. The bundle is in the wrong location it's in $CONFIGURATION_BUILD_DIR/TARGET_NAME/TARGET_NAME/BUNDLE_NAME instead of $CONFIGURATION_BUILD_DIR/TARGET_NAME/BUNDLE_NAME

@appveng3r @diejmon can you explain how you modify the bundle pod target? Is it supposed to be inside the Pods/Target Support Files/Pods-TARGET_NAME/Pods-TARGET_NAME-resources.sh file?

@tkuichooseyou I changed in Pod-Target-resource.sh one line from
install_resource "$CONFIGURATION_BUILD_DIR/gujemsiossdk/gujemsiossdk.bundle" to install_resource "$CONFIGURATION_BUILD_DIR/gujemsiossdk/gujemsiossdk/gujemsiossdk.bundle" to make it work.

My suspicion is that this may be a result of Specs passing actual file extensions inside of the bundle declaration:

    ss.ios.resource_bundle = { s.name => ['Pod/Assets/ios/*.png'] }

Whereas simply passing the bundle path like so

    ss.ios.resource_bundle = { s.name => ['Path/To/Bundle/MYBundle.bundle'] }

Will try and see if I can get a spec working with the latter

My bad, I see the documentation explicitly states it should be done this way i.e. ss.ios.resource_bundle = { s.name => ['Pod/Assets/ios/*.png'] }

So this is definitely still a bug with CocoaPods

Looks like the culprit is using resource_bundle. I went ahead and changed the pod spec to use resource and the project builds successfully. See the new Spec here

Ah, having the same issue with beta 6. Reverted to beta 5 for now.

Documentation recommends using resource_bundles instead of resources:

We strongly recommend library developers to adopt resource bundles as there can be name collisions using the resources attribute.

Having the same issue since beta6. beta5 works fine.

Here is my workaround for beta 6:

<removed>

I am using separated bundles, i think the workaround does not fit for that.

s.resource_bundles = {
'C24CoreUI' => ['Pod/Assets/UI//.storyboard', 'Pod/Assets/UI//_.xib', 'Pod/Assets/UI/Images/__/_'],
'C24CorePlist' => ['Pod/Assets/Plist//
.plist'],
'C24CoreSQLiteDB' => ['Pod/Assets/Database/
/_.sqlite'],
'C24CoreJSON' => ['Pod/Assets/JSON/__/_.json'],
'C24CoreHTML' => ['Pod/Assets/HTML/*_/_'],
}

Should still work, essentially it works when set at the platform level but not above that. You just have to make it a variable and pass that in at the platform level.

Thank you for your answer, unfortunately not. Looks like i have to wait for beta7 :)

Sorry, looks like I faked myself out, my workaround did not work.

Temporary workaround: Change every line of

install_resource "$CONFIGURATION_BUILD_DIR/{LibName}/{BundleName}.bundle" to install_resource "$CONFIGURATION_BUILD_DIR/{LibName}/{LibName}/{BundleName}.bundle"

in Pods-{ProductName}-resources.sh

Backup this file before you doing this...!

@exherb I tried changing my Pods-{ProductName}-resources.sh file to that but I still got the same error with not finding the .bundle file, I'm on beta5

@tkuichooseyou look into the error message and match the path.

When i work on a framework with bundles, would not a pod install overwrite the path changes every time? Unfortunately i have todo so every time i pull our latest version.

Confirmed that this is happening to me as well. The issue is that the build phase is trying to a copy a the resource from $BUILT_PRODUCTS_DIR/PodName/PodName.bundle, but the bundle actually lives in $BUILT_PRODUCTS_DIR/PodName/PodName/PodName.bundle.

Looks like something in CocoaPods has nested the pod one extra level deep in the folder hierarchy than required.

I should note that the built framework itself is correctly placed at $BUILT_PRODUCTS_DIR/PodName/PodName.framework. It's just the bundle that is located at $BUILT_PRODUCTS_DIR/PodName/PodName/PodName.bundle.

@mrackwitz this appears to be a regression from #5028. I've made a branch where I reverted that merge, and if I install my branch instead of the main 1.0.0.beta.6 tag, my project builds again.

@benasher44: Thanks for the hint. Yes, this is a regression.
Sorry y'all for breaking that (again). In face of that I opened #5048. Contributions in that direction would be really welcome!

@danielgalasko Your solution works perfectly!

FWIW I'm also having this problem with beta6 and MWPhotoBrowser 2.1.1, changing the install_resource line also "fixes" the problem for me.

I fixed the problem by removing the override on the Per-configuration Build Product Path setting in the Pods project resource bundle target.

I am using a resource_bundle in ProductLayerSDK, the bundle gets created in

/Users/oliver/Library/Developer/Xcode/DerivedData/ProdlyApp-gvyzwkhhrigehfcbcfriqozupkkw/Build/Products/Debug-iphonesimulator/ProductLayerSDK/ProductLayerSDK/ProductLayerSDK.bundle

But the final step - where it copies that into the framework expects it at this location:

/Users/oliver/Library/Developer/Xcode/DerivedData/ProdlyApp-gvyzwkhhrigehfcbcfriqozupkkw/Build/Products/Debug-iphonesimulator/ProductLayerSDK/ProductLayerSDK.bundle

So the second path has one more ProductLayerSDK in it.

screen shot 2016-04-09 at 18 00 06

Does this help?

@odrobnik this is a known issue with a open PR fixing it, see if Marius's PR addresses the issue for you?

@segiddins No idea how I would do that. I am only able to update Cocoapods via gems, and have messed with its source code.

There is a guides page for "using unreleased features"

This still seems to be an issue.

I'm getting

error: /Users/Library/Developer/Xcode/DerivedData/DopamineKit-bqzpbftalgimbyaujrgefxksivjl/Build/Products/Debug-iphonesimulator/DopamineKit/DopamineKit.framework: No such file or directory

I'm using resource_bundle and adding a bundle with a name different than my framework

s.resource_bundle = { 'CandyIcons' => 'Resources/**/CandyIcons.xcassets' }

edit:

Samething happens with .ios.resource_bundle

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tlandsmancars picture tlandsmancars  Â·  3Comments

pronebird picture pronebird  Â·  3Comments

pallaviMN picture pallaviMN  Â·  3Comments

lzwjava picture lzwjava  Â·  3Comments

spencerkohan picture spencerkohan  Â·  3Comments