Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Pods-resources.sh fails while copying .svn files to the app bundle #245

Closed
vytis opened this Issue · 22 comments

9 participants

@vytis

My project uses SVN and Pods-resources.sh fails with following errors:

cp -R <path>/Pods/SVProgressHUD/SVProgressHUD/SVProgressHUD.bundle <path>/Build/Products/Debug-iphoneos/Test.app
cp: <path>/Build/Products/Debug-iphoneos/Test.app/SVProgressHUD.bundle/.svn/all-wcprops: Permission denied
cp: <path>/Build/Products/Debug-iphoneos/Test.app/SVProgressHUD.bundle/.svn/entries: Permission denied
cp: <path>/Build/Products/Debug-iphoneos/Test.app/SVProgressHUD.bundle/.svn/prop-base/error.png.svn-base: Permission denied
cp: <path>/Build/Products/Debug-iphoneos/Test.app/SVProgressHUD.bundle/.svn/prop-base/error@2x.png.svn-base: Permission denied
cp: <path>/Build/Products/Debug-iphoneos/Test.app/SVProgressHUD.bundle/.svn/prop-base/success.png.svn-base: Permission denied
cp: <path>/Build/Products/Debug-iphoneos/Test.app/SVProgressHUD.bundle/.svn/prop-base/success@2x.png.svn-base: Permission denied
cp: <path>/Build/Products/Debug-iphoneos/Test.app/SVProgressHUD.bundle/.svn/text-base/error.png.svn-base: Permission denied
cp: <path>/Build/Products/Debug-iphoneos/Test.app/SVProgressHUD.bundle/.svn/text-base/error@2x.png.svn-base: Permission denied
cp: <path>/Build/Products/Debug-iphoneos/Test.app/SVProgressHUD.bundle/.svn/text-base/success.png.svn-base: Permission denied
cp: <path>/Build/Products/Debug-iphoneos/Test.app/SVProgressHUD.bundle/.svn/text-base/success@2x.png.svn-base: Permission denied

As a temporary fix I have added -f flag to the copy command, but I suppose it would be better to simply ignore .svn dir altogether...

@alloy
Owner

Indeed. I believe Xcode comes with its own cp command that has support for all these things already. If someone wants to investigate where it is and how to use it, that’d be great.

It should be fixed here: https://github.com/CocoaPods/CocoaPods/blob/master/lib/cocoapods/generator/copy_resources_script.rb#L16.

@vytis

It doesn't really fix it. The problem is that SVN litters the whole source tree with its .svn directories. The copy command fails inside one of the pods (SVProgressHUD). It seems that happens only when the pod uses a bundle, because it works fine for all other pods my project is using.

@cellularmitosis

I just got bitten by this, in the same way (a .bundle dir).

The problem appears to the that some of the files in a .svn dir have read-only permissions, and part of the cp process tries to write to the (destination) file, which it can't do, because it created it read-only...

sa-devbuild01:~ someuser$ ls -l /Users/someuser/Library/Developer/Xcode/DerivedData/...-fqjswmblksyencaipzxadjpvcioq/Build/Products/AdHoc-iphoneos/.../.../.svn
total 16
-r--r--r--  1 someuser  staff  350 Jun 26 12:21 all-wcprops
-r--r--r--  1 someuser staff  461 Jun 26 12:21 entries
@cellularmitosis

(submitted previous comment prematurely)

but yes, we shouldn't be copying .svn dirs of a .bundle dir into the destination staging area anyway.

@cellularmitosis

hmm, it appears rsync has built-in support for ignoring a large variety of files (git, svn, cvs, etc).

see http://superuser.com/a/48003

rsync -avC /path/to/source/directory /path/to/destination/directory
@cellularmitosis

I suppose an alternative would be to have svn sources in a Pod be fetched using 'svn export' rather than 'svn co'.

I suppose the developer of an upstream pod source may wish to have the convenience of having his Pods dir be "check-in-able", but I think that's the minority use-case: the vast majority of podspec users won't have svn write access to the upstream sources.

perhaps we can make the default 'svn export', and perhaps allow a mechanism to force 'svn checkout' instead?

@cellularmitosis

(patch for the above suggested solution, but without any option to force "checkout" behavior):


--- lib/cocoapods/downloader/subversion.rb.orig 2012-06-26 15:06:29.000000000 -0500
+++ lib/cocoapods/downloader/subversion.rb  2012-06-26 15:06:43.000000000 -0500
@@ -12,11 +12,11 @@
       end

       def download_head
-        svn "checkout '#{url}' '#{target_path}'"
+        svn "export '#{url}' '#{target_path}'"
       end

       def download_revision
-        svn "checkout '#{url}' -r '#{options[:revision]}' '#{target_path}'"
+        svn "export '#{url}' -r '#{options[:revision]}' '#{target_path}'"
       end
     end
   end
@cellularmitosis

apparently it isn't that simple.

Installing AdMarvel (2.9.1)
[!] Failed: /usr/bin/svn export 'https://...
...
private method `select' called for nil:NilClass
/Users/cell/opt/CocoaPods-0.6.0.rc3/lib/cocoapods/local_pod.rb:309:in `all_specs_public_header_files'
@cellularmitosis

