How to create a Ruby string within a CocoaPod PodSpec?

cocoapods, ios, ruby

Solution

You are missing a `.to_s` call. I created a sample podspec to reproduce your issue. Indeed, the:

s.source = { :git => ..., :tag => 'v' +  s.version }

does not pass validation using `lint` and I got lots of errors. However, I added the `to_s` call and it worked for me and `lint` started fetching my `v1.0.0` tag.

s.source = { :git => ..., :tag => 'v' +  s.version.to_s }

Hope it helps.

Problem

There is a common trick to re-use a string within a pod spec: ``` s.version = '0.0.2' s.source = { :git => ..., :tag => s.version } ``` By reusing the s.version string after it's assigned, I don't have to remember to change two fields when I update my `podspec`. But, what I'd really like to do is tag my code with "v0.0.2", not "0.0.2". So I tried to just create a new string by prepending a 'v' to the version: ``` s.source = { :git => ..., :tag => 'v' + s.version } ``` However, that bombs the `pod` command. I recall seeing a trick while searching for something else a while ago that showed how to inject Ruby code into a spec, but I cannot find it now, and even if I could not sure it addressed what I'm trying to do. So, my question is, is this even possible, and if so, how do I accomplish it?

Original source