4

私はC.I. iPhoneアプリのための環境を提供しています。継続的インテグレーションのためにXcodebuildからRETINAシミュレータを起動します

xcodebuild -scheme "Tests" -configuration Debug -sdk iphonesimulator5.0 

これは素晴らしいですが、iPhone標準シミュレータがデフォルトの標準モードではなく網膜モードで起動されるようにしたいと考えています。

私はハードウェアメニューオプションでこれを切り替えることができますが、私はヘッドレス統合サーバーでこれを実行しているので、そのオプションはありません。

私がしたいのは、何とかシミュレータが網膜モードで起動するように指示するコマンドラインにスイッチを渡すことです。

私は楽観的にxcodebuildコマンドにSimulateDevice = "iPhone(Retina)"を追加しようとしましたが、これはうまくいかないようです。

これは可能ですか?私は現時点で方法を見つけることができないようです。

可能でない場合は、私が取ることができる別の方法がありますか?

+0

が実際にシミュレータでアプリを起動し、あなたの** xcodebuild **コマンドですか?どうやってか教えて! –

+0

https://gist.github.com/1365687およびhttp://lifeandcode.net/2011/12/automated-ios-jenkins-builds-with-application-tests-and-core-data/とhttp: /longweekendmobile.com/2011/04/17/xcode4-running-application-tests-from-the-command-line-in-ios/私が従った参考文献の一部 – Roger

答えて

3

SimulateDeviceの値をcom.apple.iphonesimulator.plistに変更するには、AppleScriptを使用する必要があります。

ここにはexampleがあり、ユーザーに希望するデバイスタイプを選択するように促した後にこれを行います。コマンドラインから値を読み取ったり、"iPhone (Retina)"をデフォルト値として使用したりすることができます。

次のスクリプトは、コマンドラインからの値にシミュレータ装置を変更します。

on run argv 

set selectedDevice to item 1 of argv as string 

set thePListFolderPath to path to preferences folder from user domain as string 
set thePListPath to thePListFolderPath & "com.apple.iphonesimulator.plist" 
tell application "System Events" 
    tell property list file thePListPath 
     tell contents 
      set value of property list item "SimulateDevice" to selectedDevice 
     end tell 
    end tell 
end tell 

end run 

そして、あなたはコマンドosascriptを使用して、端末からそれを実行することができます

osascript myScript.scpt "iPhone (Retina)" 

それとも

osascript myScript.scpt "iPhone" 

は、あなたはそれがデフォルトで網膜シミュレータを起動するために、そのスクリプトを変更できます。

set selectedDevice to "iPhone (Retina)" 

set thePListFolderPath to path to preferences folder from user domain as string 
set thePListPath to thePListFolderPath & "com.apple.iphonesimulator.plist" 
tell application "System Events" 
    tell property list file thePListPath 
     tell contents 
      set value of property list item "SimulateDevice" to selectedDevice 
     end tell 
    end tell 
end tell 

は最後に"SimulateDevice"への変更は、新しいシミュレータを起動するまで有効になりませんので注意してください。

+0

ライオンのアプローチが好き...これはdoesn 'しかし、うまくいく。それはアーチ-i386 osacriptのように見える...しかし、トリックを行います。今私はスクリプトのエラーを取得しています: "end"または "end tell"が期待されていますが、未知のトークンが見つかりました。 (-2741) – Roger

+0

スペースをタブで置き換えることで修正しました。... – Roger

+0

OKこれは簡単にデフォルトの書き込みオプションを使用していますが、正しいトラックに私を設定しています。再起動のためには、この回答を受け入れることができてうれしく思います。あなたの答えを広げる時間をとってくれてありがとう。 – Roger

5

もう1つのアプローチは次のようになります。

defaults write com.apple.iphonesimulator "SimulateDevice" '"iPhone (Retina)"' 

は、しかし、SCHからのAppleScriptのアプローチと同様に、これはビルドフェーズの一部として使用する場合、非常に動作していないようです。まだ調査中...Rubyで誰のスクリプトについては

+0

どちらも実行スクリプトの一部として動作しないようですが、私は再起動シミュレータビットを試してみます...しかし、どのように私はコマンドラインからそれを行うのですか? – Roger

+0

ここから別のスクリプトを使って再起動シミュレータを解決しました。 http:// stackoverflow。com/questions/5125243/how-can-i-reset-the-ios-simulator-from-the-command-line – Roger

2

は、ここでは、シミュレータでシミュレートされたデバイスを設定するための方法である:「iPhone網膜(3.5インチ)
を使用することができます引数の

def set_simulated_device(simulated_device) 
    current_simulated_device = `defaults read com.apple.iphonesimulator "SimulateDevice"`.chomp 

    if current_simulated_device != simulated_device 
     simulator_pid = `ps -ax|awk '/[i]Phone Simulator.app\\/Contents\\/MacOS\\/iPhone Simulator/{print $1}'`.chomp 
     Process.kill('INT', simulator_pid.to_i) unless simulator_pid.empty? 
     `defaults write com.apple.iphonesimulator "SimulateDevice" '"#{simulated_device}"'` 
    end 
    end 


一覧「
"iPhone網膜(4インチ)"
"iPhone網膜(4インチ64ビット)"
"アプリ"
"アプリ網膜"
"iPadの網膜(64ビット)"

0

あなたはiPhoneシミュレータバイナリ

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhoneシミュレータからこれを行うことができます

  • "iPhone網膜(3.5インチ)"
  • 「iPhoneのRetina:他のバージョンのために.app /目次/ MacOSの/ iPhone \シミュレータ-SimulateDevice "iPhoneのRetina(4インチ)"

    (4インチ)」

  • "iPhone網膜(4インチ64ビット)"
  • "アプリ"
  • "アプリ網膜"
  • "アプリ網膜(64ビット)"
+0

これはシミュレータを正しく開きます...しかし、私たちが閉じるまで、それは –

+0

インストゥルメントを起動し、シミュレータがすでに実行されている場合は、実行中のシミュレータのバージョンを使用します –

0

語っていない任意の答え間違っている..しかし、これは、iOS 7

-- START:choose.sim.device 
on run argv 
    --set simType to item 1 of argv 
    tell application "iPhone Simulator" 
     activate 
    end tell 
    set simType to "Ipad Retina (64-bit)" 
    tell application "System Events" 
     tell process "iOS Simulator" 
      tell menu bar 1 
       -- Hardware menu bar item 
       tell menu bar item 5 
        -- Hardware menu 
        tell menu 1 
         -- Device menu item 
         tell menu item 1 
          -- Device sub menu 
          tell menu 1 
           click menu item simType 
          end tell 
         end tell 
        end tell 
       end tell 
      end tell 
     end tell 
    end tell 
    -- END:choose.sim.device 

    -- Need to show the simulator again after changing device, 
    -- or else the simulator be hidden when launched by instruments 
    -- for some odd reason. 
    tell application "System Events" 
     set visible of process "iPhone Simulator" to true 
    end tell 

    -- START:choose.sim.device 
end run 
-- END:choose.sim.device 

注意のために働いていた:そのない "iPadの" その "iPadの"

+0

私はどこかからこれを取得しました..そして私はどこを忘れていましたか –

0

Pro-tip、エイリアスを作成します。あなたは-destinationフラグでデバイスを指定することができます

ios "iPhone Retina (3.5-inch)" 
ios "iPhone Retina (4-inch)" 
ios "iPhone Retina (4-inch 64-bit)" 
ios "iPad" 
ios "iPad Retina" 
ios "iPad Retina (64-bit)" 
+4

エイリアスを作成するのはなぜプロチップですか?説明してください。 – rayryeng

0

alias ios="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateDevice” 

xcodebuild -scheme "Tests"  \ 
      -configuration Debug \ 
      -destination "platform=iOS Simulator,name=iPhone 6" 
関連する問題