在我那台运行雪豹(Snow Leopard)的旧Mac电脑上,我可以在聚光灯下输入“ios”,它就会自动启动iPhone/iPad模拟器。

从那以后,我不得不换了一台运行Lion的新机器。我已经安装了Xcode for Lion,我已经从首选项面板中安装了开发人员工具选项。

但是“ios”选项不再存在:(现在唯一的方法似乎是运行Xcode,创建一个空项目,然后用run选项启动模拟器。

我已经搜索了一遍又一遍,但没有任何帮助。

有人知道如何在Lion上只运行模拟器吗?

更新: 这是对下面@ike_love帖子的回应。 这个答案并不能保证在优胜美地的所有机器上都适用。


当前回答

假设你在/Applications中安装了Xcode,那么你可以从命令行启动iPhone模拟器:

$ open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app

(Xcode 6+):

$ open /Applications/Xcode.app/Contents/Developer/Applications/iOS Simulator.app

你可以在你的Desktop中创建一个符号链接来简化:

$ ln -s /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app ~/Desktop

(Xcode 6+):

$ ln -s /Applications/Xcode.app/Contents/Developer/Applications/iOS Simulator.app ~/Desktop

正如@JackHahoney所指出的,你也可以给你的~/.bash_profile添加一个别名:

$ alias simulator='open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/De‌​veloper/Applications/iPhone\ Simulator.app'

(Xcode 6+):

$ alias simulator='open /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app'

(Xcode 7 +):

$ alias simulator='open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app'

这意味着你可以用一个容易记住的单词从命令行启动iPhone模拟器:

$ simulator

其他回答

不需要修改命令行,最简单的方法是:

启动Xcode一次。 运行ios模拟器 拖动ios模拟器图标停靠它。

下次你想使用它时,只需点击底座上的ios模拟器图标。

看图片对你有帮助吗

Edit

现在有了新的Xcode如果Xcode的图标在dock上你可以右键点击它,形成菜单你可以选择打开开发人员工具在子菜单中你可以选择iOS模拟器来打开模拟器而不需要打开Xcode !

尝试下面的指示启动iphone模拟器:

去应用程序文件夹->Xcode应用程序->右击显示包内容->现在显示文件在Xcode内容->开发者->平台-> iphone模拟器。>应用程序>现在显示iOS模拟器应用程序点击启动iphone模拟器…!

如果你为它创建了一个Automator启动器,你可以让它通过spotlight启动:

Open Automator.app Choose type of Application Select Actions > Library > Utilities > Launch Application Open the dropdown of applications that can be launched and choose Other You can't directly select the Simulator app because it's inside the Xcode.app package. So instead you'll have to navigate to it in a separate Finder window and drag it onto the file selector window. It will be at one of the following paths depending on your version of Xcode (oldest to newest): /Applications/Xcode.app/Contents/Developer/iOS Simulator.app /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iOS Simulator.app /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app Finally, save this Automator app in your applications folder as iOS Simulator.app

要为你刚刚制作的Automator应用程序获得一个漂亮的图标,你可以做以下事情:

右键单击iOS模拟器。app,然后选择Get Info 点击左上角的图标,执行Cmd-C复制 右键单击您的Automator应用程序并选择获取信息 点击左上角的图标,点击Cmd-V进行粘贴

假设你在/Applications中安装了Xcode,那么你可以从命令行启动iPhone模拟器:

$ open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app

(Xcode 6+):

$ open /Applications/Xcode.app/Contents/Developer/Applications/iOS Simulator.app

你可以在你的Desktop中创建一个符号链接来简化:

$ ln -s /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app ~/Desktop

(Xcode 6+):

$ ln -s /Applications/Xcode.app/Contents/Developer/Applications/iOS Simulator.app ~/Desktop

正如@JackHahoney所指出的,你也可以给你的~/.bash_profile添加一个别名:

$ alias simulator='open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/De‌​veloper/Applications/iPhone\ Simulator.app'

(Xcode 6+):

$ alias simulator='open /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app'

(Xcode 7 +):

$ alias simulator='open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app'

这意味着你可以用一个容易记住的单词从命令行启动iPhone模拟器:

$ simulator