Class: DevToolsCore::PBXProject

Inherits:
NSObject
  • Object
show all
Defined in:
lib/xcodeproj/plist_helper.rb

Ruby value to CFTypeRef conversion collapse

Constructor Details

#initialize(path) ⇒ PBXProject

Returns a new instance of PBXProject.



705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
# File 'lib/xcodeproj/plist_helper.rb', line 705

def initialize(path)
  DevToolsCore.silence_stderr do
    CoreFoundation.IDEInitialize(1, CoreFoundation::NULL)

    # The parameter is whether UI must be initialized (which we don't need)
    CoreFoundation.XCInitializeCoreIfNeeded(0)
  end

  selector = 'projectWithFile:'

  if NSObject.respondsToSelector(PBXProject.objc_class, selector)
    projectWithFile = PBXProject.objc_msgSend([CoreFoundation::VoidPointer])
    @project = projectWithFile.call(
      PBXProject.objc_class,
      CoreFoundation.NSSelectorFromString(CoreFoundation.RubyStringToCFString(selector)),
      CoreFoundation.RubyStringToCFString(path))
  end
end

Instance Method Details

#closeObject



724
725
726
727
728
729
730
# File 'lib/xcodeproj/plist_helper.rb', line 724

def close
  selector = 'close'
  return unless NSObject.respondsToSelector(@project, selector)

  close = PBXProject.objc_msgSend([], CoreFoundation::Void)
  close.call(@project, CoreFoundation.NSSelectorFromString(CoreFoundation.RubyStringToCFString(selector)))
end

#writeToFileSystemProjectFileObject



732
733
734
735
736
737
738
739
740
741
742
743
744
# File 'lib/xcodeproj/plist_helper.rb', line 732

def writeToFileSystemProjectFile
  selector = 'writeToFileSystemProjectFile:userFile:checkNeedsRevert:'
  return unless NSObject.respondsToSelector(@project, selector)

  writeToFile = PBXProject.objc_msgSend([CoreFoundation::Boolean, CoreFoundation::Boolean, CoreFoundation::Boolean], CoreFoundation::Boolean)
  result = writeToFile.call(
    @project,
    CoreFoundation.NSSelectorFromString(CoreFoundation.RubyStringToCFString(selector)),
    1,
    0,
    1)
  result == CoreFoundation::TRUE ? true : false
end