yankodimitrov / swiftkeychain Goto Github PK
View Code? Open in Web Editor NEWAn elegant Swift wrapper around the Apple Keychain API
License: MIT License
An elegant Swift wrapper around the Apple Keychain API
License: MIT License
I`m trying to get data from keychain but receiving error "Segmentation fault: 11"
I downloaded your project and changed ViewController:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
var key = GenericKey(keyName: "test", value: "1234")
var keychain = Keychain(serviceName: "swift.keychain.test")
let storedKey = keychain.get(key).item // This producing error
}
}
Here is full log from Xcode:
CompileSwift normal x86_64 /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/ViewController.swift cd /Users/bezumkin/Downloads/SwiftKeychain /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/Keychain/KeychainQuery.swift -primary-file /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/ViewController.swift /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/Keychain/GenericKey.swift /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/Keychain/KeychainItem.swift /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/AppDelegate.swift /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/Keychain/KeychainService.swift /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/Keychain/ArchiveKey.swift /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/Keychain/Keychain.swift -target x86_64-apple-ios8.0 -target-cpu core2 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -I /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Products/Debug-iphonesimulator -F /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Products/Debug-iphonesimulator -g -module-cache-path /Users/bezumkin/Library/Developer/Xcode/DerivedData/ModuleCache -Xcc -I/Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/SwiftKeychain-generated-files.hmap -Xcc -I/Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/SwiftKeychain-own-target-headers.hmap -Xcc -I/Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/SwiftKeychain-all-target-headers.hmap -Xcc -iquote -Xcc /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/SwiftKeychain-project-headers.hmap -Xcc -I/Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Products/Debug-iphonesimulator/include -Xcc -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Xcc -I/Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/DerivedSources/x86_64 -Xcc -I/Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/DerivedSources -Xcc -DDEBUG=1 -emit-module-doc-path /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/Objects-normal/x86_64/ViewController~partial.swiftdoc -Onone -module-name SwiftKeychain -emit-module-path /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/Objects-normal/x86_64/ViewController~partial.swiftmodule -serialize-diagnostics-path /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/Objects-normal/x86_64/ViewController.dia -emit-dependencies-path /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/Objects-normal/x86_64/ViewController.d -o /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/Objects-normal/x86_64/ViewController.o 0 swift 0x000000010adedb68 llvm::sys::PrintStackTrace(__sFILE*) + 40 1 swift 0x000000010adee054 SignalHandler(int) + 452 2 libsystem_platform.dylib 0x00007fff8b624f1a _sigtramp + 26 3 swift 0x000000010b0ef95a resolveIdentTypeComponent(swift::TypeChecker&, swift::DeclContext*, llvm::ArrayRef, swift::OptionSet, bool, swift::GenericTypeResolver*) + 906 4 swift 0x000000010b045b42 swift::constraints::ConstraintSystem::getTypeOfMemberReference(swift::Type, swift::ValueDecl*, bool, bool, swift::constraints::ConstraintLocatorBuilder, swift::constraints::DependentTypeOpener*) + 626 5 swift 0x000000010b0e368d matchWitness(swift::TypeChecker&, swift::NormalProtocolConformance*, swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*) + 1021 6 swift 0x000000010b0e1495 (anonymous namespace)::ConformanceChecker::resolveWitnessViaLookup(swift::ValueDecl*) + 1141 7 swift 0x000000010b0dff73 swift::TypeChecker::conformsToProtocol(swift::Type, swift::ProtocolDecl*, swift::DeclContext*, swift::ProtocolConformance**, swift::SourceLoc, swift::Decl*) + 3731 8 swift 0x000000010b0e02ce swift::TypeChecker::resolveConformance(swift::NominalTypeDecl*, swift::ProtocolDecl*, swift::ExtensionDecl*) + 110 9 swift 0x000000010b1cd451 swift::Module::lookupConformance(swift::Type, swift::ProtocolDecl*, swift::LazyResolver*) + 2305 10 swift 0x000000010b0df5f1 swift::TypeChecker::conformsToProtocol(swift::Type, swift::ProtocolDecl*, swift::DeclContext*, swift::ProtocolConformance**, swift::SourceLoc, swift::Decl*) + 1297 11 swift 0x000000010b078eaf swift::constraints::ConstraintSystem::simplifyConformsToConstraint(swift::Type, swift::ProtocolDecl*, swift::constraints::ConstraintLocatorBuilder, unsigned int, bool) + 255 12 swift 0x000000010b07f000 swift::constraints::ConstraintSystem::simplifyConstraint(swift::constraints::Constraint const&) + 512 13 swift 0x000000010b083097 swift::constraints::ConstraintSystem::simplify() + 103 14 swift 0x000000010b085a71 swift::constraints::ConstraintSystem::solve(llvm::SmallVectorImpl&, swift::FreeTypeVariableBinding) + 65 15 swift 0x000000010b08868e swift::constraints::ConstraintSystem::solveSimplified(llvm::SmallVectorImpl&, swift::FreeTypeVariableBinding) + 3230 16 swift 0x000000010b085f6a swift::constraints::ConstraintSystem::solve(llvm::SmallVectorImpl&, swift::FreeTypeVariableBinding) + 1338 17 swift 0x000000010b085b9c swift::constraints::ConstraintSystem::solve(llvm::SmallVectorImpl&, swift::FreeTypeVariableBinding) + 364 18 swift 0x000000010b0a32a2 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::Type, bool, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*) + 946 19 swift 0x000000010b0a7192 swift::TypeChecker::typeCheckBinding(swift::PatternBindingDecl*) + 162 20 swift 0x000000010b0b50d0 validatePatternBindingDecl(swift::TypeChecker&, swift::PatternBindingDecl*) + 560 21 swift 0x000000010b0c16f0 swift::ASTVisitor<(anonymous namespace)::DeclChecker, void, void, void, void, void, void>::visit(swift::Decl*) + 224 22 swift 0x000000010b0b2f4b swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 123 23 swift 0x000000010b0ec439 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 473 24 swift 0x000000010b0eb3e7 swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 375 25 swift 0x000000010b0ebaf1 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 97 26 swift 0x000000010b098b4d typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 221 27 swift 0x000000010b099536 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, unsigned int) + 1734 28 swift 0x000000010a3ce7bd swift::CompilerInstance::performSema() + 2381 29 swift 0x000000010a133988 frontend_main(llvm::ArrayRef, char const*, void*) + 2008 30 swift 0x000000010a131a6d main + 1677 31 libdyld.dylib 0x00007fff8ffee5c9 start + 1 32 libdyld.dylib 0x000000000000003e start + 1879120502 Stack dump: 0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/Keychain/KeychainQuery.swift -primary-file /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/ViewController.swift /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/Keychain/GenericKey.swift /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/Keychain/KeychainItem.swift /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/AppDelegate.swift /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/Keychain/KeychainService.swift /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/Keychain/ArchiveKey.swift /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/Keychain/Keychain.swift -target x86_64-apple-ios8.0 -target-cpu core2 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -I /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Products/Debug-iphonesimulator -F /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Products/Debug-iphonesimulator -g -module-cache-path /Users/bezumkin/Library/Developer/Xcode/DerivedData/ModuleCache -Xcc -I/Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/SwiftKeychain-generated-files.hmap -Xcc -I/Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/SwiftKeychain-own-target-headers.hmap -Xcc -I/Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/SwiftKeychain-all-target-headers.hmap -Xcc -iquote -Xcc /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/SwiftKeychain-project-headers.hmap -Xcc -I/Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Products/Debug-iphonesimulator/include -Xcc -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Xcc -I/Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/DerivedSources/x86_64 -Xcc -I/Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/DerivedSources -Xcc -DDEBUG=1 -emit-module-doc-path /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/Objects-normal/x86_64/ViewController~partial.swiftdoc -Onone -module-name SwiftKeychain -emit-module-path /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/Objects-normal/x86_64/ViewController~partial.swiftmodule -serialize-diagnostics-path /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/Objects-normal/x86_64/ViewController.dia -emit-dependencies-path /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/Objects-normal/x86_64/ViewController.d -o /Users/bezumkin/Library/Developer/Xcode/DerivedData/SwiftKeychain-afwnxsteyvzbuucedsbgthcgxagm/Build/Intermediates/SwiftKeychain.build/Debug-iphonesimulator/SwiftKeychain.build/Objects-normal/x86_64/ViewController.o 1. While type-checking 'viewDidLoad' at /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/ViewController.swift:13:14 2. While type-checking declaration at /Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/ViewController.swift:20:9 3. While type-checking expression at [/Users/bezumkin/Downloads/SwiftKeychain/SwiftKeychain/ViewController.swift:20:25 - line:20:43] RangeText="keychain.get(key).i"
It seems like a some bug of x86_64 platform.
Thank you for any response!
hello, I have been using swiftkeychain on my project and have upgraded to Xcode 7.1 beta (7B60). Ever since that upgrade I keep getting an error when trying to save data to the keychain. The weird thing is that this only happens on my iPhone 6 running iOS 9.1 beta. All simulators work fine and my iPad air2 running ios9.1 beta works fine as well. Any help would be greatly appreciated
Error Domain=swift.keychain.error.domain Code=-25299 "(null)"
the library https://github.com/p2/OAuth2 uses SwiftKeychain to store Oauth2 tokens in the keychain, it does this with the default setting kSecAttrAccessibleWhenUnlocked
As soon as I try to use kSecAttrAccessibleAlways
I get the error
Failed to store to keychain: The process could not be completed. (swift.keychain.error.domain-Fehler -25299.)
So that Cocoapods users can have the changes from #5
See Release section of https://guides.cocoapods.org/making/making-a-cocoapod.html
Cocoapods are now supports swift in beta version.
Do you planning to add its support in SwiftKeychain? For example, here is another packages.
Thank you for awesome tool!
Hello,
I was wondering if you support Swift 2.0 already?
Best,
Sidney
How to check if accountName exists?
if I want to remove something from the keychain it does not matter if it existed before so the method remove should be successful even if the entry was not found
I found a strange issue that occurs only when I run the code with Release build configuration on 64bit device. Basically Im unable to store or access records in the Keychain. The Keychain returns a status code of 0 (errSecSuccess), but the returned result reference both in SecItemCopyMatching and SecItemAdd contains a nil value.
Here is what I have found during my testing:
1. Build configuration: Debug:
-32bit: working fine;
-64bit: working fine;
2. Build configuration: Release:
-32bit: working fine;
-64bit: unable to access or store items in the Keychain;
If I build only for 32bit architectures and run the code on 64bit device everything is working fine.
I also posted the question on the dev forum: https://devforums.apple.com/thread/255103
Is this project still actively developed on?
Hi,
What is the ETA for a Swift 3 version of SwiftKeychain?
Cheers.
Hi, when two users use the same phone. How can I use two different keychain for each user? Thank you very much.
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.