I'm using Axe DevTools and I'm trying to figure out how to tag multiple scans with the same build information. Right now I have my tests running like this:
class MyTestCase : XCTestCase {
func myTest() {
Attest.that(view: view)
.isAccessible({ result in })
.andPushResult(withTags: [myBuild])
}
}
How can I add the myBuild tag globally to all tests that I run?
I would build my own class that utilizes the Axe DevTools (Attest) APIs. Then have my test cases interact with my own class instead of interacting with Attest itself!
class AccessibilityTestUtils {
static let buildTag:String = Bundle.main.object(
forInfoDictionaryKey: "CFBundleShortVersionString"
) as! String
init(build: String) {
self.buildTag = build
}
static func runAccessibilityTestOn(aView : View) {
Attest.that(view: aView).isAccessible({ result in })
.andPushResult(withTags: [buildTag])
}
}
Example Usage
class YourTestClass {
func yourTestCase() {
AccessibilityTestUtils.runAccessibilityTestOn(aView)
}
}
Note: This approach also protects you from future changes to the Attest library by making it so that you only have to change one line of code in the event of non backwards compatible changes.
I'm trying to using Swift Combine to get the changed event of a property.
I have this class that publish the isLogged property
class CurrentUser: Account {
static let me = CurrentUser() //Singleton
#Published var isLogged: Bool = false
}
that inherit from this other class that publish the profileImageVersion property
class Account {
#Published var profileImageVersion: String?
init(){
self.profileImageVersion = ""
}
}
I'm trying to subscribe to the published inherit profileImageVersion property like this without success!
// Subscribe to account image changes
userImageChangedSubscriber = CurrentUser.me.$profileImageVersion.receive(on: DispatchQueue.main).sink(receiveValue: { (imageVersion) in
...
}
})
The error is Fatal error: Call of deleted method
if, on the other hand, I subscribe to the isLogged property, all Is working fine...
// Subscribe to logged changes
userLoggedSubscriber = CurrentUser.me.$isLogged.receive(on: DispatchQueue.main).sink(receiveValue: { (logged) in
...
})
This error is thrown only on Xcode 11.4 beta 2 / iOS 13.4.
Using Xcode 11.3.1 / 13.3 all is working fine!
I have this same crash, and as a temporary workaround I found that moving all your published properties to the concrete class you are using will fix the issue. I had a setup like this:
class EpisodesViewModel {
#Published var episodes: [Episode]
init(fetchRequest: NSFetchRequest<Episode>, context: NSManagedObjectContext? = nil) throws {
...
}
...
}
With a subclass of this model that simply gave a fetch request:
final class LatestEpisodesViewModel: EpisodesViewModel {
init() throws {
try super.init(fetchRequest: Episode.latestFetchRequest())
}
}
By changing my setup to this I was able to fix the crash:
class EpisodesViewModel {
var fetchedEpisodes: [Episode]
init(fetchRequest: NSFetchRequest<Episode>, context: NSManagedObjectContext? = nil) throws {
...
}
...
}
final class LatestEpisodesViewModel: EpisodesViewModel {
#Published var episodes: [Episode] = []
override var fetchedEpisodes: [Episode] {
didSet {
episodes = fetchedEpisodes
}
}
init() throws {
try super.init(fetchRequest: Episode.latestFetchRequest())
}
}
This certainly seems like an Apple bug to me, but this got me around the issue in the meantime.
I have this same crash on Xcode 11.4.1.
I use "Clean Build Folder", build my project again and all works now fine !
I try to build my legacy code on xcode 9, swift version 3.2 with the Cleanse dependency injector, but the static func configure<B: Binder>(binder: Binder) function got the following error:
Reference to generic type 'Binder' requires arguments in <...>
I tried all the branches and commits. What do you recommend?
The syntax seems to have changed
func configure<B : Binder>(binder binder: B) {
// Will fill out contents later
}
https://github.com/square/Cleanse
The correct syntax is the following:
struct Singleton : Scope {
}
static func configure(binder: Binder<Singleton>) {
// Will fill out contents later
}
You can check an example here:
https://github.com/square/Cleanse/blob/master/CleansePlayground.playground/Pages/CoffeeMakerExample.xcplaygroundpage/Contents.swift
I am using Alamofire for network handling in swift and run into one weird error. It seems like we can't pass Method enum as parameter. [Error is on Method parameter]
private func apiRequest(method: Method, url: String, apiData: [String : AnyObject], completion:(finished: Bool, response: AnyObject?) ->Void) {
Alamofire.request(method, url, parameters: apiData).responseJSON{ response in
if let JSON = response.result.value {
completion(finished: true, response: JSON)
} else {
completion(finished: false, response:nil)
}
}
}
You have to specify the module from which to lookup object type.
Call Alamofire.Method
There is probably a name collision. To solve it, you can use the qualified name of the enum (including the module name):
private func apiRequest(method: Alamofire.Method, ...
I have also encountered this problem, because I have declared a number of the same name of the protocol:
protocol SomeProtocol {
static func someTypeMethod()
}
protocol SomeProtocol {
init(someParameter: Int)
}
protocol SomeProtocol {
var mustBeSettable: Int { get set }
var doesNotNeedToBeSettable: Int { get }
}
Had this error conflict when using "Moya" and when bridging a c framework, fixed it by implicitly adding Moya.Method module.
var method: Moya.Method {
switch self {
case .login: return .post
case .register: return .post
}
}
The type Method is declared in two imported modules. You have to specify the module from which to use the type. Use Alamofire.Method instead of Method.
Tip: If you are using the type often, you can create a type alias in your module (application):
typealias Method = Alamofire.Method
That way you will not need to prefix the type with Alamofire. any more.
While the answer to this did fix the build error; in my case, the file showing the warning was in two different frameworks so Xcode did not know where to look. This was not the intended behavior of our internal frameworks so I simply removed the copy I no longer wanted.
You may have a class declared in two or more places in your application. The error is saying that there is no conclusive way to use this class because there are a couple different places in the code it is declared.
Swift 4 and Alamofire 4.7
Replace HTTPMethod to Alamofire.HTTPMethod
I got this error because my database table name and model class name was same...Issue resolved by renaming model class name.
Change the enum type name to different &...
Use the $(inherited) flag, or
Remove the build settings from the target.
Target - > building settings- >ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES, Value type is Boolean, click on the other, change the value to $(inherited)
perform - pod update
Done
then try to run Your project , error will gone ! (I have tried in my project)
enum 'XYZ'ButtonType {
}
I managed to fix the problem by deleting the Alamofire folder in the pods project manually. Then, I do a "pod install" to reinstall the missing pods.
There are significantly less files in the Alamofire folder after doing this.
I am using Swift 3.0 on Xcode 8.0 beta. I have installed a library using pods (FMDB) and now I am trying to extend one of its class in swift. I am able to use the API from my extended class but it crashes at runtime.
-[FMResultSet polygonsForColumnIndex:]: unrecognized selector sent to instance 0x608000056890
Below is the code for the extension:
public extension FMResultSet {
public func polygons(forColumnIndex index: Int32) -> [NMAMapPolygon] {
It crashes here when called:
let rs = db.executeQuery("select AsGeoJSON(geometry) from COM262_Project", withArgumentsIn: nil)
while (rs?.next())! {
//Crashes here!
let polygons = rs?.polygons(forColumnIndex: 0)
}
Note: Extensions work for other libraries like Alamofire.
Have you tried setting the function as #objc e.g.
public extension FMResultSet {
#objc public func polygons(forColumnIndex index: Int32) -> [NMAMapPolygon] {
On top of that have you changed the build setting Enable Modules to Yes.. Or if your using a config file CLANG_ENABLE_MODULES = YES