6

I am currently using TextMate for OS X to create basic Ruby code (still learning), saving down as a .rb file and using Terminal to run the basic code.

I was just wondering if its possible for me to use XCode for this task at all? I am assuming not from what I've been reading but if it is does anyone know of a guide of how to set this up?

2 Answers 2

4

Take a look at MacRuby. The current stable version has Xcode integration. It does need a 64-bit system running Snow Leopard.

Sign up to request clarification or add additional context in comments.

Comments

1

If you want to execute a simple ruby script:

if let file = Bundle.main.url(forResource: "my_script", withExtension: "rb") {
  let task = Process()

  task.launchPath = "/usr/bin/env"
  task.arguments = ["ruby", file.path, "arg1"]

  let pipe = Pipe()
  task.standardOutput = pipe
  task.launch()

  let data:Data = pipe.fileHandleForReading.readDataToEndOfFile()
  if let output = String(data: data, encoding: String.Encoding.utf8) {
    print(output)
  }
}

make sure you have the my_script.rb file resource copied as a build resource - Warning: The Copy Bundle Resources build phase contains this target's Info.plist file

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.