How can I download apps to iOS Simulator?
with the recent updates appstore is not available in simulator. I want to download apps such as twitter, facebook etc... to implement some UITests. How can I achieve that?
do you know?
how many words do you know
See also questions close to this topic
-
SwiftUI, apply drawGesture only when over Image
I'm try to apply the gesture only when the user is over the Image display not when tapped outside the image.
Any suggestion how I can do? this following code draw also when user tap outside the image.
struct ContentView: View { @StateObject var am = AppManager() @State var switchToTakePicture = false @State var paths: [PathContainer] = [] @State var currentDraggingId = UUID() @State var spikoPic = #imageLiteral(resourceName: "spiko-16.jpeg") @State var centerOFimage = CGSize(width: 0, height: 0) var body: some View { GeometryReader { proxy in ZStack { Image(uiImage: spikoPic) .resizable() .scaledToFit() .position(x: proxy.size.width/2, y: proxy.size.height/2) .background(GeometryReader { Color.clear.preference(key: ViewRectKey.self, value: [$0.frame(in: .global)]) }) .gesture(drawGesture) // not correct ForEach(paths) { container in // draw and set the foreground color of the paths to red container.path .stroke(Color.red, lineWidth: 4) } } .onPreferenceChange(ViewRectKey.self) { rects in print(rects.first ?? .zero) } } } var drawGesture: some Gesture { DragGesture(minimumDistance: 0) .onChanged { value in // The point that the gesture started from let start = value.startLocation // The point that the gesture ended to let end = value.location // the properties of the rectangle to be drawn let rectangle: CGRect = .init(origin: end, size: .init(width: start.x - end.x, height: start.y - end.y)) // create a path for the rectangle let path: Path = .init { path in path.addRect(rectangle) } print("rettangolo = \(rectangle) orig \(rectangle.origin) - height \(rectangle.height) width = \(rectangle.width)") // remove the previous rectangle that was drawen in current // process of drawing paths.removeAll { $0.id == currentDraggingId } // append the new rectangle paths.append(.init(id: currentDraggingId, path: path)) } .onEnded { _ in // renew the dragging id so the app know that the next // drag gesture is drawing a completely new rectangle, // and is not continuing the drawing of the last rectangle currentDraggingId = .init() } } }
i want no box outside
-
How to navigate between NavigationLink while leave a part of main window stay the same in SwiftUI
I would like to navigate between different
NavigationLink
s inNavigationView
while some part of the main window stay the same. For example, I want to make a music app and I want to let the play controller always on top, while I can display different navigation contents (songs page, artists page...) using the rest of the window.Like what's showed in the picture below, I want to keep the red part always there while the blue part changes.
My code would be like below, but it won't work correctly. The
AlwaysStayView()
disappears when I click anyNavigationLink
on sidebar. So, how can I correct it or is there any solution (prefer in SwiftUI, but framework like UIKit would also be OK). I would appreciate it.NavigationView { List { NavigationLink { DiscoverView() } label: { Label("Discover", systemImage: "magnifyingglass") } NavigationLink { SongsView() } label: { Label("Songs", systemImage: "music.note") } NavigationLink { ArtistsView() } label: { Label("Artists", systemImage: "music.mic") } } } .listStyle(SidebarListStyle()) VStack { AlwaysStayView() SongsView() } }
-
NumberFormatter and unsigned with UInt64.max
I'm trying to create a string representing
UInt64.max
usingNumberFormatter
. Here's the code:let formatter = NumberFormatter() formatter.usesGroupingSeparator = true formatter.numberStyle = .decimal formatter.positiveFormat = "# ##0.#########" formatter.maximumSignificantDigits = 20 formatter.usesSignificantDigits = false formatter.maximumFractionDigits = 20 formatter.minimumFractionDigits = 0 formatter.alwaysShowsDecimalSeparator = false // formatter.roundingMode = .halfUp let text1 = formatter.string(for: NSNumber(value: Int64.max)) let text2 = formatter.string(for: NSNumber(value: UInt64.max)) print(text1) print(text2)
which prints:
Optional("9,223,372,036,854,780,000")
Optional("-1")but should print
Optional("9223372036854775807")
Optional("18,446,744,073,709,551,615")It looks like
NSNumber
is roundingInt64
and isn't taking theUIn64
. The obj-c version ofNSNumberFormatter
works fine.Am I missing something or is there a problem with
NumberFormatter
? -
Referencing static string in Xcode UI test with apostrophe
In my project is a localized string in a *.strings file like this...
"some_key" = "Yada yada won't blah.\nBlah blah?";
In my UI Test, when I record the element and when I print object on the staticTexts dictionary, it's referenced with a string like this...
app.staticTexts["Yada yada won't blah.\nBlah blah?"]
However, in my test I localize the key and the string comes out with an extra escape character for the apostrophe in the contraction which I believe is breaking the label reference...
print("some_key".localized) Yada yada won\'t blah.\nBlah blah?
I've tried replacing "\'" with "'" and even the below code...
let begin = id.substring(start: 0, offsetBy: 15) let end = id.substring(start: 16, offsetBy: 41) id = "\(begin ?? "")'\(end ?? "")"
...but the escape is always there.
How do I keep the break line, but remove the escape on the apostrophe?
I don't control the client code being tested, so I can't change how the text is setup and I can't reference with an accessibility identifier.
-
XCTAssertEqual failed: ("nan") is not equal to ("nan") in Swift
When I run the following test case, I get
XCTAssertEqual failed: ("nan") is not equal to ("nan")
error.XCTAssertEqual(0.0 / 0.0, Double.nan)
How can I fix this error?
-
UITest app launches in background by default
I am trying to run few functional tests in UITests folder. When I run my test it launches the app in background by default. If I try to add below line in test script, it creates new app
let myapp=XCUIApplication() myapp.activate()
it creates new app on iPhone and fails. How to open the app launched in background previously by default? Please help
-
How to write UITest cases to check if the another controller is presented on simple button click?
Since,I am new at writing UItest cases.Getting a issue while testing if the another controller is presented on button click. '''
let storyboard = UIStoryboard(name: "Login", bundle: nil) let sut = storyboard.instantiateInitialViewController() as! LoginViewController sut.loadViewIfNeeded() let app = XCUIApplication() app.launch() app.buttons["Try Now"].tap()
I am having another controller named testViewController,wants to check on click of button "tryNow",this testViewController is presented or not using UItestcases.
-
Are there architectural patterns for Swift Unit Testing?
I wondered if there were architectural patterns, like MVP, MVVM for unit tests in swift.
I know about AAA pattern, but it breaks the logic inside the test method. In all the stuff I've read, the structure of the tests was made the same as the structure of the project itself, and there was no architecture as such.
Maybe you know some architectures, patterns or approaches that would help to logically break up modular tests into different objects?