LoginSignup
86
81

More than 5 years have passed since last update.

XcodeのCLI系コマンドまとめ

Posted at

普段あまり触れることのないXcodeのCLI(コンソール コマンド)ですが、ワークフローやテストの自動化の際に重宝するのでまとめてみます。

実行環境

  • Xcode 6.1.1 (6A2008a)

Command Line Toolsをインストールする

XcodeのXcodeメニューから以下を押下します。

Open Developer Tool -> More Dveloper Tools...

全画面_2015_02_22_20_49.jpg

Kobito.jpg

バージョン番号を設定、ビルド番号をインクリメントする agvtool

準備

プロジェクトをXcodeでオープンします。
Project Navigator (⌘1) を選択し、Build Settings タブを表示します。

Current Project Version にビルド番号の初期値を設定します。
Versions SystemNone から Apple Generic に変更して有効にします。

RSSReader_xcodeproj.jpg

バージョン番号の設定

$ agvtool new-marketing-version 2.0.0
Setting CFBundleShortVersionString of project RSSReader to:
    2.0.0.

Updating CFBundleShortVersionString in Info.plist(s)...

Updated CFBundleShortVersionString in "RSSReader.xcodeproj/../RSSReader/Info.plist" to 2.0.0
Updated CFBundleShortVersionString in "RSSReader.xcodeproj/../RSSReaderTests/Info.plist" to 2.0.0

バージョン番号の確認

$ agvtool mvers -terse
"RSSReader.xcodeproj/../RSSReader/Info.plist"=2.0.0
"RSSReader.xcodeproj/../RSSReaderTests/Info.plist"=2.0.0

ビルド番号のインクリメント

$ agvtool next-version -all
Setting version of project RSSReader to:
    2.

Also setting CFBundleVersion key (assuming it exists)

Updating CFBundleVersion in Info.plist(s)...

Updated CFBundleVersion in "RSSReader.xcodeproj/../RSSReader/Info.plist" to 2
Updated CFBundleVersion in "RSSReader.xcodeproj/../RSSReaderTests/Info.plist" to 2

Xcodeで確認

設定とインクリメントができました。

RSSReader_xcodeproj.jpg

KeyChain にある証明書を表示する

security find-identity -p codesigning -v
  1) 1234567890XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "iPhone Developer: Sugigami Youhei (ZZZZZZZZZZ)"
  2) 1234567890XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "iPhone Distribution: HOGE, INC. (YYYYYYYYYYY)"
  3) 1234567890XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "iPhone Developer: Sugigami Youhei (WWWWWWWWWWW)"
  4) 1234567890XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "iPhone Distribution: Sugigami Youhei (QQQQQQQQQQ)"
     4 valid identities found

プロジェクトのTargets, Configurations, Schemes一覧を表示する

$ xcodebuild -list
Information about project "RSSReader":
    Targets:
        RSSReader
        RSSReaderTests

    Build Configurations:
        Debug
        Release

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

    Schemes:
        RSSReader

SDK一覧を表示する

$ xcodebuild -showsdks
OS X SDKs:
    OS X 10.9                       -sdk macosx10.9
    OS X 10.10                      -sdk macosx10.10

iOS SDKs:
    iOS 8.1                         -sdk iphoneos8.1

iOS Simulator SDKs:
    Simulator - iOS 8.1             -sdk iphonesimulator8.1

xctool

A replacement for Apple's xcodebuild that makes it easier to build and test iOS or OSX apps.

Facebookが開発しているxcodebuildの代わりにビルドやテストを簡単に使いやすくツールです。

インストール

$ brew update
$ brew install xctool
$ xctool -v
0.2.2

ビルド

xctool build -workspace Hoge.xcworkspace -scheme FugaScheme -Debug 'Debug'

テスト

xctool run-tests -workspace Hoge.xcworkspace -scheme FugaScheme

REF

Swift

Swiftのシェルスクリプトファイルを実行する

$ vi ./main.swift
#!/usr/bin/env swift

let hello = "Hello World!"
println(hello)

$ chmod 755 ./main.swift
$ ./main.swift
Hello World!

SwiftのREPL(対話コンソール)を起動する

$ swift
Welcome to Swift!  Type :help for assistance.
  1> let hello = "Hello World!"
hello: String = "Hello World!"
  2> println(hello)
Hello World!
  3>

iosi

86
81
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
86
81