Post not yet marked as solved
113
Views
We use XCUI to run our UI tests and are trying to run our tests on real devices in CI. In order to do this, we need to sign the target app and -Runner.app files so we end up with two .ipas. I am able to export a signed target app and load that onto our remote devices. Unfortunately, I have not found a way to do this with the -Runner file. Is there a way to export the -Runner file from the command line? We use manual signing so that has made things a bit more difficult.
Post not yet marked as solved
1.3k
Views
When running a unit test target in any of my iOS/macOS framework projects, I am experiencing random/inconsistent locks/hangs in xctest or xcodebuild. A number of test suites will run and pass but then on a few suites in particular, xcodebuild will stop reporting test results to the console and it appears to be stuck in an infinite loop/deadlock. I've actually seen the lock break in a few cases after 25-30 minutes but for the most part I cancel the test run before seeing if it restarts again.This is completely reproducible for me just by running xcodebuild's test-without-building in a while loop in the terminal.```while true; do xcodebuild -destination 'platform=iOS Simulator,name=iPad Air 2,OS=12.2' -derivedDataPath <PATH_TO_DERIVED_DATA> -xctestrun '<PATH_TO_XCTESTRUN>/Framework_iphonesimulator12.2-x86_64.xctestrun' -only-testing:<UNIT_TEST_TARGET_NAME> test-without-buildingdone```In the middle of a test suite running, the console will freeze partway through the suite. Sometimes, the lock comes after the first few runs of the command and other times it takes 20+ runs for the lock to occur.This is happening on Xcode 10.2 and 10.2.1 with the framework projects on Swift 5. I first started noticing this on CI when my unit test jobs would fail because they exceeded to timeout limit for a job not receiving any responses from the console. That's what led me to test xcodebuild locally on my machine.I cannot find any information online about hanging tests with the same scenario that I'm experiencing. Hoping someone on here can help me out.Something worth noting - I actually have the exact same test suites from a framework project in an app project which experience the lock on the framework, but the lock does not happen in the app project.This happens both when parallelization and randomization are enabled or disabled.
Post not yet marked as solved
406
Views
After upgrading to Xcode 12.2, the iOS 14.2 simulators are not rendering HTTP links as they've been doing in previous versions.
Our UI Tests 'test' the universal links that our app supports by copying the link in the Messages app and tapping on the link.
Unfortunately, after Xcode 12.2 release this is not possible anymore.
Is there any plan to support this feature again?
How can we test our Universal links? Is there any other alternative that doesn't imply 3rd parties?
Thanks.
Post not yet marked as solved
187
Views
I created a UI Testing Bundle, set its testing target application to None. So I need to call XCUIApplication.launch to launch the testing target manually.
Now I want to test the in-app purchase flow, I added the Configuration.storekit in the UI testing bundle, created a SKTestSession after launching the target App, but the target App didn't get the testing storekit environment.
Is there a way to use the .storekit file and SKTestSession in UI testing bundle?
Post not yet marked as solved
109
Views
I run a script from a mac, from macOS's terminal, to run a test on an iOS device connected to the mac via USB.
How can I programatically check that the device is unlocked? Also, how can I wake the iOS device from the mac?
The command "xcrun xctrace list devices" is very close to what I want, as it gives me the list of connected devices. However it does not tell me if the device is unlocked or not.
Thanks in advance.
Post not yet marked as solved
950
Views
Hi, i'm trying to test my pod that has been working fine until I upgraded to Xcode 12. Now when I try to test a function in my Test projet, I get this message:
Cannot test target “TestProject” on “iPhone 11 Pro”: TestProject does not support any of iPhone 11 Pro’s architectures: x86_64.
I have a FAT library that contains arm64 & x86_64 architectures.
In my test target Architecture Build Settings I have "$(ARCHS_STANDARD)" variable.
Post marked as solved
301
Views
How do I do unit test with multiplatform app?
I created a new project and add a class with one object.
class MyClass {
static var apples: [Int] = [1,2,3]
}
When I want to do unit test, it fails ...
import XCTest
@testable import MyApp
class Tests_macOS: XCTestCase {
		func testExample() throws {
				XCTAssertEqual(MyClass.apples.count, 3)
		}
}
Errors
Undefined symbols for architecture x86_64:
"MyApp.MyClass.apples.unsafeMutableAddressor : [Swift.String]", referenced from:
implicit closure #1 () throws -> Swift.Int in Tests_macOS.Tests_macOS.testExample() throws -> () in Tests_macOS.o
"type metadata accessor for MyApp.MyClass", referenced from:
implicit closure #1 () throws -> Swift.Int in Tests_macOS.Tests_macOS.testExample() throws -> () in Tests_macOS.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Undefined symbol: MyApp.MyClass.apples.unsafeMutableAddressor : [Swift.String]
Undefined symbol: type metadata accessor for MyApp.MyClass
Post not yet marked as solved
2.1k
Views
When running unit tests for a second+ time, we often run into:"Failed to create temporary staging dir in <PATH_TO_SIMULATOR>/data/Library/Caches/com.apple.mobile.installd.staging"If we delete derived data, it always works the first run, but then fails on subsequent runs.Something in Xcode is deleting the directory it needs. Has anyone else seen this and found a solution?
Post not yet marked as solved
229
Views
which Xcode version will be suitable for macOS big sur 11.2.3 ?
Post not yet marked as solved
209
Views
I've run into a bit of a quandary, about why this fails to work, and I need to ask to find out if there is a reason for what I'm seeing. I can reproduce 100% of the time.
What I am trying to do: Use Swift Package Manager to generate a command line application target.
Add a Swift class/struct/function to the project
Add a UnitTest for validation
Use SPM to create a new command line project:
mkdir CommandLineTool
cd CommandLineTool
swift package init --type executable
2. Add a New File to CommandLineApp, let's call it Foo.swift:
import Foundation
public struct Foo {
public func message() - String {
return "Hello, World"
}
}
Build, and everything works!
3. Add a new UnitTest swift class FooTests.swift:
import XCTest
@testable import CommandLineTool
final class FooTests: XCTestCase {
func testFooMessage() {
let message = Foo().message()
XCTAssertTrue(message == "Hello, world!")
}
}
Build Error:
Undefined symbol: CommandLineTool.Foo.message() - Swift.String
Undefined symbol: CommandLineTool.Foo.init() - CommandLineTool.Foo
Questions: Why does this fail?
Why can I not add a UnitTest for items added to a command line SPM project?
Other Observations: The same process also fails, if I use Xcode 12.4 to generate a Command Line Tool project for macOS.
Doing the exact same process is successful if I use one of the following: Use SPM to generate a library, and I add a new Unit Test. Use Xcode 12.4 to generate a macOS UI based App or iOS app project, then add in a UnitTest for a new swift file I add to the main application.
Why can we not add unit tests to a Command Line Tool project, or a SPM based command line app?
Thank you for any help with this.
Post not yet marked as solved
155
Views
I am attempting to setup XCUI Automation for WatchOS application but it fails to launch the watch application.
Below are a couple of things i have tried out.
Created a UITesting bundle/target & attempted to add Target application as WatchOS target [but it doesn't allow selecting], so had to leave it as None.
2. Tried to pass the watchOS bundleIdentifier using
let app = XCUIApplication.init(bundleIdentifier: "com.mybundleid.mywatchapplication")
app.launch()
But i get the below error
Failed to launch com.mybundleid.mywatchapplication: The operation couldn’t be completed. Application info provider (FBSApplicationLibrary) returned nil for "com.mybundleid.mywatchapplication"
Post not yet marked as solved
150
Views
I need to pass the number of iterations to the measureBlock method i.e. I would like to write in Objective-C the following Swift code:
Code Block swift
let options = XCTMeasureOptions()
options.iterationCount = 5;
measure(options: options) {
/* The code that's being measured */
}
I wrote:
Code Block Objective-C
XCTMeasureOptions *opt = [XCTMeasureOptions new];
opt.iterationCount = 5;
[self measureBlock:^{
/* The code that's being measured */
}];
What syntax should I use to pass the opt object to measureBlock?
Thanks
Stefano Gragnani
Post not yet marked as solved
2.8k
Views
We're running into an odd issue only when running our test suite on CI (Jenkins) with Xcode 12: xctest reports
xctest encountered an error (Failed to install or launch the test runner. If you believe this error represents a bug, please attach the result bundle at /Volumes/ebs_jenkins/workspace/xcode12-sandbox/derivedData/Logs/Test/Test-Xcode12Sandbox-2020.10.08_02-50-12-+0000.xcresult. (Underlying Error: Invalid device state))
Interestingly, this issue ONLY presents itself when initiated via SSH, when using Screen Sharing (VNC) and running the test suite via Xcode UI, tests pass as expected.
The tests also pass fine on the same CI machine with Xcode 11.5.
You can find a sample project that exhibits the problem here: https://github.com/opfeffer/xcode12-sandbox
Post not yet marked as solved
170
Views
I'm using a testBundle to execute all my unit tests.
The problem is that for some reason, there are some XCTestCase which are not run if I want to run all tests.
These exact XCTestCases were running just fine previously by running all tests.
If I start all tests in such an XCTestCase they are run fine and execute successfully, but not when I want to run all tests in the testBundle.
This happens in one of the other projects I work on as well.
What could be the reason for that?
Test configuration: All tests are enabled in the testBundle.
New tests are automatically included
Exact same XCTestCases are not run from Xcode UI and command line as well
The not running test cases are enabled
Post not yet marked as solved
352
Views
I've noticed that XCTMemoryMetric & XCTCPUMetric seem to record empty or nonsensical data when running a UI test flow for an XCUIApplication.
I'm attempting to test the memory and CPU footprint for a SwiftUI iOS app using the following code:
Swift
func testBasicFlowMemory() throws{
let app = XCUIApplication()
app.launch()
var metrics:[XCTMetric] = []
metrics.append( XCTClockMetric() )
metrics.append( XCTMemoryMetric(application: app) )
metrics.append( XCTCPUMetric(application: app) )
self.measure(metrics: metrics){
/*Method which uses XCUI API to test the app instance*/
self.runBasicFlowTest(app: app)
}
}
When I run the test above, I notice runBasicFlowTest is executed 6 times (even though the metics only record 5 values.
Of the three metrics I wanted to track only XCTClockMetric returned meaningful data:
[Clock Monotonic Time, s] values: [114.728229, 114.944770, 121.813337, 116.394432, 117.491242]
XCTMemoryMetric mostly recorded 0.0 or nonsense data:
[Memory Physical, kB] values: [3596.288000, 0.000000, 0.000000, 0.000000, 0.000000]
[Memory Peak Physical, kB] values: [0.000000, 0.000000, 0.000000, 0.000000, 0.000000]
XCTCPUMetric likewise recorded 0.0 or nonsense data:
[CPU Instructions Retired, kI] values: [0.000000, 206223944.266000, 0.000000, 0.000000, 211895544.471000]
[CPU Cycles, kC] values: [0.000000, 252096240.472000, 0.000000, 0.000000, 257352232.305000],
[CPU Time, s] values: [0.000000, 86.585296, 0.000000, 0.000000, 0.000000]
I'm on Xcode Version 12.4 (12D4e), and my app is targeting iOS 14.4 on a simulated iPhone 11 Pro.
Has anyone had any luck using XCTMetrics with UI Tests?