uber / mockolo

Efficient Mock Generator for Swift
Apache License 2.0
813 stars 86 forks source link

Mock generation fails when loading lib_InternalSwiftSyntaxParser.dylib #194

Closed fummicc1 closed 2 years ago

fummicc1 commented 2 years ago

What Happened

Hello, I am new to mockolo but this library is very great as a mock generator. After I installed mockolo via Mint, I ran the following run comamnd from Terminal and got the error log.

Environments

Run Command

mint run mockolo -s ./Pog/Pog -d ./Pog/Pog/Mock/Generated

Log

🌱 Finding latest version of mockolo
🌱 Running mockolo 1.7.0...
dyld[30649]: Library not loaded: @rpath/lib_InternalSwiftSyntaxParser.dylib
  Referenced from: <567E5949-DBDB-340F-8C8A-FC61515EE9DC> /Users/fumiyatanaka/.mint/packages/github.com_uber_mockolo/build/1.7.0/mockolo
  Reason: tried: '/Users/fumiyatanaka/.mint/packages/github.com_uber_mockolo/build/1.7.0/lib_InternalSwiftSyntaxParser.dylib' (no such file),
 '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), 
'/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), 
'/Users/fumiyatanaka/.mint/packages/github.com_uber_mockolo/build/1.7.0/lib_InternalSwiftSyntaxParser.dylib' (no such file), 
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), 
'/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), 
'/System/Volumes/Preboot/Cryptexes/OS@rpath/lib_InternalSwiftSyntaxParser.dylib' (no such file), 
'/Users/fumiyatanaka/.mint/packages/github.com_uber_mockolo/build/1.7.0/lib_InternalSwiftSyntaxParser.dylib' (no such file), 
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), 
'/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), 
'/Users/fumiyatanaka/.mint/packages/github.com_uber_mockolo/build/1.7.0/lib_InternalSwiftSyntaxParser.dylib' (no such file), 
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file), 
'/System/Volumes/Preboot/Cryptexes/OS/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/lib_InternalSwiftSyntaxParser.dylib' (no such file),
 '/usr/local/lib/lib_InternalSwiftSyntaxParser.dylib' (no such file), 
'/usr/lib/lib_InternalSwiftSyntaxParser.dylib' (no such file, not in dyld cache)

Working Directory

スクリーンショット 2022-07-09 10 40 51
fummicc1 commented 2 years ago

Note: I think this error occures when swift toolchain is for Swift 5.7. Because I can generate mock by re-compiling mockolo locally, where Xcode14 beta is installed.

Tips: I can avoid this error by the following way.

  1. Clone this mockolo repository
  2. Run swift build -c release with current directory mockolo. (Notice that xcodebuild -p shows Xcode14 beta path.)
  3. run executable file.
sidepelican commented 2 years ago

This should be fixed by mint. mockolo has dependency of @rpath/lib_InternalSwiftSyntaxParser.dylib(you can check this by otool -L <your/mockolo/path>) , and swift build puts lib_InternalSwiftSyntaxParser.dylib to the same directory to mockolo. mint copies mockolo to mint's cache directory but doesn't copy lib_InternalSwiftSyntaxParser.dylib. so lib_InternalSwiftSyntaxParser.dylib cannot found with @rpath.

fummicc1 commented 2 years ago

Thank you, sidepelican, for your reply. Actually I am not familiar with dylib, so I am probing the origin of that problem. (I think install_name_tool may be helpful 👀 to overwrite rpath of dylib... or I have mint directly copy all files in @executable_path to .mint/packages/.../build folder.)

I think this comment on Mint may be related with this issue.


This codes is where copying executables of target-package(like mockolo, LicensePlist and so on) to .mint/packages. Because only copying executable ones, This problem may occure, I think.