Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add `prepare_command` to Specification DSL #1247

Closed
fabiopelosin opened this Issue Aug 1, 2013 · 14 comments

Comments

Projects
None yet
8 participants
Owner

fabiopelosin commented Aug 1, 2013

Give the recent introduction of the resources_bundle the usage case for the specification hooks are exhausting. It has been agreed to drop the post_install hook and to replace the pre_install hook with the prepare_command attribute.

The prepare_command would take a bash script (a string) and this script would be executed before the Pods project is built to allow the script to generate and modify the files which would be picked by the other attributes.

The script could simply execute a more complex script stored in the repository of the Pod.

Owner

alloy commented Aug 1, 2013

And this prepare_command will be executed with a working dir that’s the root of the library.

Owner

fabiopelosin commented Aug 1, 2013

As the purpose of the command is to just generate/modify files it will be executed only once, after the download of the pod and before it is cleaned.

Owner

fabiopelosin commented Aug 2, 2013

This was already implemented in master.

Zyphrax commented Aug 8, 2013

Will this automaticly resolve #1194?
(is prepare_command guaranteed to be executed only once?)

Owner

fabiopelosin commented Aug 8, 2013

Yes, the pre install hook was executed during every installation as it was used in some cases to append files to the resources script (which is recreated from scratch). This is not necessary anymore because we have dedicated attributes for that now.

odrobnik commented Aug 8, 2013

@irrationalfab Where is a sample for the prepare_command?

How would the following need to be changed?

spec.pre_install do |pod_representation, library_representation|
  Dir.chdir(pod_representation.root + 'Core/Source/') do
    Dir.glob('*.css') do |css_file|
      system '/usr/bin/xxd', '-i', css_file, css_file + '.c'
    end
  end
end
Owner

fabiopelosin commented Aug 8, 2013

Here. It is just a bash script executed in the root of the Pod.

odrobnik commented Aug 8, 2013

@irrationalfab What should I do about this? Travis-CI complains about this, but the latest stable CocoaPods I am getting from gem update is 0.22.3.

If I update this for the unstable version then the spec would fail to install for all people who have the latest stable version...

odrobnik commented Aug 8, 2013

PS: Like this?

spec.prepare_command = '/usr/bin/xxd -i Core/Source/default.css Core/Source/default.css.c'
Owner

fabiopelosin commented Aug 8, 2013

My mistake about updating the version of the specs repo. Btw, the 0.23 release is out. The command looks good to me.

@jzapater jzapater pushed a commit to jzapater/CocoaPods that referenced this issue Sep 17, 2013

@keith keith Merge pull request #1247 from LFabien/cedar
[Update] Cedar (0.9.1)
4e73412

Are there any variables available to be passed to the prepare_command? I'm looking for a way to tell it the path to the consuming project.

kenoy commented Jun 17, 2015

Hi, I'm new to CocoaPods, can you please confirm whether post_install hook is still working in PodFile? I am a bit confused as the documentation is still on the website https://guides.cocoapods.org/syntax/podfile.html#post_install suggesting its valid but reading this thread suggests it has been dropped. I have tried to do some logging within the hook and using version 0.37.2 and it appears it wasn't going through the post_install, so just wanted confirmation. Thanks!

Owner

orta commented Jun 17, 2015

It still exists @kenoy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment