When the issue happens I see CoreSimulatorBridge pasted from CoreSimulatorBridge popup instead of my usual popup MyApp pasted from MyAppUITests-Runner. Any comments why it could happen?
code example:
UIPasteboard.general.string = "build 2882"
let app = XCUIApplication()
let textField = app.textFields["my text field"]
textField.tap()
let menuQuery = app.menuItems
let menuItem = menuQuery["Paste"]
menuItem.waitForExistence(timeout: 5)
menuItem.tap()
The rare result:
Related
I'm creating an app similar to THIS one
I'm working on adding siri shortcuts into my app to get quotes by categories just like this app.
So far I've succeeded in creating NSUserActivity and donating shortcuts. My shortcuts are showing up in spotlight and they work just as expected ( In the overlay window for a shortcut without opening the app)
However, when I show the INUIAddVoiceShortcutViewController and use that to add that shortcut to the shortcuts app, it stops working in the overlay and opens my app instead
The app I'm trying to copy the feature from also has an option to edit their shortcut action which I can't get in my app.
Here is an example of how the app I'm trying to copy shows the sheet, notice the arrow in the 'Do' section
It looks like this when opened
But my app doesn't work like that even though I've set up the intentDefinition file
My app looks like this. I can't for the love of god get it to be editable.
I've read the documentation, read through every tutorial on the web, gone through google's first page completely and still can't find a relevant updated code sample.
This is my IntentDefinition File
I'm donating all available shortcuts as soon as my app opens into the dashboard (I did that to test if I need to donate shortcuts before adding them to siri)
This is my code to generate a new user activity
public let kNewArticleActivityType = "\(bundleID).GetQuotes"
class Shortcuts {
public static func newUserActivity(category: Categories, thumbnail: UIImage? = UIImage(named: "icon")) -> NSUserActivity {
let categoryString = category.getStringValue().capitalized
let invocationPhrase = "\(categoryString) quote"
let attributes = CSSearchableItemAttributeSet(itemContentType: kUTTypeItem as String)
attributes.contentDescription = "Get quote from the \(categoryString) category"
attributes.thumbnailData = thumbnail?.jpegData(compressionQuality: 1.0)
attributes.keywords = ["quote", "motivation", "positive", "vibrations"]
let activity = NSUserActivity(activityType: kNewArticleActivityType)
activity.persistentIdentifier = NSUserActivityPersistentIdentifier(kNewArticleActivityType)
activity.isEligibleForSearch = true
activity.isEligibleForPrediction = true
activity.suggestedInvocationPhrase = invocationPhrase
activity.title = "Get a quote"
activity.userInfo = ["category": categoryString]
activity.contentAttributeSet = attributes
return activity
}
static func donateInteraction(with category: Categories) {
let categoryString = category.getStringValue().capitalized
let phrase = "\(categoryString) quote"
let intent = GetQuotesIntent()
intent.suggestedInvocationPhrase = phrase
intent.category = category
let interaction = INInteraction(intent: intent, response: nil)
interaction.donate { (error) in
if let error = error {
print("Interaction donation failed because \(error.localizedDescription)")
} else {
print("Successfully donated interaction")
}
}
}
}
As soon as a category name is clicked, I add it to siri using this code
func addToSiriClicked(category: String) {
let categoryEnum = Categories.getEnum(from: category)
let activity = Shortcuts.newUserActivity(category: categoryEnum)
self.userActivity = activity
let shortcut = INShortcut(userActivity: activity)
let viewController = INUIAddVoiceShortcutViewController(shortcut: shortcut)
viewController.modalPresentationStyle = .formSheet
viewController.delegate = self
self.present(viewController, animated: true, completion: nil)
}
If anyone can find any relevant tutorial for ios 14 or for siri shortcuts that isn't 2 years old, please send me a link. My donations work as expected from the spotlight, but they are generated as another interaction when I add them to siri and they stop working and open the app from that shortcut.
To get the edit function, you have to initialize the INUIAddVoiceShortcutViewController class with your custom intent
It has 2 initializers, 1 for the user activity and another one for a custom intent. Using the intent initializer solved this issue for me.
let shortcut = INShortcut(intent: Shortcuts.newIntent(category: categoryEnum))
if let shortcut = shortcut {
INVoiceShortcutCenter.shared.setShortcutSuggestions([shortcut])
let viewController = INUIAddVoiceShortcutViewController(shortcut: shortcut)
viewController.modalPresentationStyle = .formSheet
viewController.delegate = self
self.present(viewController, animated: true, completion: nil)
}
I am not sure what I am doing wrong. But in this method
INVoiceShortcutCenter.shared.getAllVoiceShortcuts { (vShortCuts, error) in
print(vShortCuts)
}
vShortCuts is an empty array.
var suggestions = [INShortcut]()
let userActivity = NSUserActivity.init(activityType: "com.riyaz.testactivity")
userActivity.title = "test activity"
let shortCut = INShortcut.init(userActivity: userActivity)
suggestions.append(shortCut)
INVoiceShortcutCenter.shared.setShortcutSuggestions(suggestions)
I donated a suggestion
Opened "Shortcuts app".
Navigated to Gallery and Added the suggestion to Siri with a text.
However,
The same text does not trigger the appdelegate's willContinueUserActivity
And also INVoiceShortcutCenter.shared.getAllVoiceShortcuts returns an empty array.
Any help appriciated.
I've got a UITest that succeeds in iOS 10 (10.3):
let app = XCUIApplication()
let pageTitle = app.navigationBars["Module.ContainerView"].staticTexts["page title"]
XCTAssert(pageTitle.exists)
This however fails in iOS 11 (11.1). The app.navigationBars["Module.ContainerView"] exists, the staticTexts of that is an empty array.
Any ideas how to test for a title in the navigation bar in iOS 11?
You can find the exact type of title by using the recording feature.
As a solution you can try with the below code. Hope it will work.
let app = XCUIApplication()
let pageTitle =
app.navigationBars["Module.ContainerView"].otherElements["page title"]
XCTAssert(pageTitle.exists)
let app = XCUIApplication()
let navTitleIdentifier = "Community"
let navigationTitleElement = app.navigationBars.matching(identifier: navTitleIdentifier).firstMatch
XCTAssert(navigationTitleElement.exists)
I am having a bit of trouble with a part of the Eureka framework for Swift in iOS. It works fine, except for when I try to clear out a form programatically which is already on the screen all the fields seem to clear out fine, except for the DecimalRow type field.
(form.rowBy(tag: "name") as? TextRow)?.value = ""
**(form.rowBy(tag: "amount") as? DecimalRow)?.value = Double(0.0)**
(form.rowBy(tag: "date") as? DateRow)?.value = Date()
(form.rowBy(tag: "reimb") as? SwitchRow)?.value = false
The DecimalRow type field stays whatever value was in it and does not respond to the line above in bold (asterisk-ed).
Any insight appreciated. Many thanks.
Have you reloaded the row?
This worked fine on my code.
(self.form.rowBy(tag: "user_weight") as? DecimalRow)?.value = Double(0.0)
(self.form.rowBy(tag: "user_weight")?.reload()
Where
<<< DecimalRow("user_weight")
And if I run
self.form.values() I get:
"user_weight": Optional(0.0)
So its cleared
You can also clear the form in this way
self.form.setValues(["user_weight": 0])
An example made by them
form.setValues(["IntRowTag": 8, "TextRowTag": "Hello world!", "PushRowTag": Company(name:"Xmartlabs")])
https://github.com/xmartlabs/Eureka#how-to-set-the-form-values-using-a-dictionary
I'm getting this error in latest version of xcode using swift 2
on line
let s = linkTxt.text
Text in linkTxt appears by button "pasteFromClipBoard"
let s = linkTxt.text
let u = NSURL(string: s!)
let file = u?.lastPathComponent
What is the reason of it and how to fix it?
Update:
the problem appears in function saveData() which calls when file downloading is finished. It calls from NSURLSessionDataTask function. More interesting, that in start-downloading-button there are the same lines where filename is generating and there is no such error on it. I fixed these issues by declaring variables, writing text's values into them and use these variables in saveData() except textObject.text; I had to delete lines with NSUserDefaults from saveData() too because I got the same error. Did understand nothing >_<
Update 2:
It's really a bug. I've deleted this line and wrote again - problem fixed
linkTxt.txt is returning nil and NSURL(string: s!) will try to forcefully unwrap it.
let s = linkTxt.text
if let s = linkTxt.txt {
let u = NSURL(string: s!)
let file = u?.lastPathComponent
}