leandromperez / specleaks Goto Github PK
View Code? Open in Web Editor NEWUnit Tests Memory Leaks in Swift. Write readable tests for mem leaks easily with these Quick and Nimble extensions.
License: MIT License
Unit Tests Memory Leaks in Swift. Write readable tests for mem leaks easily with these Quick and Nimble extensions.
License: MIT License
Hi !
Thank you for this very cool library.
With Swift 5, there is a warning because the library was not build with Swift 5.
I think there are not so many changes since 4.2, so maybe a new version with swift version updated could be useful for every Swift 5 users :)
Hi!
Build doesn't work. Could you explain the right way to install library, please?
First of all, thank you for this library, I am excited to start using it.
It appears I am getting this error because Matchers.swift
was only added after the first POD release.
Please could you deploy a new release?
I'm using Carthage and would love to use this tool, however it doesn't seem to support macOS. Not sure if this is the same with CocoaPods? Would it be possible to support the desktop platform?
After updating to Xcode 11.4 I cannot build the library anymore via Carthage
Ld /Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Intermediates.noindex/SpecLeaks.build/Release-iphonesimulator/SpecLeaks.build/Objects-normal/x86_64/Binary/SpecLeaks normal x86_64 (in target 'SpecLeaks' from project 'SpecLeaks')
cd /Users/igorkulman/Projects/open-source/iOSSampleApp/Sources/Carthage/Checkouts/specleaks
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-ios10.0-simulator -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk -L/Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Products/Release-iphonesimulator -F/Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Products/Release-iphonesimulator -F/Users/igorkulman/Projects/open-source/iOSSampleApp/Sources/Carthage/Checkouts/specleaks/Carthage/Build/iOS -filelist /Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Intermediates.noindex/SpecLeaks.build/Release-iphonesimulator/SpecLeaks.build/Objects-normal/x86_64/SpecLeaks.LinkFileList -install_name @rpath/SpecLeaks.framework/SpecLeaks -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Intermediates.noindex/SpecLeaks.build/Release-iphonesimulator/SpecLeaks.build/Objects-normal/x86_64/SpecLeaks_lto.o -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Intermediates.noindex/SpecLeaks.build/Release-iphonesimulator/SpecLeaks.build/Objects-normal/x86_64/SpecLeaks.swiftmodule -framework Quick -framework Nimble -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Intermediates.noindex/SpecLeaks.build/Release-iphonesimulator/SpecLeaks.build/Objects-normal/x86_64/SpecLeaks_dependency_info.dat -o /Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Intermediates.noindex/SpecLeaks.build/Release-iphonesimulator/SpecLeaks.build/Objects-normal/x86_64/Binary/SpecLeaks
ld: warning: Could not find or use auto-linked library 'XCTestSwiftSupport'
ld: warning: Could not find or use auto-linked framework 'XCTest'
Undefined symbols for architecture x86_64:
"__swift_FORCE_LOAD_$_XCTestSwiftSupport", referenced from:
__swift_FORCE_LOAD_$_XCTestSwiftSupport_$_SpecLeaks in LeaksAnalyzer.o
__swift_FORCE_LOAD_$_XCTestSwiftSupport_$_SpecLeaks in Expectation+Leaks.o
__swift_FORCE_LOAD_$_XCTestSwiftSupport_$_SpecLeaks in Matchers.o
__swift_FORCE_LOAD_$_XCTestSwiftSupport_$_SpecLeaks in AnalyzeLeakAction.o
__swift_FORCE_LOAD_$_XCTestSwiftSupport_$_SpecLeaks in LeakTest.o
__swift_FORCE_LOAD_$_XCTestSwiftSupport_$_SpecLeaks in AnalyzeLeak.o
Ld /Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Intermediates.noindex/SpecLeaks.build/Release-iphonesimulator/SpecLeaks.build/Objects-normal/i386/Binary/SpecLeaks normal i386 (in target 'SpecLeaks' from project 'SpecLeaks')
cd /Users/igorkulman/Projects/open-source/iOSSampleApp/Sources/Carthage/Checkouts/specleaks
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target i386-apple-ios10.0-simulator -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk -L/Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Products/Release-iphonesimulator -F/Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Products/Release-iphonesimulator -F/Users/igorkulman/Projects/open-source/iOSSampleApp/Sources/Carthage/Checkouts/specleaks/Carthage/Build/iOS -filelist /Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Intermediates.noindex/SpecLeaks.build/Release-iphonesimulator/SpecLeaks.build/Objects-normal/i386/SpecLeaks.LinkFileList -install_name @rpath/SpecLeaks.framework/SpecLeaks -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Intermediates.noindex/SpecLeaks.build/Release-iphonesimulator/SpecLeaks.build/Objects-normal/i386/SpecLeaks_lto.o -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Intermediates.noindex/SpecLeaks.build/Release-iphonesimulator/SpecLeaks.build/Objects-normal/i386/SpecLeaks.swiftmodule -framework Quick -framework Nimble -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Intermediates.noindex/SpecLeaks.build/Release-iphonesimulator/SpecLeaks.build/Objects-normal/i386/SpecLeaks_dependency_info.dat -o /Users/igorkulman/Library/Caches/org.carthage.CarthageKit/build/5.2+f58d9b74f6b642adce092215d0238d3c/specleaks/0.1.8/Build/Intermediates.noindex/SpecLeaks.build/Release-iphonesimulator/SpecLeaks.build/Objects-normal/i386/Binary/SpecLeaks
ld: warning: Could not find or use auto-linked library 'XCTestSwiftSupport'
ld: warning: Could not find or use auto-linked framework 'XCTest'
Undefined symbols for architecture i386:
"__swift_FORCE_LOAD_$_XCTestSwiftSupport", referenced from:
__swift_FORCE_LOAD_$_XCTestSwiftSupport_$_SpecLeaks in LeaksAnalyzer.o
__swift_FORCE_LOAD_$_XCTestSwiftSupport_$_SpecLeaks in Expectation+Leaks.o
__swift_FORCE_LOAD_$_XCTestSwiftSupport_$_SpecLeaks in Matchers.o
__swift_FORCE_LOAD_$_XCTestSwiftSupport_$_SpecLeaks in AnalyzeLeakAction.o
__swift_FORCE_LOAD_$_XCTestSwiftSupport_$_SpecLeaks in LeakTest.o
__swift_FORCE_LOAD_$_XCTestSwiftSupport_$_SpecLeaks in AnalyzeLeak.o
(maybe you meant: __swift_FORCE_LOAD_$_XCTestSwiftSupport_$_SpecLeaks)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **
Any plans to add Carthage support?
Hi
when I use this framework to test does function has leak. Code is like below. test unit shows it has leak, but when I use deinit
to test is the viewcontroller
is free, the deinit
function called. and when I check memory graph, it seems no leak. can you help me to figure out why the test unit shows leak?
struct SchoolModel{ }
extension SchoolModel{
static func loadData(completion: @escaping ([String]) -> Void){
DispatchQueue.main.async {
completion([])
}
}
}
import UIKit
class ViewController: UIViewController {
var completeData:[String] = []
override func viewDidLoad() {
super.viewDidLoad()
SchoolModel.loadData { (data) in
self.completeData = data
}
}
deinit {
print("\(#function)")
}
}
import Nimble
import Quick
import SpecLeaks
@testable import LeakTry
class leakTest: QuickSpec {
override func spec() {
describe("") {
let test = LeakTest {
let vc = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "ViewController") as! ViewController
return vc
}
describe("init") {
it("must not leak") {
expect(test).toNot(leak())
}
}
}
}
}
Could you add Swift Package Manager support?
There is a release candidate for version 9 of Nimble available that has support for XCode 12 (more info here). However, updating to Nimble 9 breaks this Pod.
I have attached a screenshot that indicates specifically which file/part of the code is causing the compilation issues, it is just a type mismatch between TimeInterval
and DispatchTimeInterval
in Expectation+Leaks.swift
.
ld: '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework/XCTest' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework/XCTest' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I tried to import SpecLeaks with cocoapods (specifying pod 'SpecLeaks' in my podfile), but it seems that many files are missing.
In fact, I only got LeakTest.swift, but all the other files are not downloaded.
Maybe there is a problem with your pod configuration ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.