MacRuby, CocoaPods, 10.7, and XCode 4.3
I have a MacRuby project that uses CocoaPods for many of its ObjC dependencies. I had a bit of trouble getting it to run properly with the latest version of Xcode (4.3). This had to do with a recent change I made to MABSupportFolder (use of isEmpty()) which triggered a fairly obscure bug in addition to the new XCode 4.3 organizational structure not being properly recognized at first.
The obscure MacRuby bug was being caused by running -count on an NSString. When using MacRuby if you test if a NSString responds to -count using -respondsToSelector: you’ll get true as the response because of Ruby’s String#count method. However, that method requires an argument, but running respondsToSelector:@selector(count) will return true for an NSString. This bug was triggered because of my usage of Will Shipley’s isEmpty() function.
If you recently upgraded to Xcode 4.3, make sure you run this command (got this tip from here):
[code]sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer[/code]
Or `pod install` will not run properly. Also, I just found out that CocoaPods does not use macruby anymore – you can run it using the system ruby install.
For someone trying to get MacRuby working with CocoaPods here is my Podfile:
[codee]
platform :osx
dependency ‘FMDB’
dependency ‘ASIHTTPRequest’
dependency ‘MABToolkit’
dependency ‘KFAppleScriptHandlerAdditions’
# Enable garbage collection support, which MacRuby requires.
post_install do |installer|
installer.project.targets.each do |target|
target.buildConfigurations.each do |config|
config.buildSettings[‘GCC_ENABLE_OBJC_GC’] = ‘supported’
end
end
end
generate_bridge_support!
[/codee]
The top of your main.rb should look like this:
[code]
framework ‘Cocoa’
load_bridge_support_file NSBundle.mainBundle.pathForResource(“Pods”, ofType:”bridgesupport”)
[/code]