samdmarshall / nslocalizer

A tool for finding missing and unused NSLocalizedStrings
BSD 3-Clause "New" or "Revised" License
157 stars 10 forks source link

Exception while trying to find missing strings #9

Closed ApoorvKhatreja closed 5 years ago

ApoorvKhatreja commented 5 years ago

My xcodeproj is part of a xcworkspace (which has multiple xcodeproj), not sure if this error is related to that?

Type of issue: [ Bug ]


Related Files:


Description:

$ nslocalizer --project <MY_PROJECT>.xcodeproj --target <MY_TARGET> --find-missing
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pbPlist-1.0.3-py3.7.egg/pbPlist/Switch.py", line 41, in __iter__
    raise StopIteration # pragma: no cover
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/nslocalizer", line 11, in <module>
    load_entry_point('nslocalizer==1.0.1', 'console_scripts', 'nslocalizer')()
  File "/usr/local/lib/python3.7/site-packages/nslocalizer-1.0.1-py3.7.egg/nslocalizer/main.py", line 123, in main
    Executor.run(args)
  File "/usr/local/lib/python3.7/site-packages/nslocalizer-1.0.1-py3.7.egg/nslocalizer/Executor/Executor.py", line 58, in run
    xcodeproj_file = xcodeproj(project_file_path)
  File "/usr/local/lib/python3.7/site-packages/nslocalizer-1.0.1-py3.7.egg/nslocalizer/xcodeproj/xcodeproj.py", line 44, in __init__
    self.project_file = pbProj.PBXProj(pbxproj_file_path)
  File "/usr/local/lib/python3.7/site-packages/nslocalizer-1.0.1-py3.7.egg/nslocalizer/xcodeproj/pbProj/pbProj.py", line 38, in __init__
    plist = pbPlist.pbPlist.PBPlist(file_path)
  File "/usr/local/lib/python3.7/site-packages/pbPlist-1.0.3-py3.7.egg/pbPlist/pbPlist.py", line 41, in __init__
    self.root = parser.read()
  File "/usr/local/lib/python3.7/site-packages/pbPlist-1.0.3-py3.7.egg/pbPlist/pbParser.py", line 118, in read
    parsed_plist = self.__readTest(True)
  File "/usr/local/lib/python3.7/site-packages/pbPlist-1.0.3-py3.7.egg/pbPlist/pbParser.py", line 133, in __readTest
    read_result = self.__parse(requires_object)
  File "/usr/local/lib/python3.7/site-packages/pbPlist-1.0.3-py3.7.egg/pbPlist/pbParser.py", line 142, in __parse
    parsed_item = pbItem.pbItemResolver(self.__parseDict(), 'dictionary') # pylint: disable=redefined-variable-type
  File "/usr/local/lib/python3.7/site-packages/pbPlist-1.0.3-py3.7.egg/pbPlist/pbParser.py", line 256, in __parseDict
    new_object = self.__readTest(False)
  File "/usr/local/lib/python3.7/site-packages/pbPlist-1.0.3-py3.7.egg/pbPlist/pbParser.py", line 133, in __readTest
    read_result = self.__parse(requires_object)
  File "/usr/local/lib/python3.7/site-packages/pbPlist-1.0.3-py3.7.egg/pbPlist/pbParser.py", line 139, in __parse
    for case in Switch(starting_character):
RuntimeError: generator raised StopIteration
samdmarshall commented 5 years ago

given the stack-trace, it appears that there is a problem with one of the project files and the format that it has. not sure there is anything I can do without isolating the problem or position of the error within the xcode project file itself and having access to a reproducible sample.

bjhomer commented 5 years ago

I just ran into this as well. It can be easily reproduced by simply making a brand new project in Xcode 10.1 and trying to run --find-unused on it. I'll attach a sample project you can try it out with.

Dummy.zip

bjhomer commented 5 years ago

I believe I found the root cause: https://github.com/samdmarshall/pbPlist/pull/3

samdmarshall commented 5 years ago

Can you please attempt to install from HEAD and see if the issue persists? if not i'll cut a new release and can close this issue.

bjhomer commented 5 years ago

Yes, it does appear to resolve this particular issue. I'm having some other issues with pip3 on 10.14.3, but I'll file a separate issue for that.