apple / swift-numerics

Advanced mathematical types and functions for Swift
Apache License 2.0
1.69k stars 147 forks source link

`** ARCHIVE FAILED **` due to `_NumericsShims` missing #267

Open maximkhatskevich opened 1 year ago

maximkhatskevich commented 1 year ago

Despite _NumericsShims is NOT intended to be part of public API, attempt to archive any of the publicly exposed modules results into failure.

The command to execute in CLI:

xcodebuild archive -scheme Numerics -destination "generic/platform=iOS" -archivePath "build/ios-device" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES

it fails with underlaying error being:

.../Library/Developer/Xcode/DerivedData/swift-numerics-dgyhdelhvghturdxbqtbuzsazzjo/Build/Intermediates.noindex/ArchiveIntermediates/Numerics/IntermediateBuildFilesPath/swift-numerics.build/Release-iphoneos/RealModule.build/Objects-normal/arm64/RealModule.swiftinterface:6:8: error: no such module '_NumericsShims'

Same happens when try to archive in similar fashion any framework (does not matter if it's a Swift Package or created via Xcode framework), WHERE swift-numerics is in the dependencies list.

NOTE: in case of a framework that is built using Xcode, Archive via Xcode GUI works fine with same settings set in Xcode build settings (SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES) - archive works fine. I'd resort to that option, but it does not allow to archive for iOS simulator and I really want to put it in a script for automated execution.

Is it expected/intended behaviour? Any clarifications/suggestions would be much appreciated!

Xcode version 14.3.1

maximkhatskevich commented 1 year ago

A bit more context. This issue happens when I use https://github.com/apple/swift-openapi-generator (which uses this package as dependency) as development time plugin, but it interferes with the build/archive process anyway. If I switch to manual CLI invocation for the generator - I do not need to mention swift-openapi-generator anywhere in dependencies, and this package is not a dependency anymore, hence it does not block my archive process, which means my problem is solved. But I am curious nonetheless if it is supposed to be this way or is it a bug? What if I want to use this package as dependency in my package and then need to archive a binary version?

stephentyrone commented 1 year ago

It's not totally clear if this is a project issue or an Xcode build issue, or if this is simply a configuration that we can't support yet, but we're taking a look at it.

maximkhatskevich commented 1 year ago

I agree, it might be Xcode build system issue, indeed. Thank you for looking into it!

ptliddle commented 7 months ago

Did this ever get resolved or was a workaround found? I just hit this same issue when validating my build for upload to the AppStore. Numerics is a dependency in mlx-swift in my case https://github.com/ml-explore/mlx-swift. I also run into this issue with swift-async-algorithms where the swift-collections was causing the same issue. Here's a link to the issue and a current workaround. https://github.com/apple/swift-collections/issues/364

Intiserahmed commented 3 months ago

Hi @ptliddle , May I know how you have solved the Numerics issue? I have also having the same issue '_NumericsShims'

Screenshot 2024-08-25 at 9 31 38 PM