Created
January 18, 2015 14:00
-
-
Save endel/6e2f9ac7279a6ee42b90 to your computer and use it in GitHub Desktop.
Alamofire + SwiftyJSON = Segmentation fault?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just instantiating is fine, the request gets executed normally | |
var req : MyRequest = MyRequest(...); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Command failed due to signal: Segmentation fault: 11 | |
// (details below) | |
var req : MyRequest = MyRequest(...); | |
req.onSuccess { (data) in | |
println("onSuccess!") | |
println(data) | |
} | |
CompileSwift normal x86_64 /Users/endel/Projects/hook-swift/Example/example/ViewController.swift | |
cd /Users/endel/Projects/hook-swift/Example | |
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/endel/Projects/hook-swift/Example/example/ViewController.swift /Users/endel/Projects/hook-swift/Example/example/AppDelegate.swift -target x86_64-apple-ios8.1 -target-cpu core2 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -I /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Products/Debug-iphonesimulator -F /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Products/Debug-iphonesimulator -g -module-cache-path /Users/endel/Library/Developer/Xcode/DerivedData/ModuleCache -Xcc -I/Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/example-generated-files.hmap -Xcc -I/Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/example-own-target-headers.hmap -Xcc -I/Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/example-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/example-project-headers.hmap -Xcc -I/Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Products/Debug-iphonesimulator/include -Xcc -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Xcc -I/Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/DerivedSources/x86_64 -Xcc -I/Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/DerivedSources -Xcc -DDEBUG=1 -emit-module-doc-path /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/Objects-normal/x86_64/ViewController~partial.swiftdoc -Onone -module-name example -emit-module-path /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/Objects-normal/x86_64/ViewController~partial.swiftmodule -serialize-diagnostics-path /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/Objects-normal/x86_64/ViewController.dia -emit-dependencies-path /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/Objects-normal/x86_64/ViewController.d -o /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/Objects-normal/x86_64/ViewController.o | |
0 swift 0x0000000101fa7b68 llvm::sys::PrintStackTrace(__sFILE*) + 40 | |
1 swift 0x0000000101fa8054 SignalHandler(int) + 452 | |
2 libsystem_platform.dylib 0x00007fff882ccf1a _sigtramp + 26 | |
3 libsystem_platform.dylib 0x00007fff5e916478 _sigtramp + 3596916088 | |
4 swift 0x000000010144c11c swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 108 | |
5 swift 0x000000010146b9c9 swift::Lowering::SILGenFunction::visitBraceStmt(swift::BraceStmt*) + 297 | |
6 swift 0x000000010146ea88 swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Stmt*) + 152 | |
7 swift 0x000000010143af31 swift::Lowering::SILGenFunction::emitValueConstructor(swift::ConstructorDecl*) + 5617 | |
8 swift 0x00000001014161da swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*) + 666 | |
9 swift 0x0000000101417a4b swift::SILModule::constructSIL(swift::Module*, swift::SourceFile*, swift::Optional<unsigned int>) + 475 | |
10 swift 0x0000000101417af8 swift::performSILGeneration(swift::SourceFile&, swift::Optional<unsigned int>) + 72 | |
11 swift 0x00000001012edf18 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 3432 | |
12 swift 0x00000001012eba6d main + 1677 | |
13 libdyld.dylib 0x00007fff87f905c9 start + 1 | |
14 libdyld.dylib 0x000000000000003c start + 2013723252 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Undefined symbols for architecture x86_64: | |
// (details below) | |
Alamofire.request(Alamofire.Method.GET, "", parameters: nil).response { (_, _, _, _) -> Void in | |
}.cancel() | |
var req : MyRequest = MyRequest(...); | |
req.onSuccess { (data) in | |
println("onSuccess!") | |
println(data) | |
} | |
Ld /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Products/Debug-iphonesimulator/example.app/example normal x86_64 | |
cd /Users/endel/Projects/hook-swift/Example | |
export IPHONEOS_DEPLOYMENT_TARGET=8.1 | |
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" | |
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk -L/Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Products/Debug-iphonesimulator -F/Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Products/Debug-iphonesimulator -filelist /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/Objects-normal/x86_64/example.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -objc_abi_version -Xlinker 2 -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/Objects-normal/x86_64/example.swiftmodule -mios-simulator-version-min=8.1 -Xlinker -dependency_info -Xlinker /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Intermediates/example.build/Debug-iphonesimulator/example.build/Objects-normal/x86_64/example_dependency_info.dat -o /Users/endel/Library/Developer/Xcode/DerivedData/example-aznshidyckvcxybybqsyvrnleepo/Build/Products/Debug-iphonesimulator/example.app/example | |
Undefined symbols for architecture x86_64: | |
"__TMdV10SwiftyJSON4JSON", referenced from: | |
__TFFC7example14ViewController11viewDidLoadFS0_FT_T_U0_FV10SwiftyJSON4JSONT_ in ViewController.o | |
ld: symbol(s) not found for architecture x86_64 | |
clang: error: linker command failed with exit code 1 (use -v to see invocation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Alamofire; | |
import SwiftyJSON; | |
public class MyRequest { | |
var request : Alamofire.Request; | |
public init(url : String, method: Alamofire.Method, headers: [String: String], data : [String: AnyObject]? = nil) { | |
let manager = Alamofire.Manager.sharedInstance | |
manager.session.configuration.HTTPAdditionalHeaders = headers | |
self.request = Alamofire.request(method, url, parameters: data, encoding: Alamofire.ParameterEncoding.JSON) | |
} | |
public func onSuccess(completionHandler: (SwiftyJSON.JSON) -> Void) -> Self { | |
self.request.response { (request, response, data, error) in | |
if error == nil { | |
completionHandler(SwiftyJSON.JSON(data!)); | |
} | |
} | |
return self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment