New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
structure["key.offset"] is off by 1 #635
Comments
It would really help if you shared the steps you took to reproduce this issue. We haven't seen this before. |
Sorry, here is the snippet where it is retrieving data from the structure:
A Swift class is being scanned, and the structure is being built (cast) as:
after the structure is read in:
Once the structure is valued, then locating the function structures, the process gets the function bodies (this worked fine on OSX, but just noticed on Ubuntu this behavior):
Using: SourceKitten 0.27.0, on Ubuntu 18 ... Linux 4.15.0-1056 Ubuntu SMP Tue Nov 26 15:14:34 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux |
I think I'm running into this issue. Case 1 (no unicode chars)
Output of
Case 2 (In the comment, the letter
|
Ah, the |
Hmm, that make sense. |
You should use SourceKittenFramework, which has a number of methods for manipulating strings from byte offsets: https://github.com/jpsim/SourceKitten/blob/0.28.0/Source/SourceKittenFramework/StringView.swift#L133-L141 |
@jpsim Thanks :) |
Would that be the cause of the issue ? Until I upgrade to Sahara a while back it worked fine as is ... but noticed since the upgrade that it is off at times. |
@Moriquendi - did using SourceKittenFramework fix things for you ? |
@pkasson @jpsim
Looks like it's working so I hope it's correct 😬 |
That helps ! Are you using Xcode strictly, or Swift Package Manager ? I am having troubles upgrade to kitten 28, which includes StringView - totally hoses up the build. |
I used CocoaPods @pkasson |
Would you mind sharing the specific bits for your Podfile ? Here is what I am using and its complaining about def shared_pods But the build complains about SWXMLHash being Swift 3 and that's coming from SourceKitten, how did you get it to work with Swift 4/5 ? |
@pkasson Ah, is your project a MacOS app or command line tool? I think I had similar issue when I was trying to link those frameworks into command line tool - probably because you can’t have dynamic frameworks there. Not sure if there’s a way to force static linking in CocoaPods. If you do find the solution, please let me know 😬 |
Yes, I usually try the unthinkable. I did get this thing to work fine using SPM and on Ubuntu no less, but upgrading one of the libraries made it sad. However, by updating the paths to find all libraries, it ran just fine (not trying to distribute this thing, just run it). |
Switching from SPM to CocoaPods worked. BTW, if not deploying a CLI app, setting the paths allow the app to work, and do not need to be statically linked. But, this is a good read on the topic: |
Kitten reports the offset for the function body to be off by 1, and chops off the beginning of the function name for the body:
unc numberOfComponents(in pickerView: UIPickerView) -> Int { return 1 }
Was parsing BitcoinTicker on Github and noticed all the function bodies are missing the first character.
The text was updated successfully, but these errors were encountered: