Please sign in to comment.
update gemspec to better support Linux
Right now if you run `gem install calatrava` on Linux you'll encounter an error trying to build native extensions for Xcodeproj, as the gem hosted on RubyGems was built on a Mac. This change moves the platform-specific dependency installation into a "native extension" so that it can take place at gem-install time rather than package-build time. For more info see this blog post: http://www.programmersparadox.com/2012/05/21/gemspec-loading-dependent-gems-based-on-the-users-system/ Note that this approach is considered by some (including the author of the above post) to be a hack. However, the alternative is to create platform- specific gems, which feels even less desirable (at least to me).
- Loading branch information...
Showing with 30 additions and 5 deletions.
|@@ -0,0 +1,29 @@|
|+# This is a hack to enable platform-specific dependencies in a single gem.|
|+# For background info see:|
|+# Code primarily borrowed from here:|
|+installer = Gem::DependencyInstaller.new|
|+ # I don't *think* you can use Calatrava.platform == :mac here as it seems|
|+ # RubyGems builds Ruby extensions without the dependencies declared in the gemspec.|
|+ if RUBY_PLATFORM =~ /darwin/|
|+ installer.install "xcodeproj", ">= 0.4.0"|
|+ installer.install "cocoapods", "~> 0.16.0"|
|+rescue Exception => ex|
|+ # Exit with a non-zero value to let RubyGems know something went wrong.|
|+ exit 1|
|+# Since this is Ruby, RubyGems will attempt to run Rake.|
|+# If it doesn't find and successfully run a Rakefile, it errors out.|
|+File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") do |f||
|+ f.write "task :default\n"|