ah, some other part of cocoapods is creating the dest dir, which causes svn export to barf.

a work-around is to use --force.

--- lib/cocoapods/downloader/subversion.rb.orig 2012-06-26 15:06:29.000000000 -0500
+++ lib/cocoapods/downloader/subversion.rb  2012-06-26 15:06:43.000000000 -0500
@@ -12,11 +12,11 @@
       end

       def download_head
-        svn "checkout '#{url}' '#{target_path}'"
+        svn "export --force '#{url}' '#{target_path}'"
       end

       def download_revision
-        svn "checkout '#{url}' -r '#{options[:revision]}' '#{target_path}'"
+        svn "export --force '#{url}' -r '#{options[:revision]}' '#{target_path}'"
       end
     end
   end
@cellularmitosis

hey guys,

I just set up another co-worker with cocoapods, and was bitten by this issue again, which reminded me that I had hacked my own copy of cocoapods to force an svn export instead of a checkout.

Is anyone actually using svn-based podspecs successfully using the default checkout behavior rather than export behavior?

If we don't make export the default, perhaps we can provide an alternate method of specifying the source in the podspec, which indicates export rather than checkout behavior?

i.e., something like:

s.source = { :svnex => 'http://...' }

-jason

@fabiopelosin

I'm not familiar with svn but I think that we should export. If people want to use versioned code there is the upcoming (actually resurrecting) local download option.

Regarding the --force the problem looks that is due to the fact that we create the empty pod folder before, However I don't see any reason for doing it.

Lets see what is @alloy's take.

@alloy
Owner

I think changing it to export is fine, please create a pull-request for that.

However, it doesn’t fix the situation where a user has the project in a SVN repo, which would add the .svn dirs to the bundles again. So our copy script should be aware of this nonetheless. I believe Xcode has a copy tool that does all these things correctly.

@cellularmitosis

@alloy I just realized this would still be an issue (if a user checked in their entire Pods dir into svn) when discussing this with a co-worker yesterday.

I'll create a pull request for the export change, but I'm not sure what needs to be done about the copy tool. Should that be a separate ticket?

@cellularmitosis

I've created a pull request, but I don't know ruby, so I didn't understand the '%|checkout' syntax, and instead just added the 'export' operand directly into the quoted section. Please let me know if this is wrong.

I didn't include the --force flag as it sounds like that issue should be resolved by not creating an empty dir before doing the export, but I don't know where in the code that change needs to happen. This means the subversion downloader will be broken.

Sorry, this is about as good as I can do with a pull request at this point in time.

@mgrebenets

So this one is still open?
It's quite a pain. To build a project successfully I have to clean it every time, otherwise getting "Permission denied" errors from 'cp' command, all caused by SVProgressHUD.bundle/.svn contents.

The problem appeared after I put my source into svn repo and made working copy from it.
Before source was put under svn control there were no problems of this type.

It's with latest CocoaPods version 0.15.2.

Until that's solved in CocoaPods itself, can anyone point me to the workaround?
Is it possible to come up with custom podspec for SVProgressHUD that does things the "right" way?
Or a custom shell script in build phase to change permissions?

P.S.
and git rules in this regard, but I have to stick with svn for this particular project

@fabiopelosin
Owner

We are looking into adding the Copy Resources phase of the integrated target which should solve this issue. Unfortunately I don't know any workaround to suggest.

@mgrebenets

Hi again. Looks like there is a straightforward solution - change permissions on folders manually.
I didn't change permissions directly though, I copied the whole project to a flash drive, then worked with that project on another machine, then copied modified files back to original computer.

The problem disappeared right after the first copy. I assume the permissions were changed for copied files.

@ShengHuaWu

Have encountered this issue. Could any one teach me how to add -f flag to cp command? Thanks very much.

@forthenature

I just made a change on install_resource() in Pods-resources.sh .
I replaced
cp -R "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
with
rsync -av --exclude '/.svn/' "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}";

and everything is ok.

@alloy alloy referenced this issue
Closed

Copy resources v2 #743

@Matiaz

This is what worked for me,

I deleted all the pods located on the Pods Folder of the project and later I did a "pod install" when everything was downloaded I opened the project with xcode again and did a "Project->Clean" after that just Build and run and that solved my problem.

Again that worked for me. :)

@fabiopelosin

Closing as from 0.17 there is almost no need to add the Pods folder under source control (As long as you trust the remotes containing the sources to be up). Also we plan to migrate to a more rousts system based on resources bundles.

@tiemevanveen

"Closing as from 0.17 there is almost no need to add the Pods folder under source control (As long as you trust the remotes containing the sources to be up). Also we plan to migrate to a more rousts system based on resources bundles."

It might be obvious to ignore the Pods folder with SVN or Git but maybe it is a good idea to add this to this page?

http://docs.cocoapods.org/guides/integrating_a_project.html

@yalp yalp referenced this issue from a commit in yalp/cocoapods-downloader
@yalp yalp Add :checkout option to allow checkinable pod when using --no-clean
The svn downloader uses export instead of checkout by default since
CocoaPods/CocoaPods#473.

But having a "checkin-able" pod is still usefull for the Pods developpers even
if it has been aggreed to be a minority-use case.
(from CocoaPods/CocoaPods#245 discussion).
bd3ea5f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.