marksands / Aviator

Xcode plugin that brings ⇧⌘T from AppCode over to Xcode
MIT License
29 stars 6 forks source link

Shortcut only works from class to test file #9

Closed c3farrell closed 9 years ago

c3farrell commented 9 years ago

Hi, Thank you for the plugin! After install to Xcode 6.4, via Alcatraz, the shortcut works from class file to test file. When I am in the test file, the shortcut does not return me to the class, nothing happens. My test files are suffixed with 'Spec' rather than 'Test,' not sure if that matters. Thank you!

marksands commented 9 years ago

Thank you for reporting this! I've been wondering how long my hack would hold up before it crumbled beneath itself. I will find time to monkey patch 'Spec' as an alternative naming scheme, but ideally I need some sort of engine that does a way better job of guessing than assuming a file suffix.

kenji21 commented 9 years ago

Maybe looking at target membership ?

$ /usr/libexec/PlistBuddy Test7.xcodeproj/project.pbxproj -c "print rootObject"
BA96075A1B26F7E50001E907
$ /usr/libexec/PlistBuddy Test7.xcodeproj/project.pbxproj -c "print objects:BA96075A1B26F7E50001E907:targets"
Array {
    BA9607611B26F7E50001E907
    BA9607751B26F7E50001E907
    BA9607801B26F7E50001E907
}

Then choose the second targets (as I know that is a test one, but we can iterate within plugin) :

$ /usr/libexec/PlistBuddy Test7.xcodeproj/project.pbxproj -c "print objects:BA9607751B26F7E50001E907"
Dict {
    buildConfigurationList = BA96078D1B26F7E50001E907
    productReference = BA9607761B26F7E50001E907
    productType = com.apple.product-type.bundle.unit-test
    productName = Test7Tests
    isa = PBXNativeTarget
    buildPhases = Array {
        BA9607721B26F7E50001E907
        BA9607731B26F7E50001E907
        BA9607741B26F7E50001E907
    }
    dependencies = Array {
        BA9607781B26F7E50001E907
    }
    name = Test7Tests
    buildRules = Array {
    }
}

And the first build phase ( the one of type PBXSourcesBuildPhase ) :

$ /usr/libexec/PlistBuddy Test7.xcodeproj/project.pbxproj -c "print objects:BA9607751B26F7E50001E907"
Dict {
    isa = PBXSourcesBuildPhase
    buildActionMask = 2147483647
    files = Array {
        BA96077B1B26F7E50001E907
        BA9607951B26F7F50001E907
        BA9607971B26F7FC0001E907
    }
    runOnlyForDeploymentPostprocessing = 0
}

And now the files are nearly there :

$ /usr/libexec/PlistBuddy Test7.xcodeproj/project.pbxproj -c "print objects:BA96077B1B26F7E50001E907"
Dict {
    isa = PBXBuildFile
    fileRef = BA96077A1B26F7E50001E907
}
$ /usr/libexec/PlistBuddy Test7.xcodeproj/project.pbxproj -c "print objects:BA9607931B26F7F50001E907"
Dict {
    path = TestSwift.swift
    isa = PBXFileReference
    sourceTree = <group>
    fileEncoding = 4
    lastKnownFileType = sourcecode.swift
}

Maybe it would be more easy to have test files using objc within the plugin :-)

marksands commented 9 years ago

@kenji21 I'm not sure what you're saying. I do look at target membership.

marksands commented 9 years ago

@chrisfarrell 8da4910 should fix your issue. Let me know if it's not solved. :+1:

I'm now working on Aviator 2.0 on a local branch, since I just found out that Xcode automatically parses the information I need. I just need to rewrite this plugin to use that framework, so there shouldn't be any more issues like this cropping up in the future!