0

I'm writing a post_install script in a Podfile, and I need to modify a particular scheme. I'm new to Ruby, so I'm sure I have many bad/non-idiomatic habits. Here's what I have:

post_install do |installer|
  pods_project = installer.pods_project
  scheme_filename = "BonMot.xcscheme"
  scheme = Xcodeproj::XCScheme.new File.join(pods_project.path, "xcshareddata/xcschemes", scheme_filename)
  # do stuff with scheme
end

How can I avoid the hardcoded xcshareddata/xcschemes in the middle? Or is that the best way to do this?

Zev Eisenberg
  • 8,080
  • 5
  • 38
  • 82

1 Answers1

1

You can use Xcodeproj::XCScheme.shared_data_dir(project_path)

(Agreed we could have a better way to create an Xcodeproj::XCScheme instead directly from the Xcodeproj::Project instance to make this easier)

So something like this should work:

scheme_path = Xcodeproj::XCScheme.shared_data_dir(project.path) + 'BomMot.xcscheme'
scheme = Xcodeproj::XCScheme.new(scheme_path)
AliSoftware
  • 32,623
  • 6
  • 82
  • 77