MakeAWishFoundation / SwiftyMocky

Framework for automatic mock generation. Adds a set of handy methods, simplifying testing. One of the best and most complete solutions, including generics support and much more.
MIT License
1.03k stars 104 forks source link

cannot decode object of class (SwiftActor) for key (NS.objects) because no class named "SwiftActor" was found #353

Open anwuna opened 1 year ago

anwuna commented 1 year ago

I consistently encounter the following error when executing mint run MakeAWishFoundation/SwiftyMocky generate from my project's root directory or when running the unit test target. Despite exhaustive troubleshooting attempts, the issue persists.


❌  Error: ShellOut encountered an error
Status code: 3
Message: "../.mockyF31F8ECF-FEAF-4D67-B756-3F750DC4353E/.template.swifttemplate: 2023-09-08 07:43:16.986 zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAcxWnbQNG8%3D[59146:1061858] *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (SwiftActor) for key (NS.objects) because no class named "SwiftActor" was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target). If the class was renamed, use setClassName:forClass: to add a class translation mapping to NSKeyedUnarchiver'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007ff80e2b618a __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007ff80dddc42b objc_exception_throw + 48
    2   Foundation                          0x00007ff80f5760b1 -[NSCoder __failWithException:] + 165
    3   Foundation                          0x00007ff80f153b5d -[NSCoder(Exceptions) __failWithExceptionName:errorCode:format:] + 378
    4   Foundation                          0x00007ff80f07b8e3 _decodeObjectBinary + 654
    5   Foundation                          0x00007ff80f07df11 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1686
    6   Foundation                          0x00007ff80f09561d -[NSArray(NSArray) initWithCoder:] + 161
    7   Foundation                          0x00007ff80f07c1aa _decodeObjectBinary + 2901
    8   Foundation                          0x00007ff80f07b534 _decodeObject + 152
    9   Foundation                          0x00007ff80f07b41f -[NSKeyedUnarchiver decodeObjectForKey:] + 162
    10  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d1e7336 $sSo7NSCoderC15SourceryRuntimeE11maybeDecode33_59ED7E9A0473E0D69ACA0F3EDA062D19LL6forKeyxSgSS_tlF + 198
    11  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d1e776c $sSo7NSCoderC15SourceryRuntimeE6decode6forKeyxSgSS_tlF + 44
    12  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d2597e8 $s15SourceryRuntime16FileParserResultC5coderACSgSo7NSCoderC_tcfc + 1080
    13  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d25ad48 $s15SourceryRuntime16FileParserResultC5coderACSgSo7NSCoderC_tcfcTo + 40
    14  Foundation                          0x00007ff80f07c1aa _decodeObjectBinary + 2901
    15  Foundation                          0x00007ff80f07b534 _decodeObject + 152
    16  Foundation                          0x00007ff80f07b41f -[NSKeyedUnarchiver decodeObjectForKey:] + 162
    17  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d1e7336 $sSo7NSCoderC15SourceryRuntimeE11maybeDecode33_59ED7E9A0473E0D69ACA0F3EDA062D19LL6forKeyxSgSS_tlF + 198
    18  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d1e776c $sSo7NSCoderC15SourceryRuntimeE6decode6forKeyxSgSS_tlF + 44
    19  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d27ff95 $s15SourceryRuntime15TemplateContextC5coderACSgSo7NSCoderC_tcfc + 277
    20  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d2806e8 $s15SourceryRuntime15TemplateContextC5coderACSgSo7NSCoderC_tcfcTo + 40
    21  Foundation                          0x00007ff80f07c1aa _decodeObjectBinary + 2901
    22  Foundation                          0x00007ff80f07b534 _decodeObject + 152
    23  Foundation                          0x00007ff80f07b41f -[NSKeyedUnarchiver decodeObjectForKey:] + 162
    24  Foundation                          0x00007ff80f186647 +[NSKeyedUnarchiver unarchiveObjectWithFile:] + 138
    25  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d2824a3 $sSo13NSProcessInfoC15SourceryRuntimeE7contextAC15TemplateContextCSgvg + 227
    26  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d2b3ee3 main + 4323
    27  dyld                                0x00007ff80de0941f start + 1903
)
libc++abi: terminating due to uncaught exception of type NSException"
Output: "Using configuration file at '../.mockyF31F8ECF-FEAF-4D67-B756-3F750DC4353E/.config.yml.tmp'
Scanning sources...
Found 2241 types in 1277 files, 12 changed from last run.
Files changed:
../.build/checkouts/apollo-ios/Sources/GitHubAPI/GitHubAPI/Sources/Schema/Objects/RepoConfigEnableCollaboratorsOnlyAuditEntry.graphql.swift
../.build/checkouts/apollo-ios/Sources/GitHubAPI/GitHubAPI/Sources/Schema/Objects/TeamRemoveMemberAuditEntry.graphql.swift
../.build/checkouts/apollo-ios/Sources/GitHubAPI/GitHubAPI/Sources/Schema/Objects/OrgInviteMemberAuditEntry.graphql.swift
../.build/checkouts/apollo-ios/Sources/GitHubAPI/GitHubAPI/Sources/Schema/Objects/RepoAddMemberAuditEntry.graphql.swift
../.build/checkouts/apollo-ios/Sources/GitHubAPI/GitHubAPI/Sources/Schema/Objects/RepoConfigEnableAnonymousGitAccessAuditEntry.graphql.swift
../.build/checkouts/apollo-ios/Sources/GitHubAPI/GitHubAPI/Sources/Schema/Objects/RepoConfigEnableContributorsOnlyAuditEntry.graphql.swift
../.build/checkouts/apollo-ios/Sources/GitHubAPI/GitHubAPI/Sources/Schema/Objects/OrgConfigDisableCollaboratorsOnlyAuditEntry.graphql.swift
../.build/checkouts/apollo-ios/Sources/GitHubAPI/GitHubAPI/Sources/Schema/Objects/BaseRefForcePushedEvent.graphql.swift
../.build/checkouts/apollo-ios/Sources/GitHubAPI/GitHubAPI/Sources/Schema/SchemaConfiguration.swift
../.build/checkouts/apollo-ios/Sources/GitHubAPI/GitHubAPI/Sources/Schema/SchemaMetadata.graphql.swift
../.build/checkouts/apollo-ios/Sources/UploadAPI/UploadAPI/Sources/Schema/SchemaConfiguration.swift
../.build/checkouts/apollo-ios/Sources/UploadAPI/UploadAPI/Sources/Schema/SchemaMetadata.graphql.swift
Loading templates...
Loaded 1 templates.
Generating code...
error: ../.mockyF31F8ECF-FEAF-4D67-B756-3F750DC4353E/.template.swifttemplate: 2023-09-08 07:43:16.986 zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAcxWnbQNG8%3D[59146:1061858] *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (SwiftActor) for key (NS.objects) because no class named "SwiftActor" was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target). If the class was renamed, use setClassName:forClass: to add a class translation mapping to NSKeyedUnarchiver'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007ff80e2b618a __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007ff80dddc42b objc_exception_throw + 48
    2   Foundation                          0x00007ff80f5760b1 -[NSCoder __failWithException:] + 165
    3   Foundation                          0x00007ff80f153b5d -[NSCoder(Exceptions) __failWithExceptionName:errorCode:format:] + 378
    4   Foundation                          0x00007ff80f07b8e3 _decodeObjectBinary + 654
    5   Foundation                          0x00007ff80f07df11 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1686
    6   Foundation                          0x00007ff80f09561d -[NSArray(NSArray) initWithCoder:] + 161
    7   Foundation                          0x00007ff80f07c1aa _decodeObjectBinary + 2901
    8   Foundation                          0x00007ff80f07b534 _decodeObject + 152
    9   Foundation                          0x00007ff80f07b41f -[NSKeyedUnarchiver decodeObjectForKey:] + 162
    10  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d1e7336 $sSo7NSCoderC15SourceryRuntimeE11maybeDecode33_59ED7E9A0473E0D69ACA0F3EDA062D19LL6forKeyxSgSS_tlF + 198
    11  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d1e776c $sSo7NSCoderC15SourceryRuntimeE6decode6forKeyxSgSS_tlF + 44
    12  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d2597e8 $s15SourceryRuntime16FileParserResultC5coderACSgSo7NSCoderC_tcfc + 1080
    13  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d25ad48 $s15SourceryRuntime16FileParserResultC5coderACSgSo7NSCoderC_tcfcTo + 40
    14  Foundation                          0x00007ff80f07c1aa _decodeObjectBinary + 2901
    15  Foundation                          0x00007ff80f07b534 _decodeObject + 152
    16  Foundation                          0x00007ff80f07b41f -[NSKeyedUnarchiver decodeObjectForKey:] + 162
    17  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d1e7336 $sSo7NSCoderC15SourceryRuntimeE11maybeDecode33_59ED7E9A0473E0D69ACA0F3EDA062D19LL6forKeyxSgSS_tlF + 198
    18  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d1e776c $sSo7NSCoderC15SourceryRuntimeE6decode6forKeyxSgSS_tlF + 44
    19  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d27ff95 $s15SourceryRuntime15TemplateContextC5coderACSgSo7NSCoderC_tcfc + 277
    20  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d2806e8 $s15SourceryRuntime15TemplateContextC5coderACSgSo7NSCoderC_tcfcTo + 40
    21  Foundation                          0x00007ff80f07c1aa _decodeObjectBinary + 2901
    22  Foundation                          0x00007ff80f07b534 _decodeObject + 152
    23  Foundation                          0x00007ff80f07b41f -[NSKeyedUnarchiver decodeObjectForKey:] + 162
    24  Foundation                          0x00007ff80f186647 +[NSKeyedUnarchiver unarchiveObjectWithFile:] + 138
    25  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d2824a3 $sSo13NSProcessInfoC15SourceryRuntimeE7contextAC15TemplateContextCSgvg + 227
    26  zS3a4gNX3EPugaiCq4oLj3Jfvo4zLtXIBAc 0x000000010d2b3ee3 main + 4323
    27  dyld                                0x00007ff80de0941f start + 1903
)
libc++abi: terminating due to uncaught exception of type NSException

Also, I'm using SwiftyMocky CLI v4.1.0

IronLeash commented 11 months ago

Could you resolve this issue? We have in the team the same problem and could not resolve it

IronLeash commented 11 months ago

We still have the issue, as walkthrough we call in our scripts mint run swiftymocky generate --disableCache @anwuna, did you find the source of the problem?