iOS Main.string国际化不起作用

微笑希望以后遇到的朋友少走弯路。


通过Main.string配置国际化文件,切换到其他语言时有时国际化不起作用,main.string(有问题)文件在编译时好像是不会报错的。在运行时才回打印一些log。如下:


CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 90. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.

2016-06-01 10:04:02.678 Glass[2800:2442022] Unable to load .strings file: CFBundle 0x12d5a9720 </var/containers/Bundle/Application/FB133B22-02AB-4B18-8770-4AA0D40D307C/Glass.app> (executable, loaded) / Main: Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected character / at line 2" UserInfo={NSDebugDescription=Unexpected character / at line 2, kCFPropertyListOldStyleParsingError=Error Domain=NSCocoaErrorDomain Code=3840 "Missing ';' on line 90" UserInfo={NSDebugDescription=Missing ';' on line 90}}




这是因为Main.string 是有问题,所以不能正常显示其他国际语言。

上述问题是在这里

"7eb-9u-XCD.text" = "Hotspot connection settings"

在末尾缺少 ; 符号,添加上就不再有问题了。

"7eb-9u-XCD.text" = "Hotspot connection settings";

您的问题不太清晰,我猜测您想问的是如何使用 Python 进行 iOS 自动化测试时的 OCR 文字识别和坐标定位。 OCR 文字识别可以使用 Python 的第三方库 pytesseract 来实现,它是一个基于 Google 的开源 OCR 引擎 Tesseract 的 Python 封装。您可以通过以下命令安装: ``` pip install pytesseract ``` 在使用 pytesseract 进行 OCR 识别时,您需要先对需要识别的区域进行截图,然后使用 pytesseract.image_to_string() 方法来获取识别结果。例如: ```python import pytesseract from PIL import Image # 截图 im = Image.open('screenshot.png') region = im.crop((x1, y1, x2, y2)) # OCR 识别 text = pytesseract.image_to_string(region, lang='eng') print(text) ``` 坐标定位可以通过 iOS 自动化测试框架 XCTest 来实现。您可以使用 XCTest 提供的 XCUIElementQuery 来查找您需要的 UI 元素,然后使用 XCUIElement 的坐标信息来进行操作。例如: ```python import time import unittest from appium import webdriver class iOSAutomationTest(unittest.TestCase): def setUp(self): desired_caps = { "platformName": "iOS", "platformVersion": "14.5", "deviceName": "iPhone 12", "app": "/path/to/your/app", "automationName": "XCUITest", "udid": "your-device-udid" } self.driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps) def tearDown(self): self.driver.quit() def test_example(self): # 查找 UI 元素 button = self.driver.find_element_by_xpath("//XCUIElementTypeButton[@name='Example']") # 获取坐标信息 x = button.location['x'] y = button.location['y'] # 点击 self.driver.tap([(x, y)]) # 等待 time.sleep(2) if __name__ == '__main__': unittest.main() ``` 需要注意的是,iOS 自动化测试需要使用 Appium 作为驱动,并且需要在您的 iOS 设备上安装 Appium 的 WebDriverAgent 服务。同时,您需要在 Appium 中设置正确的 capabilities 和启动参数,才能进行 iOS 自动化测试。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值