Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Xcode模拟器中更改时间和日期_Xcode_Time_Ios Simulator - Fatal编程技术网

在Xcode模拟器中更改时间和日期

在Xcode模拟器中更改时间和日期,xcode,time,ios-simulator,Xcode,Time,Ios Simulator,如何在iPhone模拟器中更改时间?我想让手机上的其他应用程序看到与当前应用程序不同的时间 更改主机Mac上的系统时间。模拟器运行一个单独的用户空间,但共享内核,因此它没有与主机不同时间的概念。旧问题,现代答案: ,这允许您通过覆盖状态栏值对模拟器的外观进行更多的控制 找到正确的设备 命令xcrun simctl list: 抓取适当的设备UDID并将其传递到以下命令中,以更改模拟器的当前时间: % xcrun simctl status_bar F36583E8-6833-4526-8622-

如何在iPhone模拟器中更改时间?我想让手机上的其他应用程序看到与当前应用程序不同的时间

更改主机Mac上的系统时间。模拟器运行一个单独的用户空间,但共享内核,因此它没有与主机不同时间的概念。

旧问题,现代答案:

,这允许您通过覆盖状态栏值对模拟器的外观进行更多的控制

找到正确的设备
命令
xcrun simctl list

抓取适当的设备UDID并将其传递到以下命令中,以更改模拟器的当前时间:

% xcrun simctl status_bar F36583E8-6833-4526-8622-CE24022BE876 override --time "9:41"
%
运行
xrun simctl help status\u bar
将显示一系列选项:

$ xcrun simctl help status_bar
Set or clear status bar overrides
Usage: simctl status_bar <device> [list | clear | override <override arguments>]

Supported Operations:
    list
    List existing overrides.

    clear
    Clear all existing status bar overrides.

    override <override arguments>
    Set status bar override values, according to these flags.
    You may specify any combination of these flags (at least one is required):

    --time <string>
         Set the date or time to a fixed value.
         If the string is a valid ISO date string it will also set the date on relevant devices.
    --dataNetwork <dataNetworkType>
         If specified must be one of 'wifi', '3g', '4g', 'lte', 'lte-a', or 'lte+'.
    --wifiMode <mode>
         If specified must be one of 'searching', 'failed', or 'active'.
    --wifiBars <int>
         If specified must be 0-3.
    --cellularMode <mode>
         If specified must be one of 'notSupported', 'searching', 'failed', or 'active'.
    --cellularBars <int>
         If specified must be 0-4.
    --operatorName <string>
         Set the cellular operator/carrier name. Use '' for the empty string.
    --batteryState <state>
         If specified must be one of 'charging', 'charged', or 'discharging'.
    --batteryLevel <int>
         If specified must be 0-100.
$xcrun simctl帮助状态\u栏
设置或清除状态栏替代
用法:simctl状态栏[列表|清除|覆盖]
支持的操作:
列表
列出现有覆盖。
清楚的
清除所有现有状态栏替代。
推翻
根据这些标志设置状态栏覆盖值。
您可以指定这些标志的任意组合(至少需要一个):
--时间
将日期或时间设置为固定值。
如果字符串是有效的ISO日期字符串,它还将在相关设备上设置日期。
--数据网络
如果指定,则必须是“wifi”、“3g”、“4g”、“lte”、“lte-a”或“lte+”中的一个。
--wifiMode
如果指定,则必须是“搜索”、“失败”或“活动”之一。
--维菲巴
如果指定,则必须为0-3。
--纤维铠装
如果指定,则必须是“不受支持”、“搜索”、“失败”或“活动”之一。
--纤维素棒
如果指定,则必须为0-4。
--运算符名
设置蜂窝网络运营商/运营商名称。将“”用于空字符串。
--电池酸盐
如果指定,则必须是“充电”、“充电”或“放电”之一。
--电池级
如果指定,则必须为0-100。

可能的重复项您可以指定设备名称,而不是干扰UUID,例如
xcrun simctl status\u bar“iPhone 11 Pro Max”override--time“7:11”
对我来说,这只改变了状态栏中显示的时间,不会改变模拟器上的系统时间。是的,我很感激你的努力,但是这个答案太浪费时间了。它不会改变模拟系统的时间。。。只是状态栏
% xcrun simctl status_bar F36583E8-6833-4526-8622-CE24022BE876 override --time "9:41"
%
$ xcrun simctl help status_bar
Set or clear status bar overrides
Usage: simctl status_bar <device> [list | clear | override <override arguments>]

Supported Operations:
    list
    List existing overrides.

    clear
    Clear all existing status bar overrides.

    override <override arguments>
    Set status bar override values, according to these flags.
    You may specify any combination of these flags (at least one is required):

    --time <string>
         Set the date or time to a fixed value.
         If the string is a valid ISO date string it will also set the date on relevant devices.
    --dataNetwork <dataNetworkType>
         If specified must be one of 'wifi', '3g', '4g', 'lte', 'lte-a', or 'lte+'.
    --wifiMode <mode>
         If specified must be one of 'searching', 'failed', or 'active'.
    --wifiBars <int>
         If specified must be 0-3.
    --cellularMode <mode>
         If specified must be one of 'notSupported', 'searching', 'failed', or 'active'.
    --cellularBars <int>
         If specified must be 0-4.
    --operatorName <string>
         Set the cellular operator/carrier name. Use '' for the empty string.
    --batteryState <state>
         If specified must be one of 'charging', 'charged', or 'discharging'.
    --batteryLevel <int>
         If specified must be 0-100.