How to run xcode from terminal?

后端 未结 7 2442
挽巷
挽巷 2020-12-23 11:37

My question is very simple: suppose there is an xcode project a.xcodeproj, could I open it with the command: xcode a.xcodeproj?

If I try this, I receiv

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-23 11:50

    Can't remember where I came across this script, but I use this ruby script for finding either a *.xcodeproj or *.xcworkspace file in the working directory and opening that file (without Xcode opening any previous projects)

    #!/usr/bin/env ruby
    
    # Open xcode without any previous projects being opened as well.
    # We first look for a workspace, then a project in the current directory, opening the first that is found.
    
    f = []
    f.concat Dir["*.xcworkspace"]
    f.concat Dir["*.xcodeproj"]
    
    if f.length > 0
      puts "opening #{f.first}"
      `open -a /Applications/Xcode.app #{f.first} --args -ApplePersistenceIgnoreState YES`
      exit 0
    end
    
    puts "No Xcode projects found"
    exit 1
    

提交回复
热议问题