swift icon indicating copy to clipboard operation
swift copied to clipboard

Version-specific Package.swift file causes Danger to not load plugins

Open JosephDuffy opened this issue 3 years ago • 2 comments

This may be out of scope but it took me a while to debug so I wanted to open an issue for it:

I only run Danger on CI so the main Package.swift does not include Danger, but rather a specific [email protected] file contains Danger.

I can build Danger with the usual swift build --target DangerDependencies but when running (e.g. swift run danger-swift ci) I get an error:

Error Message
JIT session error: Symbols not found: [ _$s23SwiftChecksDangerPlugin4FileMp, _$s23SwiftChecksDangerPlugin21InfoPlistFileProviderVN, _$s23SwiftChecksDangerPlugin21InfoPlistFileProviderVAA0gH0AAWP, _$s23SwiftChecksDangerPlugin11VersionFileVN, _$s23SwiftChecksDangerPlugin11VersionFileVAA0F0AAWP, _$s23SwiftChecksDangerPlugin11VersionFileV4path11interpreterACSS_AC11InterpreterOtcfC, 
_$s23SwiftChecksDangerPlugin13InfoPlistFileV0F3KeyV13versionNumberAEvau, _$s23SwiftChecksDangerPlugin12FileProviderMp, _$s23SwiftChecksDangerPlugin0aB0V5check13fileProviders5files11versionKindySayAA12FileProvider_pG_SayAA0K0_pGSStFZ, _$s23SwiftChecksDangerPlugin21InfoPlistFileProviderVMn, _$s23SwiftChecksDangerPlugin21InfoPlistFileProviderV15discoveryMethod8plistKey07projectG4PathA2C09DiscoveryJ0O_AA0efG0V0fL0VSStcfC, _$s23SwiftChecksDangerPlugin11VersionFileVMn ]
Failed to materialize symbols: { (0x7fc4bddb9540, { ___swift_instantiateConcreteTypeFromMangledName, _$s23SwiftChecksDangerPlugin0aB0V5check13fileProviders5files11versionKindySayAA12FileProvider_pG_SayAA0K0_pGSStFZfA_, _$s23SwiftChecksDangerPlugin11VersionFileV11InterpreterOWOe, _got.$s6Danger6GitHubVMn, __swift_FORCE_LOAD_$_swiftCoreGraphics_$__tmp_dangerfile, _got.$s23SwiftChecksDangerPlugin11VersionFileVMn, _symbolic ______p 23SwiftChecksDangerPlugin12FileProviderP, _$s15_tmp_dangerfile11projectNameSSvp, _got.$s10Foundation4DateVMn, _got.$s23SwiftChecksDangerPlugin4FileMp, _symbolic _____Sg 6Danger6GitHubV9MilestoneV, _$s15_tmp_dangerfile20checkProjectVersionsyyF, _$s23SwiftChecksDangerPlugin21InfoPlistFileProviderV15DiscoveryMethodOWOe, _$s6Danger9SwiftLintO4lint_6inline10configFile6strict5quiet13swiftlintPathSayAA0bC9ViolationVGAC0C5StyleO_SbSSSgS2bAOtFZfA3_, _$s23SwiftChecksDangerPlugin12FileProvider_pMD, _$s6Danger9SwiftLintO4lint_6inline10configFile6strict5quiet13swiftlintPathSayAA0bC9ViolationVGAC0C5StyleO_SbSSSgS2bAOtFZfA_, _$s6Danger6GitHubVSgWOc, __swift_FORCE_LOAD_$_swiftDispatch_$__tmp_dangerfile, __swift_FORCE_LOAD_$_swiftDarwin_$__tmp_dangerfile, _$s10Foundation4DateVSgMD, __swift_FORCE_LOAD_$_swiftCoreFoundation_$__tmp_dangerfile, _symbolic _____ 23SwiftChecksDangerPlugin21InfoPlistFileProviderV, _$s15_tmp_dangerfile18checkSwiftVersionsyyF, _$s6Danger6GitHubV9MilestoneVSgMD, _main, _$s6Danger6GitHubVSgMD, _$ss26DefaultStringInterpolationVWOh, _$s6Danger9SwiftLintO4lint_6inline10configFile6strict5quiet13swiftlintPathSayAA0bC9ViolationVGAC0C5StyleO_SbSSSgS2bAOtFZfA1_, _symbolic _____Sg 6Danger6GitHubV, _$s15_tmp_dangerfile4isPRSbvp, _symbolic ______p 23SwiftChecksDangerPlugin4FileP, _symbolic _____Sg 10Foundation4DateV, __swift_FORCE_LOAD_$_swiftXPC_$__tmp_dangerfile, _$s6Danger6GitHubVSgWOh, _$s6Danger6GitHubVWOh, _got.$s6Danger6GitHubV9MilestoneVMn, __swift_FORCE_LOAD_$_swiftObjectiveC_$__tmp_dangerfile, _$s6Danger9SwiftLintO0C5StyleOWOe, _$s6Danger9SwiftLintO4lint_6inline10configFile6strict5quiet13swiftlintPathSayAA0bC9ViolationVGAC0C5StyleO_SbSSSgS2bAOtFZfA2_, _got.$s23SwiftChecksDangerPlugin12FileProviderMp, ___swift_project_value_buffer, _$sSSWOh, _$s23SwiftChecksDangerPlugin4File_pMD, _symbolic _____ 23SwiftChecksDangerPlugin11VersionFileV, _got.$s23SwiftChecksDangerPlugin21InfoPlistFileProviderVMn, __swift_FORCE_LOAD_$_swiftFoundation_$__tmp_dangerfile, _$s6Danger9SwiftLintO4lint_6inline10configFile6strict5quiet13swiftlintPathSayAA0bC9ViolationVGAC0C5StyleO_SbSSSgS2bAOtFZfA4_, ___swift_allocate_value_buffer, _$s15_tmp_dangerfile6danger6Danger0D3DSLVvp, __swift_FORCE_LOAD_$_swiftIOKit_$__tmp_dangerfile }) }

SwiftChecksDangerPlugin is the name of my plugin.

To fix this I've added a comment to my Package.swift:

// Needed to make Danger work: .library(name: "DangerDeps",

This seems to satisfy the lookup that Danger performs.

JosephDuffy avatar Feb 13 '21 23:02 JosephDuffy

Unfortunately there is no support yet for multiple Package.swift, Danger searches for the dependencies library into the Package.swift, so if it doesn't find any library won't trigger the build of the library and won't link it to the Dangerfile compilation. Would be an interesting feature though.

f-meloni avatar Feb 14 '21 16:02 f-meloni

I'm happy for this to be left as an unsupported feature, but thought it might be useful for other people running in to the same issue.

I took a look and didn't see an immediately obvious place this could be easily added.

For my use case I will move Danger to a separate directory/package once #406 has been released and this will be fully resolved for me.

JosephDuffy avatar Feb 15 '21 22:02 JosephDuffy