Conditionally link a package excluding Catalyst platform

Hi! I want to add some libs provided by Amplify package conditionally based on architecture. The goal is to exclude Mac Catalyst, because it's unsupported by that package. So, I'm trying to do it with OTHER_LDFLAGS following this example on SO. I configured target dependency to build Amplify, AWSPinpointAnalyticsPlugin and AWSCognitoAuthPlugin (They go within Amplify package).



OTHER_LDFLAGS[sdk=iphone*] = $(inherited) -library "Amplify" -library "AWSPinpointAnalyticsPlugin" -library "AWSCognitoAuthPlugin"

It results into the build errors:

clang: error: no such file or directory: 'Amplify'

Obviously it's a wrong way, because Amplify package isn't compiled to libraries. It producing multiple .swiftmodule files in that build directory. So the question is how to link them?

Can't edit the previous question, so created a new one. Also can't delete the old question, it's probably against GDPR.

Some updates here. I discovered that in order to link a swfit module you need to use this commands in OTHER_LDFLAGS:
-Xlinker -add_ast_path -Xlinker $(BUILT_PRODUCTS_DIR)/"MyModule.swiftmodule"
Actually this is a HUGE misguide that OTHER_LDFLAGS actually passed to clang, not to ld. :crazy_face:

I was able to solve my particular issue by switching to cocoapods. With cocoapods-catalyst-support I excluded catalyst pretty easily. The question regarding Swift PM is still open. I hope Apple will add platform filter later.

1 Like