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

Add prepare_command to Specification DSL #1247

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

Add prepare_command to Specification DSL #1247

fabiopelosin opened this issue Aug 1, 2013 · 14 comments
Labels
t1:enhancement Enhancements that have not been picked up yet. Please comment if you plan to work on it

Comments

@fabiopelosin
Copy link
Member

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.

@alloy
Copy link
Member

alloy commented Aug 1, 2013

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

@fabiopelosin
Copy link
Member Author

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.

@fabiopelosin
Copy link
Member Author

This was already implemented in master.

@yvbeek
Copy link

yvbeek commented Aug 8, 2013

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

@fabiopelosin
Copy link
Member Author

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
Copy link

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

@fabiopelosin
Copy link
Member Author

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

@odrobnik
Copy link

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
Copy link

odrobnik commented Aug 8, 2013

PS: Like this?

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

@fabiopelosin
Copy link
Member Author

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

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

besi commented Feb 13, 2014

See the guides for prepare_command http://guides.cocoapods.org/syntax/podspec.html#prepare_command

@phatblat
Copy link

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.

@kennethcervantes
Copy link

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!

@orta
Copy link
Member

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
Labels
t1:enhancement Enhancements that have not been picked up yet. Please comment if you plan to work on it
Projects
None yet
Development

No branches or pull requests

8 participants