Skip to content

Instantly share code, notes, and snippets.

@Kuniwak
Created August 7, 2018 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kuniwak/e3284f11c371b1c8e44e0d51387d91ee to your computer and use it in GitHub Desktop.
Save Kuniwak/e3284f11c371b1c8e44e0d51387d91ee to your computer and use it in GitHub Desktop.
Workaround for XCTContext.runActivity on AppCode.
import _SwiftXCTestOverlayShims
public extension XCTContext {
// XXX: This is for AppCode. The original of runActivity have been failed on only AppCode.
// This cause is __XCTContextShouldStartActivity, it returns true when it is called on Xcode, but not on AppCode.
public class func runActivityPatched<Result>(named name: String, block: (XCTActivity) throws -> Result) rethrows -> Result {
let context = _XCTContextCurrent()
return try autoreleasepool {
let activity = _XCTContextWillStartActivity(context, name, XCTActivityTypeUserCreated)
defer {
_XCTContextDidFinishActivity(context, activity)
}
return try block(activity)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment