fus
fus copied to clipboard
invalid byte sequence in UTF-8
I installed fus using sudo gem install fus
and tried running it in the root of my project but got the following error message:
$ fus find
/Library/Ruby/Gems/2.3.0/gems/fus-0.0.3/lib/fus/swift_class.rb:26:in `match': invalid byte sequence in UTF-8 (ArgumentError)
from /Library/Ruby/Gems/2.3.0/gems/fus-0.0.3/lib/fus/swift_class.rb:26:in `match'
from /Library/Ruby/Gems/2.3.0/gems/fus-0.0.3/lib/fus/swift_class.rb:26:in `used_in_obj_c?'
from /Library/Ruby/Gems/2.3.0/gems/fus-0.0.3/lib/fus/finder.rb:69:in `block in used_in_obj_c?'
from /Library/Ruby/Gems/2.3.0/gems/fus-0.0.3/lib/fus/finder.rb:69:in `any?'
from /Library/Ruby/Gems/2.3.0/gems/fus-0.0.3/lib/fus/finder.rb:69:in `used_in_obj_c?'
from /Library/Ruby/Gems/2.3.0/gems/fus-0.0.3/lib/fus/finder.rb:48:in `block in unused_classes'
from /Library/Ruby/Gems/2.3.0/gems/fus-0.0.3/lib/fus/finder.rb:44:in `reject'
from /Library/Ruby/Gems/2.3.0/gems/fus-0.0.3/lib/fus/finder.rb:44:in `unused_classes'
from /Library/Ruby/Gems/2.3.0/gems/fus-0.0.3/lib/fus/finder.rb:21:in `unused_classnames'
from /Library/Ruby/Gems/2.3.0/gems/fus-0.0.3/bin/fus:14:in `find'
from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from /Library/Ruby/Gems/2.3.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
from /Library/Ruby/Gems/2.3.0/gems/fus-0.0.3/bin/fus:34:in `<top (required)>'
from /usr/local/bin/fus:22:in `load'
from /usr/local/bin/fus:22:in `<main>'
Weird. You must have some character that the regex function doesn't like in one of your source files. I'd need to have more info about the specifics to fix
I have the same issue.
@oleghnidets if there is any way you can provide a test file that causes this failure that would be helpful.
While debugging, I noticed fus goes very deeply into the Pods folder analyzing if swift class is used in ObjC classes and failed on this file:
.../Pods/Postal/dependencies/build/macos/include/libetpan/clist.h
This file online: https://github.com/dinhviethoa/libetpan/blob/master/src/data-types/clist.h
The file which was analyzing by fus at the moment of failure is just the first available file containing that:
//
// EmptyCase.swift
//
import XCTest
/// Empty test case to make Tests target compilable until any platform-specific tests would be added
class EmptyCase: XCTestCase {}
Workaround for me was:
- Create a folder and symlink all folders I want to analyze inside
- Edit finder.rb file to allow following symlinks:
10c10
< .glob("#{path}/**/*.swift")
---
> .glob("#{path}/**{,/*/**}/*.swift")
13c13
< @obj_c_paths = Dir.glob("#{path}/**/*.m") + Dir.glob("#{path}/**/*.h")
---
> @obj_c_paths = Dir.glob("#{path}/**{,/*/**}/*.m") + Dir.glob("#{path}/**{,/*/**}/*.h")
15,16c15,16
< @ib_paths = (Dir.glob("#{path}/**/*.xib") +
< Dir.glob("#{path}/**/*.storyboard"))
---
> @ib_paths = (Dir.glob("#{path}/**{,/*/**}/*.xib") +
> Dir.glob("#{path}/**{,/*/**}/*.storyboard"))
- Run fus targeting a folder with symlinks