Search code examples
cocoapods

Environment variables in Podspec


I have an open source library that is build automatically by a CI system, and deployed in trunk/cocoapods automatically by the CI itself.

I would like to reduce the human-error possibility in the library version. Currently, when a new release is ready I have to go inside the podspec and manually modify the version tag.

Since the CI automatically release the library for every new git-tag, is there a way to use the CI environment variables in the podspec?.

In particular I tried the following:

Pod::Spec.new do |s|
.......
 s.version      = ${CI_COMMIT_TAG}
......

But doesn't seems to work.

Any ideas how to use environment variables for it?

Something better then a text search-replace script maybe :D


Solution

  • After some research and tries this seems to work for me:

    s.version      = "#{ ENV['CI_COMMIT_TAG'] }"