Using TCA linked as a dynamic framework, when Archiving my macOS app I’m getting an error from SwiftNavigation:
External macro implementation type 'PerceptionMacros.PerceptibleMacro' could not be found for macro 'Perceptible()'
Expectation
Not getting this error
Context
Tuist version: 4.32.0
I was trying to Archive my app for the first time and realized I wasn’t able to. I tried cleaning up derived data and all that other stuff to no avail.
This error seems to be quite common (I’ve seen it here or there in the past couple months in various Tuist / TCA / Xcode versions). Here’s a discussion from the TCA repo:
Unfortunately none of the situations people were encountering the error in seemed relevant. My configuration names are Debug and Release, I haven’t touched them.
Other issues seem to be blocking building in any configuration, which is not the case for me. The issue only seems to happen when Archiving.
Some seemingly pertinent information would be that I’m using Tuist’s dependency handling, not SPM. I chose to link all dependencies (and pertinent transitive dependencies) as dynamic frameworks, as that’s apparently the only way to get Xcode Previews to work using Tuist’s dependency management.
The products I’ve set to be linked as frameworks are the ones needed to satisfy Tuist’s warnings when generating the project, and runtime warnings about duplicate symbols.
Release builds seem to work as I can Profile my application just fine, so it’s not that.
Another thing I do that might be relevant is that I set EXCLUDED_ARCHS = x86_64 on all my targets as well as the dependencies (I can only build on arm64).
I use Swift 6.0 and Xcode 16.1
Reproduction (mandatory for problems)
I don’t have a minimal reproduction yet as I don’t have the time to drill into it more than I already have at this point, but if no one has any pointers I’ll try later on.
Apologies for that issue that you came across. I read through the issue, and tried to reproduce it in this branch in one of the existing fixtures, fixtures/app_with_composable_architecture, but had no success.
Would you mind taking a look at that project and try to reproduce the issue there? For convenience, I placed an archive.sh script in the directory of the fixture. The project consists of an app, which depends on two dynamic frameworks, both of which have a dependency on ComposableArchitecture.
If you are a bit limited in time, I can also take your pointers and continue trying until we can find out the root cause.
I checked out the branch and attempted to get the setup as close to mine as possible. It does archive fine (though I use the Xcode command instead of the script). I’ve made a few changes:
App and Frameworks need the macOS destination.
I added the EXCLUDED_ARCHS setting to the base project settings, and to the base project settings in PackageSettings in Package.swift
I also run Swift 6, so I set SWIFT_VERSION to 6.0 at the project base settings, and // swift-tools-version: 6.0 in Package.swift
With all this I’m getting errors in SwiftSyntax similar in the file SyntaxExpressibleByStringInterpolationConformances.swift like:
'retroactive' attribute does not apply; 'ExpressibleByStringInterpolation' is declared in this module
I remember this issue from a little while ago, but somehow I overcame it in my project. I don’t have them anymore. Maybe we should try to get around that before we continue?
Well this is embarrassing.
One thing I neglected to mention because I didn’t think it was that important was that I set ENABLE_USER_SCRIPT_SANDBOXING to true on dependency project settings in order to silence Xcode’s recommendation warning to enable it in the generated dependency projects.
In a desperate effort I removed it and tried archiving again, and it worked.
Indeed adding this setting to fixture causes Archiving to fail as well.
Very happy I was able to find the cause. Not sure if this is something you’re interested in fixing (if it’s even possible), come to think of it I’m sure there’s a reason it’s not enabled by default for dependencies.
I also set DEFINES_MODULE to false on dependencies as I think as long as they don’t include Clang modules there’s no need to have it enabled (also to silence Xcode’s recommendation warning).
Apologies, I should have provided more context. Thank you for your time thus far!
And the best part of this is that search engines should (hopefully) index this and capture it as an answer for anyone running into something similar in the future