Git Product home page Git Product logo

Comments (3)

choulepoka avatar choulepoka commented on May 27, 2024 3

I had a similar issues, and here is what i do

1st thing - Custom Sourcery

I use a custom sourcery, installed directly using Homebrew

brew install sourcery

In my mockfile, i add at the top:

sourceryCommand: sourcery
sourceryTemplate: null

Now it is using the latest sourcery

2nd: sed commands

I execute 2 sed commands that updates the generated code to be @unchecked Sendable

Here is the snippet of code I use to generate my mocks

mint run swiftymocky autoimport
mint run swiftymocky generate
find . -type f -name Mock.generated.swift -exec sed -i '' "s/Mock {/Mock, @unchecked Sendable {/g" {} \;
find . -type f -name Mock.generated.swift -exec sed -i '' "s/enum MethodType {/enum MethodType: @unchecked Sendable {/g" {} \;

Hope this helps!

from swiftymocky.

MarioJ94 avatar MarioJ94 commented on May 27, 2024

Hi @choulepoka! Thanks for the response! First of all, mock generation is now working thanks to your recommendations!

Let me explain what we had:
We have two Mockfile files, the main Mockfile for the app for the .pbxproj ([...]/app) and another for the Package ([...]/app/Packages/PackageName).
In our main (app) Mockfile we have

sourceryCommand: null
sourceryTemplate: null

This makes it use Sourcery v1.6.0 when generating the app mocks, which is the dependency we are including in our Podfile for the tests target

def unit_testing_pods
  pod 'SwiftyMocky', '4.1.0'
  pod 'Sourcery', '1.6.0'
end

On the other hand, in our Package's Mockfile we had...

sourceryCommand: mint run sourcery
sourceryTemplate: null

... which forced the usage of Sourcery 1.9.2 since it always checks for last version. Changing it to sourceryCommand: sourcery makes it use Sourcery 1.8.2 because it is the one I have globally linked.

🌱 Installed mint packages:
  Sourcery
    - 1.6.0
    - 1.8.2 *
    - 1.9.0
    - 1.9.1
    - 1.9.2

Changing it to 1.6.0 (the one used for the app's Mockfile) makes it fail, which I will try to understand at some point.

Running at: /Users/userName/Workspace/Repositories/repoName/app/Packages/PackageName
Using template from SwiftPM
Processing mock: PackageNameTests ...
Using sourcery command: sourcery
❌  Error: ShellOut encountered an error
Status code: 134
Message: "dyld[76332]: Library not loaded: @rpath/lib_InternalSwiftSyntaxParser.dylib
  Referenced from: <B097698B-C1F6-34E5-8843-A28955C3ECFA> /Users/userName/.mint/packages/github.com_krzysztofzablocki_Sourcery/build/1.6.0/sourcery
  Reason: tried: '/Users/userName/.mint/packages/github.com_krzysztofzablocki_Sourcery/build/1.6.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/userName/.mint/packages/github.com_krzysztofzablocki_Sourcery/build/1.6.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/userName/.mint/packages/github.com_krzysztofzablocki_Sourcery/build/1.6.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/userName/.mint/packages/github.com_krzysztofzablocki_Sourcery/build/1.6.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)
/bin/bash: line 1: 76332 Abort trap: 6           sourcery --config "/Users/userName/Workspace/Repositories/repoName/app/Packages/PackageNameTests/.mocky5FCB09FA-7382-47FC-A33B-3552795AD436/.config.yml.tmp""
Output: ""

But now that I take a look at the Mockfile format explained here https://github.com/MakeAWishFoundation/SwiftyMocky/blob/master/guides/Mockfile.md, I guess that (since we have both the Package and the app code in the same repository) we should just have a single Mockfile with the different Mock configurations.

Summary:

  • I have different Sourcery version in my machine
  • The Sourcery version working for the Package is the 1.8.2.
  • Might be a good idea to move everything to the same Mockfile (?)

I will take this day and the next to check if everything works properly before marking this as closed to ensure I only needed to define the Mockfile properly without having to perform any other command.

Thanks @choulepoka !!!

from swiftymocky.

MarioJ94 avatar MarioJ94 commented on May 27, 2024

Using the autoimport seems to include some imports. With those imports, latest version of Sourcery v1.9.2 seems able to generate the mocks, so there is no need to change the Mockfile from sourceryCommand: mint run sourcery to sourceryCommand: sourcery, although we sometimes got some errors, re-running it would make it work.

With that said, as you suggested, we will use the local sourcery version because we think using the local version helps with stability. Thank you very much for your help!

from swiftymocky.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.