Builds fails when trying to use `Swifter` in XCUITest
I'm trying to create a long-running server in a XCUITest test.
import XCTest
import Swifter
class AccountCenterUITests: XCTestCase {
func testExample() throws {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()
let server = HttpServer()
server["/hello"] = { .ok(.htmlBody("You asked for \($0)")) }
try server.start()
XCTAssert(true)
}
}
However I'm getting crashes:
$ xcodebuild \
-project AccountCenter.xcodeproj \
-scheme AccountCenter \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 12,OS=15.5' \
test
2022-07-25 10:38:30.342 xcodebuild[5880:35295] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-07-25 10:38:30.343 xcodebuild[5880:35295] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
Resolve Package Graph
Resolved source packages
Swifter - https://github.com/httpswift/swifter.git @ 1.5.0
[AccountCenter] Processing Info.plist
Signing AccountCenter.app (in target 'AccountCenter' from project 'AccountCenter')
[AccountCenterUITests] Compiling AccountCenterUITests.swift
❌ Undefined symbols for architecture arm64
❌ "type metadata accessor for Swifter.HttpRequest", referenced from:
❌ "type metadata accessor for Swifter.HttpServer", referenced from:
❌ "Swifter.HttpServer.__allocating_init() -> Swifter.HttpServer", referenced from:
❌ ld: symbol(s) not found for architecture arm64
❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)
Testing failed:
Undefined symbol: type metadata accessor for Swifter.HttpRequest
Undefined symbol: type metadata accessor for Swifter.HttpServer
Undefined symbol: Swifter.HttpServer.__allocating_init() -> Swifter.HttpServer
Testing cancelled because the build failed.
** TEST FAILED **
The following build commands failed:
Ld /Users/bartek/Library/Developer/Xcode/DerivedData/AccountCenter-dcpwguqebomrtsafgxoihvvsrwmo/Build/Products/Debug-iphonesimulator/AccountCenterUITests-Runner.app/PlugIns/AccountCenterUITests.xctest/AccountCenterUITests normal (in target 'AccountCenterUITests' from project 'AccountCenter')
(1 failure)
What can be causing this?
@bartekpacia, have you figured it out yet?
Hi @asafkorem,
Unfortunately I didn't. I tried a few more libraries and ended up using Building42/Telegraph. I also saw people use swhitty/FlyingFox and be happy with it.
Here's my short story about looking for a simple, working server (for iOS UI test automation purposes - here it is):
- swifter - doesn't build on M1
- SwiftLocalhst - doesn't build as well
- GCDWebServer - doesn't work, no support for SPM
- fork of GCDWebServer that does work with SPM: works fine but for some strange reason, doesn't work in XCUITest
- Telegraph - finally, something that works!
But in the end, I migrated to gRPC, so I don't use any of the libraries I mentioned above anymore :)
PS I see that you work on Detox - great job and thanks! It inspired us a lot in Patrol :)
@bartekpacia, I remember you and Patrol from an issue you commented on (XCUITest integration on Detox), hope everything is going well for you, and thanks for sharing your story results!
BTW, I'm using Apple's Network framework directly, https://developer.apple.com/documentation/network, it works fine, but I just wanted to consider other alternatives.