8

I'm using MetaCodable macro in my project, installed via SwiftPM, when I try to build the project using Microsoft Azure's Pipeline using my local machine as a run agent (MBP M1 Max - Sonoma - XCode 15), I get this error message:

error: external macro implementation type 'CodableMacroPlugin.CodedAt' could not be found for macro 'CodedAt'

Some folks here suggest to add -external-plugin-path to other Swift flags in build settings, but that doesn't solve the issue.

And in this thread some also suggests to add -load-plugin-library, or -plugin-path, or -load-plugin-executable to other Swift flags, I tried every option of these using the value: $(BUILT_PRODUCTS_DIR)#MetaCodable but I got the same error with every CI build.

I also get this warning in the Azure's Pipeline build log:

"output": "<unknown>:0: warning: compiler plugin not loaded: '/Users/my_user_name/Library/Developer/Xcode/DerivedData/MyProject/Build/Products/Release/CodableMacroPlugin; failed to initialize /Users/my_user_name/vsts-agent-osx-x64-2.183.1/_work/9/MyProject/Data/Models/SomeModel.swift

Any thoughts about this are appreciated.

6
  • 1
    Are you facing this issue only in CI or when you build your project locally as well? Also, can you provide Minimal Reproducible Example showing the issue? Commented Oct 30, 2023 at 9:02
  • it's happening on the CI only, local build is working fine. I can't provide an example with Microsoft's Azure CI log here
    – JAHelia
    Commented Oct 30, 2023 at 11:07
  • 1
    Few things you can try: Try building from xcodebuild command line, try some of the solutions suggested on swift forums: forums.swift.org/t/…, forums.swift.org/t/… Commented Oct 30, 2023 at 13:43
  • xcodebuild command runs without problems on my machine: xcodebuild -project /Users/xxxxx/MyProject.xcodeproj -scheme MyScheme -configuration Release -destination 'generic/platform=iOS' build but the Microsoft Azure's Pipeline still fails. I even tried to add this command as a CI step (of type Terminal) in Microsoft Azure (in replacement of the original CI build step) but it didn't go through due to the same error
    – JAHelia
    Commented Nov 2, 2023 at 7:27
  • @neilaur not yet
    – JAHelia
    Commented Feb 20 at 12:33

2 Answers 2

4

I had the same issue and after hours found the solution on my side.

For our library we had to define a macOS support version besides iOS for SwiftSyntaxMacros. Locally we used MacOS 14 and set it to 14. On the Server we were running 13.X. We did not get a error for the MacOS support version only "error: external macro implementation type 'foo' could not be found for macro 'foo'".

After setting it to MacOS 12 the issue was gone:

platforms: [.macOS(.v12), .iOS(.v15)],

I hope this is useful for you. Online I found no solutions for this issue.

1
  • the macro we are using has the macOS support, it's added like this: .macOS(.v10_15)
    – JAHelia
    Commented Nov 1, 2023 at 6:15
4

If your project works fine in Xcode, but you're seeing this issue only from an xcodebuild command or other CI pipeline tool. This can be caused by the -sdk flag you've specified (e.g. -sdk iphonesimulator).

Simply REMOVE:

-sdk iphonesimulator

From your xcodebuild command

2
  • this does not solve the problem
    – JAHelia
    Commented Mar 19 at 12:41
  • I was seeing a similar issue to the one above. I was using -sdk iphonesimulator, but removing it would try to build the iOS app for my Mac, which doesn't work either. However, in my case, I just needed a build to succeed (I was analyzing the build log), so switching to -sdk iphoneos fixed the problem.
    – mikepj
    Commented Jun 25 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.