命令行编译之xcodebuild

A. 确保xcodebuild命令能正常运行

如果使用xcodebuild命令出现如下错误:

could not stat active Xcode path '/Volumes/Xcode/Xcode.app/Contents/Developer'. (No such file or directory)

解决办法:

xcode-select -switch 新的xcode路径



sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer


B. xcodebuild使用

1. 查看xcode版本号和build号
imac:demo maricoliu$ xcodebuild -version
Xcode 4.6.2
Build version 4H1003

2. 查看当前系统的sdk及版本
imac:demo maricoliu$ xcodebuild -showsdks
OS X SDKs:
Mac OS X 10.7                 -sdk macosx10.7
OS X 10.8                     -sdk macosx10.8

iOS SDKs:
iOS 6.1                       -sdk iphoneos6.1

iOS Simulator SDKs:
Simulator - iOS 6.1           -sdk iphonesimulator6.1

3. 查看工程项目信息
先cd到工程目录下
imac:demo maricoliu$ xcodebuild -list
Information about project "demo":
    Targets:
        demo
        demoTests

    Build Configurations:
        Debug
        Release

    If no build configuration is specified and -scheme is not passed then "Release" is used.

    Schemes:
        demo

4. 编译工程
默认编译release版本
imac:demo maricoliu$ xcodebuild -target demo

编译debug版本
imac:demo maricoliu$ xcodebuild -target demo -configuration Debug

5.clean工程
imac:demo maricoliu$ xcodebuild clean

你可能感兴趣的:(mac,命令行编译,xcodebuild)