asafkorem / COSTouchVisualizer

Visualize touches, gestures and long presses on your iPhone or iPad
https://www.conopsys.com/COSTouchVisualizer/
MIT License
960 stars 70 forks source link

Swift Segmentation Fault 11 #21

Closed jjeon5 closed 9 years ago

jjeon5 commented 9 years ago

After properly adding the pod and putting

class AppDelegate: UIResponder, UIApplicationDelegate {
    lazy var window: COSTouchVisualizerWindow? = {
        COSTouchVisualizerWindow(frame: UIScreen.mainScreen().bounds)
        }()
   ...
}

There is a segmentation fault

error: use of undeclared type 'COSTouchVisualizerWindow'
    lazy var window: COSTouchVisualizerWindow? = {
                     ^~~~~~~~~~~~~~~~~~~~~~~~
0  swift                    0x0000000101cd8968 llvm::sys::PrintStackTrace(__sFILE*) + 40
1  swift                    0x0000000101cd8e54 SignalHandler(int) + 452
2  libsystem_platform.dylib 0x00007fff88cb1f1a _sigtramp + 26
3  libsystem_platform.dylib 0x0000000000000040 _sigtramp + 1999954240
4  swift                    0x000000010209dea2 mapSignatureFunctionType(swift::ASTContext&, swift::Type, bool, bool, bool, unsigned int) + 66
5  swift                    0x000000010209dcf3 swift::ValueDecl::getOverloadSignature() const + 531
6  swift                    0x0000000101fb35cd checkRedeclaration(swift::TypeChecker&, swift::ValueDecl*) + 397
7  swift                    0x0000000101fad073 swift::ASTVisitor<(anonymous namespace)::DeclChecker, void, void, void, void, void, void>::visit(swift::Decl*) + 2723
8  swift                    0x0000000101f9df0b swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 123
9  swift                    0x0000000101f8425a swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, unsigned int) + 1514
10 swift                    0x00000001012b95dd swift::CompilerInstance::performSema() + 2381
11 swift                    0x000000010101e788 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2008
12 swift                    0x000000010101c86d main + 1677
13 libdyld.dylib            0x00007fff8d0405c9 start + 1
14 libdyld.dylib            0x000000000000005e start + 1929116310
joeblau commented 9 years ago

Can you post the snippet of your AppDelegate?

Also are you using Frameworks with pods or a bridging header?

jjeon5 commented 9 years ago

Pods I also commented out the original window.

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    lazy var window: COSTouchVisualizerWindow? = {
        COSTouchVisualizerWindow(frame: UIScreen.mainScreen().bounds)
        }()
    //var window: UIWindow?
jjeon5 commented 9 years ago

Any luck?

joeblau commented 9 years ago

Not yet, I was investigating it but I couldn't even get the window to load in Xcode 6.3. I'm getting a compile time error about overriding the getter on window.

What version of Xcode/Swift Does your Podfile contain the use_frameworks! declaration ?

jjeon5 commented 9 years ago

I'm using Xcode 6.2 right now. About the use_frameworks!, no I am unaware of this. Sorry I'm quite new to Cocoapods.

joeblau commented 9 years ago

Okay,

Apple might have changed something in Xcode 6.3 in the Swift formatting that is breaking my project which is why I can't run it right now. I'll have to trouble shoot that first.

As for use_frameworks!, that takes advantage of Apple's support for having proper bundled packages. Framework support was added in the latest minor release version of Cocoapods (0.36.0). If you're not using frameworks, then you're importing the COSTouchVisualizer through a bridging header.

Once I figure out why I can't use this library in Swift 1.2, I'm going to take a look at whether or not the bridging header makes a difference or not.

KeiroMidori commented 9 years ago

I can confirm this issue with the latest swift update. Hope you can find what's going on !

dzdora commented 9 years ago

I am having the same issue. Importing COSTouchVisualizer through a Bridging header. The error I'm getting is as follows:

Objective-C method 'window' provided by getter for 'window' conflicts with optional requirement getter for 'window' in protocol 'UIApplicationDelegate'

as well as for the setter

Objective-C method 'setWindow:' provided by setter for 'window' conflicts with optional requirement setter for 'window' in protocol 'UIApplicationDelegate'

I'm getting these both with and without use_frameworks!

krusche commented 9 years ago

Use the following in your AppDelegate

    lazy var window: UIWindow? = {
        COSTouchVisualizerWindow(frame: UIScreen.mainScreen().bounds)
    }()

Then it should work without problems

joeblau commented 9 years ago

@krusche thank you, I was trying that but I forgot the step of setting the delegate. I just updated the project with a Swift example and here is the entire AppDelegate

import UIKit
import COSTouchVisualizer

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, COSTouchVisualizerWindowDelegate {

    lazy var window: UIWindow? = {
        var customWindow = COSTouchVisualizerWindow(frame: UIScreen.mainScreen().bounds)
        customWindow.touchVisualizerWindowDelegate = self
        return customWindow
        }()

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        return true
    }

    func touchVisualizerWindowShouldAlwaysShowFingertip(window: COSTouchVisualizerWindow!) -> Bool {
        return true
    }
}