Skip to content
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

fix copy multiple .xcassets resource error #3358

Closed
wants to merge 1 commit into from

Conversation

candyan
Copy link

@candyan candyan commented Apr 3, 2015

if a project has multiple .xcassets folder, the copy_resources.sh will occur a error.

like this:
error: Failed to read file attributes for "/Users/Candyan/Joyshare/Mobile/Arrietty/Arrietty/Images.xcassets /Users/Candyan/Joyshare/Mobile/Arrietty/Arrietty/test.xcassets" Failure Reason: No such file or directory

i found the problem in copy_resources.sh

'while read line' commond will read all result rather than one line of result.

@segiddins
Copy link
Member

@AliSoftware please take a look at this?

@AliSoftware
Copy link
Contributor

This PR seems good.

The travis failure is only due to integration specs not being rebuilt with the fixed script, we should probably fix/rebuild them along the way but I won't have time today, so postponing the merge until then. (except if @mrackwitz do rebuild them again today 😉)

@AliSoftware AliSoftware self-assigned this Apr 5, 2015
@sdarlington
Copy link

I think both versions fail if there are spaces in the file name. My alternate version is this:

XCASSET_FILES="$XCASSET_FILES $(find "$PWD" -path $PWD/Pods -prune -o -name "*.xcassets"  -print | sed "s/^\\(.*\\)$/'\\1'/")"

It works for me but I've not done much testing beyond my one project that was failing.

(I can create a pull request if you like but it might be easier to include in this one?)

@spenrose
Copy link

spenrose commented Apr 9, 2015

I had spaces in my file name because of the auto created watch kit extension. @sdarlington fixes the issue for me.

@candyan
Copy link
Author

candyan commented Apr 10, 2015

@sdarlington @spenrose

i can fix it.
i also have the problem.
but i use "-" replace spaces to solve it temporary

@bonkey
Copy link

bonkey commented Apr 10, 2015

How about using \0?

find "$PWD" -name "*.xcassets" -not -path "$PODS_ROOT/*" -print0 | while read -d $'\0' xcasset ; do
  XCASSET_FILES="$XCASSET_FILES '$xcasset'"
done

@sdarlington
Copy link

@bonkey Looks good (though I've not tried it). Didn't know about the -d option for read.

@candyan candyan force-pushed the master branch 2 times, most recently from 18e2d38 to e27c431 Compare April 10, 2015 11:33
@bonkey
Copy link

bonkey commented Apr 10, 2015

It needs some adjustments as it looks like XCASSET_FILES in a loop is a local copy only

@candyan
Copy link
Author

candyan commented Apr 10, 2015

@bonkey seems can use \n

@bonkey
Copy link

bonkey commented Apr 10, 2015

Found at least sth what works in my case:

    XCASSET_FILES="$XCASSET_FILES $(find "$PWD" -name "*.xcassets" -not -path "$PODS_ROOT/*" -exec echo -n " '{}'" \;)"

@sdarlington
Copy link

I still prefer @bonkey or my solution -- I think they're a lot clearer -- but if it works I'll be happy(!).

@romanr
Copy link

romanr commented Apr 12, 2015

I have same issue with large project containing multiple XCassets and App extension.

  • I have no spaces in the path or any of the file names or xcassets or any of the image names.
  • The original fix in this pull request did not help (which is changing while read line; do to while read -d $'\n' line; do

My solution was to use @sdarlington fix:
XCASSET_FILES="$XCASSET_FILES $(find "$PWD" -path $PWD/Pods -prune -o -name "*.xcassets" -print | sed "s/^\\(.*\\)$/'\\1'/")"

changing line 172 to
while read line; do XCASSET_FILES="$XCASSET_FILES $(find "$PWD" -path $PWD/Pods -prune -o -name "*.xcassets" -print | sed "s/^\\(.*\\)$/'\\1'/")";

Here's step by step for those who has same problem:

  1. Find out where your gems installed: ruby -r rubygems -e "p Gem.path"
  2. modify the lines at the end of file: sudo nano /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.36.3/lib/cocoapods/generator/copy_resources_script.rb (or whatever your path is) and change line 172 to the above.
  3. pod update in your project

kylef added a commit that referenced this pull request Apr 15, 2015
Allow support for pods with xcasset bundles using `:path`.

Closes #1549
Closes #3384
Closes #3358
@kylef
Copy link
Contributor

kylef commented Apr 15, 2015

Thanks for the pull request @candyan, this unfortunately doesn't completely fix the problem so I'm going to close this in favour of #3405.

@kylef kylef closed this Apr 15, 2015
kylef added a commit that referenced this pull request Apr 15, 2015
Allow support for pods with xcasset bundles using `:path`.

Closes #1549
Closes #3384
Closes #3358
kylef added a commit that referenced this pull request Apr 15, 2015
Allow support for pods with xcasset bundles using `:path`.

Closes #1549
Closes #3384
Closes #3358
kylef added a commit that referenced this pull request Apr 16, 2015
Allow support for pods with xcasset bundles using `:path`.

Closes #1549
Closes #3384
Closes #3358
cbrauchli pushed a commit to cbrauchli/CocoaPods that referenced this pull request Apr 21, 2015
Allow support for pods with xcasset bundles using `:path`.

Closes CocoaPods#1549
Closes CocoaPods#3384
Closes CocoaPods#3358
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants