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
base: master
from

Conversation

Projects
None yet
8 participants
@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

This comment has been minimized.

Show comment
Hide comment
@segiddins

segiddins Apr 4, 2015

Member

@AliSoftware please take a look at this?

Member

segiddins commented Apr 4, 2015

@AliSoftware please take a look at this?

@AliSoftware

This comment has been minimized.

Show comment
Hide comment
@AliSoftware

AliSoftware Apr 4, 2015

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 😉)

Contributor

AliSoftware commented Apr 4, 2015

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

This comment has been minimized.

Show comment
Hide comment
@sdarlington

sdarlington Apr 8, 2015

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?)

sdarlington commented Apr 8, 2015

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

This comment has been minimized.

Show comment
Hide comment
@spenrose

spenrose Apr 9, 2015

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

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

This comment has been minimized.

Show comment
Hide comment
@candyan

candyan Apr 10, 2015

@sdarlington @spenrose

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

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

This comment has been minimized.

Show comment
Hide comment
@bonkey

bonkey 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

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

This comment has been minimized.

Show comment
Hide comment
@sdarlington

sdarlington Apr 10, 2015

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

sdarlington commented Apr 10, 2015

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

@bonkey

This comment has been minimized.

Show comment
Hide comment
@bonkey

bonkey Apr 10, 2015

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

bonkey commented Apr 10, 2015

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

@candyan

This comment has been minimized.

Show comment
Hide comment
@candyan

candyan Apr 10, 2015

@bonkey seems can use \n

candyan commented Apr 10, 2015

@bonkey seems can use \n

@bonkey

This comment has been minimized.

Show comment
Hide comment
@bonkey

bonkey 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 " '{}'" \;)"

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

This comment has been minimized.

Show comment
Hide comment
@sdarlington

sdarlington Apr 10, 2015

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

sdarlington commented Apr 10, 2015

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

@romanr

This comment has been minimized.

Show comment
Hide comment
@romanr

romanr 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

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

[Copy Resources] Resolve various problems with xcasset bundles
Allow support for pods with xcasset bundles using `:path`.

Closes #1549
Closes #3384
Closes #3358
@kylef

This comment has been minimized.

Show comment
Hide comment
@kylef

kylef Apr 15, 2015

Contributor

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.

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

[Copy Resources] Resolve various problems with xcasset bundles
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

[Copy Resources] Resolve various problems with xcasset bundles
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

[Copy Resources] Resolve various problems with xcasset bundles
Allow support for pods with xcasset bundles using `:path`.

Closes #1549
Closes #3384
Closes #3358

cbrauchli added a commit to cbrauchli/CocoaPods that referenced this pull request Apr 21, 2015

[Copy Resources] Resolve various problems with xcasset bundles
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