swifter icon indicating copy to clipboard operation
swifter copied to clipboard

Builds fails when trying to use `Swifter` in XCUITest

Open bartekpacia opened this issue 3 years ago • 3 comments

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 avatar Jul 22 '22 12:07 bartekpacia

@bartekpacia, have you figured it out yet?

asafkorem avatar Mar 20 '23 13:03 asafkorem

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):

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 avatar Mar 20 '23 14:03 bartekpacia

@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.

asafkorem avatar Mar 21 '23 11:03 asafkorem