Posts

Post not yet marked as solved
1 Replies
833 Views
I'm trying to test an API I'm writing with Structured Concurrency. I prefer to run my tests with continueAfterFailure = false so that I may establish preconditions on my tests. At the moment my test is:     func testRssUrl() async throws {         self.continueAfterFailure = false         let xml = PodcastXml.url(url)         let feed = try await xml.feed         let rssFeed: RSSFeed? = feed.rssFeed         XCTAssertNil(rssFeed) // Included for this sample         XCTAssertNotNil(rssFeed)         validate(zebraFeed: rssFeed!)     } My expectation of Swift Concurrency is that the try await should hold the method, until xml.feed resolves to a value or throws. Either of the XCTAssertNil or XCTAssertNotNil should fail (in the actual test, I'm not using NotNil). As written, between the two asserts and the try, validate(zebraFeed: ) should never be called because of continueAfterFailure. Yet it is. The test still fails because XCTAssertNil is failing, which is my actual expectation. Test execution should also be stopping there. What am I missing?
Posted Last updated
.
Post not yet marked as solved
2 Replies
857 Views
I'm looking to construct a custom logger API. For example: log.verbose(Date(), "Begun process") (That's contrived example, the point being some object and a message. I will then be manipulating both.) Within my Log object I then want to transform the date value and the message into a final log message. "Nanoseconds: 9790324:: Begun process". If I was working with strings, it would be a pretty simple issue. But I'm not. It looks like Logger, which actually does the logging takes in a OSLogMessage which I cannot instantiate and cannot pass by value or reference. Even if I had just: func verbose(_ date: Date, _ message: OSLogInterpolation) { log(date: Date, level: .info, message: message) } func info(_ date: Date, _ message: OSLogInterpolation) { log(date: Date, level: .default, message: message) } private func log(date: Date, level: OSLogType, message: OSLogInterpolation) { // Neither of these work log.log(level: level, message) log.log(level: level, OSLogMessage(interpolation: message)) } Ideally what I'd like is: private func log(date: Date, level: OSLogType, message: OSLogInterpolation) { let interpolation = "Nanoseconds: \(date.getNanoseconds):: " + message log.log(level: level, OSLogMessage(interpolation: interpolation)) } With the idea being that OSLogMessage is still respecting any privacy notices on the interpolation.
Posted Last updated
.
Post not yet marked as solved
0 Replies
1.4k Views
I'm trying to configure a fully automated CI machine for my iOS builds. Fully automated is critical, no human intervention is an option. Also required is that we must be testing our product on older version of the iOS runtime. Naturally this has presented a number of challenges. The latests of which is this: Upon executing our tests for the older runtimes the simulator fails to launch. Since the installation and configuration of Xcode happens automatically xcode-select still points to the command line tools. That's not a problem for the entire rest of our run script because the script uses an export DEVELOPER_DIR declaration to set the development environment. Across multiple versions of Xcode both xcrun and xcodebuild respect the correct paths. It's only when we get to the test command: xcodebuild test -workspace Development.xcworkspace -scheme MyProduct -destination "platform=iOS Simulator,id=$DEVICE_ID" that a problem begins. The full error follows, but the relevant issue seems to be the line xcrun: error: unable to find utility \"simctl\", not a developer tool or in PATH\n indicating that xcrun cannot find simctl. Upon logging into the CI machine checks of xcrun simctl -h return indications that simctl cannot be found until I set my DEVELOPER_DIR, which is what I would expect. But the same is true for xcodebuild. So the big question becomes: How and why does xcrun lose its environmental variables when being executed by xcodebuild to launch a process during tests and how do I set it correctly? Thus far I have attempted to set the DEVELOPER_DIR in the test command as shell variable and modify the PATH to include the DEVELOPER_DIR. Additionally, I began trying to boot the simulator before testing. So far no luck. Full Error 2020-06-30 13:02:14.867 xcodebuild[78984:32139389] [MT] IDETestOperationsObserverDebug: (171C5A6F-2E6C-4918-B159-74A9666522FC) Beginning test session MyProductTests-171C5A6F-2E6C-4918-B159-74A9666522FC at 2020-06-30 13:02:14.868 with Xcode 11C29 on target <DVTiPhoneSimulator: 0x7fe483869030> { SimDevice: iPhone X (2B8B392C-A580-475B-B78F-066583C537C2, iOS 11.4, Booted) } (11.4 (15F79)) 2020-06-30 13:02:44.581 xcodebuild[78984:32139389] [MT] IDETestOperationsObserverDebug: (171C5A6F-2E6C-4918-B159-74A9666522FC) Finished requesting crash reports. Continuing with testing. 2020-06-30 13:02:44.581 xcodebuild[78984:32139389] [MT] IDETestOperationsObserverDebug: (171C5A6F-2E6C-4918-B159-74A9666522FC) Failed to make test runner session: Error Domain=com.apple.dt.xctest.error Code=14 "Error retrieving daemon unix domain socket from simulator, failed after 30 attempts.; getenv error: Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"" UserInfo={NSLocalizedDescription=Error retrieving daemon unix domain socket from simulator, failed after 30 attempts.; getenv error: Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory", DetailedDescriptionKey={ 		DiagnosticLaunchCtlPrintTestManager = "xcrun simctl spawn 2B8B392C-A580-475B-B78F-066583C537C2 launchctl print system/com.apple.testmanagerd:\nxcrun: error: unable to find utility \"simctl\", not a developer tool or in PATH\n"; 		DiagnosticTestManagerLaunchCtlSimSockEnvVar = "xcrun simctl spawn 2B8B392C-A580-475B-B78F-066583C537C2 launchctl getenv TESTMANAGERD_SIM_SOCK:\nxcrun: error: unable to find utility \"simctl\", not a developer tool or in PATH\n"; 		DiagnosticTestManagerSimSockEnvVar = "xcrun simctl getenv 2B8B392C-A580-475B-B78F-066583C537C2 TESTMANAGERD_SIM_SOCK:\nxcrun: error: unable to find utility \"simctl\", not a developer tool or in PATH\n"; }}
Posted Last updated
.
Post not yet marked as solved
1 Replies
2.6k Views
Inspecting an Info.plist for a new project, created in the Xcode 11 public release I found a new variable, PRODUCT_BUNDLE_PACKAGE_TYPE. It's being assigned to CFBundlePackageType. Searches google searches, including scoped to "site:apple.com", checks of the release notes, and developer forums don't show any documentation on what it is. It doesn't appear in the build settings. I went so far as to re-install Xcode 10.3 and confirmed that it's not present there.It's not blocking me, but I'm terribly curious.
Posted Last updated
.