-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pod install includes all xcassets from all targets #6159
Comments
I believe the problem is this section of the generated resource copy script: Maybe we can get a list of xcassets that are actually part of the target using xcodeproj? |
I have the same issue. |
I'd just like to add that we started experiencing a crash during the copy pods resources phase. The output from our CI:
The solution was to comment these lines out from the generated resources.sh scripts:
Then just ensure that the Copy Pods Resources phase happens before the normal Copy Resources phase. This resolved both this issue and the crash. But of course this is a hacky workaround... :) cc @drico |
As a workaround I rename all archives I don't want to "merge" before "[CP] Copy Pods Resources" an rename them back afterwards. |
@mfclarke what do you mean by "associated with the target"? |
@benasher44 I mean members of the target. For example:
I would expect that Target2 would only have assets from Common.xcassets and Target2.xcassets in the .app bundle. But, it also has the contents of the other xcasset bundles due to the way the cocoapods resources.sh script works. This is especially troublesome when the names of assets in the individual target xcasset bundles are the same. Since they're all copied into the .app bundle they just overwrite the files in there already and you end up with for example Target3's images in Target1's .app bundle. |
Hm okay, so you're saying that these targets have .xcassets that are only added in the main project (i.e. outside of your Podfile/pods), and then the resource copy script (from CocoaPods) is kind of re-bundling all of them together, when it's only meant to be doing it for pods? |
Exactly. The resources.sh specifically searches for all .xcasset bundles outside of the Pods folder and bundles them in. There's probably a good reason for this, but it doesn't play nice if you have multiple targets with different xcasset bundles. |
Hm interesting. Thanks for bring this to our attention! This definitely seems like a bug, and we'll try to look into it soon. Of course, we always appreciate PRs, so if you have time/energy to look into this even if it just results in a more detailed analysis of the root cause, we'd appreciate it! |
same probleme here when using carthage and cocoapods,it will add assets from the Carthage/Checkouts |
Is there any update on this? It increased the build time and my app size significantly. I had to move assets files out of asset catalogs to play nicely. |
No updates! I'm not sure that anyone is working on this at the moment. It's very likely that this has been an issue for some time, and we'd certainly appreciate anyone's willingness to attempt a PR to fix! |
We currently use this https://github.com/2359media/ios-dev-discussions/issues/7 workaround. |
Also wonder if this is fixed by #6694 |
I don't think it was fixed, I just stopped using asset catalogs as a whole. |
Hey @dnkoutso, in our case all our xcasset bundles contain assets with the same names (just different image content). So in the end the fix for us was ensuring I don't have a sample app handy sorry. |
Confirm still having this issue. CocoaPods 1.4.0 |
@almsta your link to a workaround does not work, can you explain the idea behind? |
@appmagnetics the mentioned linked contained the following, added to your Podfile: post_install do |installer_representation|
# Pods-<target>-resources.sh to only handle target specific xcassert files.
# orignal workaround found here: https://github.com/2359media/ios-dev-discussions/issues/7
installer_representation.aggregate_targets.each do |at|
files = at.user_targets.map{|t|
t.resources_build_phase.files_references.select{|f|
f.last_known_file_type == 'folder.assetcatalog'
}.map{|f|
Pathname.new(f.real_path).relative_path_from(f.project.path.dirname)
}
}.flatten
script = at.copy_resources_script_path
files = files.join('" "')
`sed -i '' 's@OTHER_XCASSETS=.*@XCASSET_FILES+=(\"#{files}\")@' '#{script}'`
end
end |
@almsta thanks a lot. Can you explain a bit what happens in your code snippet? You are running copy resources script with the explicit list of files? But what happens with the original copy files script which is installed by CocoaPods - will they get overwritten? |
@almsta I've compared the original and "fixed" script and I see how it works now, thanks! |
Definitely a bug. See more here #7779 (comment) |
It appears the link to the previous workaround is dead and the workaround posted above does not work for recent version of CocoaPods due to changes in the script. I have updated the workaround to support the script changes since my team still deals with this issue:
|
Report
What did you do?
Run pod install using CocoaPods 1.1.1. Then build a multi target project.
What did you expect to happen?
The target being built would contain only the xcassets that are associated with the target.
What happened instead?
xcassets were bundled in from all targets in the project
CocoaPods Environment
Stack
Installation Source
Plugins
Podfile
The text was updated successfully, but these errors were encountered: