Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure with BUILD_LIBRARY_FOR_DISTRIBUTION=YES #196

Open
chhetri-rahul opened this issue Aug 12, 2023 · 23 comments
Open

Build failure with BUILD_LIBRARY_FOR_DISTRIBUTION=YES #196

chhetri-rahul opened this issue Aug 12, 2023 · 23 comments

Comments

@chhetri-rahul
Copy link

chhetri-rahul commented Aug 12, 2023

When will the support for visionOS be provided, for both simulator and physical device?

We have a SDK which consumes swift-cryto as a package dependency (v 2.1.0). We are updating our codebase to support the new OS from Apple. The SDK builds for iOS and MacCatalyst on intel and M1 machines.

Right now when i build from cli with command:

xcodebuild -workspace MySDK.xcworkspace -configuration Debug -sdk xrsimulator build -derivedDataPath ./out -scheme MySDK -destination "generic/platform=visionOS Simulator,OS=latest,name=Apple Vision Pro" "ARCHS=\x86_64 \arm64

if fails with the error:

no such module 'CCryptoBoringSSL'
@_implementationOnly import CCryptoBoringSSL

@Lukasa
Copy link
Collaborator

Lukasa commented Aug 12, 2023

v2.1.0 is very old, it was released in April 2022. Can you update to 2.6.0 and tell me if this reproduces?

@chhetri-rahul
Copy link
Author

After updating to v2.6.0 we are getting the following compilation error

error-img

Here you suggested to change the build setting BUILD_LIBRARY_FOR_DISTRIBUTION as false which is not possible in our case.

And regarding the consumption of these APIs we are already importing using the @_implementationOnly import statement.

Can you please guide on how to fix this?

@Lukasa
Copy link
Collaborator

Lukasa commented Aug 17, 2023

You must change the build setting for swift-crypto to disable BUILD_LIBRARY_FOR_DISTRIBUTION: we do not have a stable ABI and we don't support this build mode.

You may subsequently link this library into a different library that you own which does have a stable ABI, which is where @_implementationOnly will be helpful.

@Lukasa
Copy link
Collaborator

Lukasa commented Aug 17, 2023

Additionally: are you actually using _CryptoExtras? If not, you could drop the dependency.

@chhetri-rahul
Copy link
Author

Changing the build setting BUILD_LIBRARY_FOR_DISTRIBUTION also didn't help and it fails with the same error

I had updated this setting for both the targets (Crypto, _CryptoExtras) like below:

Screenshot 2023-08-30 at 4 10 18 PM

Also, _CryptoExtras is required by us and cannot be removed. We use _RSA.Signing.Padding from this module.

Btw this error can be seen in a standalone project as well when we try to archive it by running cli command.

Anything else that we can try?

@Lukasa
Copy link
Collaborator

Lukasa commented Aug 30, 2023

Sorry, how do you reproduce this in a standalone project?

@chhetri-rahul
Copy link
Author

  1. Make a framework project from Xcode template, add the package dependency, include both Crypto and _CryptoExtras to your target.
  2. Have one file in your target where you @_implementationOnly import module is added.
  3. Run the following command on terminal

xcodebuild archive -configuration Release -sdk iphoneos -scheme MySwiftCryptoCheckSDK BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO -derivedDataPath ./gen/out -archivePath ./gen/Archive

@chhetri-rahul
Copy link
Author

Btw the failure is not related to visionOS, it fails for iphoneos as well (havent checked for other destinations) .

@Lukasa
Copy link
Collaborator

Lukasa commented Aug 30, 2023

So I believe that BUILD_LIBRARY_FOR_DISTRIBUTION=YES may be overriding the build setting in the package. Can you provide the build log?

@chhetri-rahul
Copy link
Author

archive-failed.txt

I noticed the archive commands succeeds when i remove BUILD_LIBRARY_FOR_DISTRIBUTION=YES from the command. But it is one thing we can't remove.

@Lukasa
Copy link
Collaborator

Lukasa commented Sep 4, 2023

Yeah, that setting is overriding your change to the Package. Why can't you change the build setting for the package?

@FredericJacobs FredericJacobs changed the title Support for visionOS Build failure with BUILD_LIBRARY_FOR_DISTRIBUTION=YES Sep 5, 2023
@FredericJacobs
Copy link
Member

Renaming the issue to reflect the issue is not related to visionOS

@chhetri-rahul
Copy link
Author

Yeah, that setting is overriding your change to the Package. Why can't you change the build setting for the package?

I did change the build setting for the Crypto and _CryptoExtras in my fork and used it in my code but still got the same error.

@Lukasa
Copy link
Collaborator

Lukasa commented Sep 6, 2023

Sorry, I meant to say: why does your project require setting BUILD_LIBRARY_FOR_DISTRIBUTION=YES on all targets in your project?

@chhetri-rahul
Copy link
Author

Not all the targets in the project require this setting, just two of them.

@Lukasa
Copy link
Collaborator

Lukasa commented Sep 7, 2023

Is there any reason you cannot set this setting only for those two?

@chhetri-rahul
Copy link
Author

@Lukasa can you help me tell how to set the build setting for individual targets?. Should i set this setting in xcode build settings ui and let terminal use the values from there or in command line i have to pass the setting to each target.

For the latter case how will the xcodebuild command look like.

@Lukasa
Copy link
Collaborator

Lukasa commented Sep 11, 2023

You would set this in the Xcode build settings UI for the specific targets.

@chhetri-rahul
Copy link
Author

Thanks @Lukasa i will try what you suggested.

I also found this when looking for a solution. The archive command succeeds with this change.
archive-success.txt

Will removing @inlineable like in above cause any kind of problem in our code?

@Lukasa
Copy link
Collaborator

Lukasa commented Sep 13, 2023

It may lead to worse performance, but that’s it

@chhetri-rahul
Copy link
Author

Thanks @Lukasa for being patient in answering all the questions i have and for actively replying.

The performance degrade youre saying is only during build time or when the code gets used when app is running?

Also I tried what you suggested above and it fixes the archive failure problem, the only thing i want to know now is that we have 6 targets in our workspace (framework targets, unit tests, app targets) the setting BUILD_LIBRARY_FOR_DISTRIBUTION=YES is just to be passed to the framework target right?.

We distribute xcframework so i guess only having this setting in framework target is enough but want your opinion on it.

@Lukasa
Copy link
Collaborator

Lukasa commented Sep 22, 2023

The performance degradation will be while the app is running.

And yes, you should only need to pass that value to the framework target.

@chhetri-rahul
Copy link
Author

Okay Thank you very much @Lukasa 🤝🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants