Swift UITesting error: Invalid escape sequence in literal. \U201c - xcode

I am building an automation suite using Xcode 7 with swift.
My app loads with the following Alert View:
Allow "Light Alarm" to access your location while you use the app?
When I record with UI Testing and click this alert I get the following code:
app.alerts["Allow \U201cLight Alarm\U201c to access your location while you use the app?"]
Note: The quotes has been replaced with \U201c
However, when I try and compile I get the following error:
"Invalid escape sequence in literal"
Anyone know how to get round this?

This seems to be a bug in Xcode when generating code during UI recording.
Swift uses \u{NNNN} escape sequences in string literals, so
app.alerts["Allow \u{201c}Light Alarm\u{201c} ..."]
would be correct, or simply
app.alerts["Allow “Light Alarm“ ..."]
(Actually it should be "Allow “Light Alarm” ..." where the
second quotation mark is U+201D = RIGHT DOUBLE QUOTATION MARK :)
A similar issue for UI recorded code in Objective-C was reported in
Incomplete universal character name in UI Testing.
I do not know a workaround, it seems that the only thing you can do
at present is to fix the code after recording (and sent a bug report
to Apple).

Installing Xcode 7.3 fixed this issue for me

Related

VS Code debugger: failure to find module (utf-8 characters)

When I try to run a Node.js debugging session from Visual Code, the debugging console returns an error, saying that the bootloader.bundle.js could not be found. However, the bootloader.bundle.js file exists at the expected location, while the debug console specifies the folder incorrectly by substituting a UTF-8 character (letter č) with the replacement character (�). The snippet of the error message can be found below:
Error: Cannot find module 'c:/Users/xxxx xxxx�/AppData/Local/Programs/
Microsoft VS Code/resources/app/extensions/ms-vscode.js-debug/src/bootloader.bundle.js'
Can I somehow fix this in VS Code, perhaps by modifying the launch.json file in some way or some other settings?
Any help is appreciated!
EDIT:
I temporarily fixed the issue by reinstalling VS Code to another folder without that doesn't include diacritical characters. I'd like to to keep this question open, however, in case somebody knows of a way to fix this sort of problem (e.g. by by modifying some configuration files) that does not require either reinstalling or relying on a portable version of the app.
I have just dealt with the same issue. There have been Unicode characters in my folder's path and I got the same error "Cannot find module". Reasons are described in details here.
To fix it I have gone to File - Preferences - Settings and then entered "usePreview" and then I unchecked the option "Use the new in-preview JavaScript debugger for ..." under the section "Debug > JavaScript: Use Preview" and reloaded VS Code. The issue has gone.

Build error in android studio 3.1.3

I am getting the following error in android studio 3.1.3 when i try to rebuild my firebase login app.please help
support-compat-27.1.1.aar\76a2bb1ead9b3a164321ee3d23767645\res\values
\values.xml:50:4: Error: The content of elements must consist of well-formed
character data or markup.
You need to check the file values.xml inside the values folder. I'm sure there is a character like an exclamation mark ! or a double quote put in between other double quotes "
Provide more info on what is inside the values.xml file to get more accurate answer.

Xamarin Test Cloud - Upload error, Unexpected character encountered while parsing value

I have noticed in a few threads on the Xamarin Forums (here, here) that people were having troubles uploading an app to Xamarin Test Cloud. Those posts were old but none of the solutions worked.
Error I get is
Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
I created a new project with the same bundle ID and the same Info.plist and I am able to upload to XTC with that. But clearly isn't the app I want to test (though I did try out text input and screenshots, this system is awesome).
There is nothing else on my end that I can think of causing the problems. I did notice my .ipa file was about 230mb but had not seen anything about a max filesize for XTC.
I tried to use the --debug option to get more info when I ran the same command to upload from terminal but it did not help. Any suggestions what to do or why XTC servers may be erroring on my files?
Sorted it out. Issue was I had linker behavior set to "Don't link", changing it to "Link Framework SDKs Only".
Hope this helps someone else if they have this issue.

UI XCTest recording with unicode characters in XCode 7 gives wrong Swift code

Right now when recording an element on my app, it returns something along the lines of:
XCUIApplication().alerts["\U201cMy Application\U201d Would Like to Send You Notifications"].staticTexts["Notifications may include alerts, sounds, and icon badges. These can be configured in Settings."].tap()
Which throws a compiler error. I then changed it to this, to follow the swift convention on references unicode characters:
XCUIApplication().alerts["\u{201c}My Application\u{201d} Would Like to Send You Notifications"].staticTexts["Notifications may include alerts, sounds, and icon badges. These can be configured in Settings."].tap()
This does compile, but the test fails because Swift does not find the element when testing. I then tried this:
XCUIApplication().alerts["“My Application” Would Like to Send You Notifications"].staticTexts["Notifications may include alerts, sounds, and icon badges. These can be configured in Settings."].tap()
Which has the same result.
I realize that this is likely a bug with xcode, but is there a workaround? The issue seems to have been around for awhile.
I can't reproduce your error. Using the swift convention \u{201c}works great. U can also try using just a backslash if you want to use quotation marks
"\"MyApp\" Would Like to Send You Notifications"
You message indicates that you want to react to a system notification rather than your own UIAlert. Thats why you can't find it. Try setting up an UI Interuption Alert before the Alert appears and then react to it:
addUIInterruptionMonitorWithDescription("\"MyApp\" Would Like to Send You Notifications") {
(alert) -> Bool in
alert.buttons["OK"].tap()
return true
}
Also consider Joe Masilotti's excellent Cheat Sheet for further information.
Workaround for Xcode 7.1 bug in UI XCTest recording unicode titles (Swift)
Record all actions you want as usual.
Copy generated code
Open this online unicode converter tool
Paste your code in "Unicode characters*" text area
Select conversion direction: Unicode characters to unicode escape sequences
Click Convert button
Copy converted code from "Unicode escape sequences" text area in your program
That all. I hope Apple will fix this bug soon.
I faced the same problem and I fixed it with this code below:
let notificationAlertElement = XCUIApplication().alerts["\u{201c}My Application\u{201d} Would Like to Send You Notifications"].staticTexts["Notifications may include alerts, sounds, and icon badges. These can be configured in Settings."].collectionViews.buttons["OK"]
if (notificationAlertElement.exists) {
notificationAlertElement.tap()
}
I can't get "addUIInterruptionMonitorWithDescription" working. So, the solution I use is to not register for notification if in simulator.
//Because simulator does not have to have notifications, ust disable it.
#if !arch(i386) && !arch(x86_64)
//Ask the user to accept notifications from the application
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Alert, categories: nil))
#endif

Swift code completion isn't working

I installed Xcode 6.0 beta and downloaded the iOS8 library Documentation.
but when i create a Swift project, try to typing code
func aa(){
let format = NSDateFormatter()
var pageData = format.
}
I find Xcode can't dot any property and function. Am I missing any step?
The problem is sloved, typing a whitespace can aid code completion
It's append when you change the hardware type and you choose less than iphone5.
Choose Iphone 6 for example in the list at the right of the stop button and the code completion for 'format' will appear.
I met the same problem and solve it by removing the non-ASCII char in comment (in my problem, it's a chinese char "年" automatically generated in comment by xcode).
btw. "typing a whitespace can aid code completion" doesn't work for me
It’s a bug, your code works on my system (OS X 10.9). Note that when typing code, I sometimes see the code completion crash for two seconds and come back.
When trying a first project named "swift", code completion crashed in a infinite loop… beta bugs… I just had to name it something else to test the language.
You know, I've experienced something similar with Objective C projects in Xcode 6 Beta 1. It seems Apple have changed the default behaviour a bit:
In Xcode 5.x code would always automatically complete as you type, but in this early beta try pressing ESCAPE - that will bring up the list you're looking for. Works for me. Some code auto completes as you type (both in Swift and Objective C), but at times only ESCAPE will bring up what we're looking for.
I'm nor sure if this is expected behaviour or a bug (I'm guessing the latter).
I must admit that your code works fine on my system without this trick. Just make sure you have code completion setup under Xcode - Preferences - Text Editing:

Resources