-
Notifications
You must be signed in to change notification settings - Fork 61
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 QRCode as an SDK dependency #32
Comments
Hi @vlasty-proglove. Can you send me a simple example project that shows the issue? I'd like to actually see the issue first hand as I'm not fully understanding the scope of your issue. Where is the name collision occurring, and with what? Is it possible to explicitly import class(es) out of the QRCode package to work around the name collisions? Like this - https://stackoverflow.com/a/67644981/146361 |
Hi @dagronf, yes, here are some examples from the command line when I try to build it using "xcodebuild" command. note: 'QRCode' declared here error: 'QRCodeEngine' is not a member type of class 'QRCode.QRCode' error: 'BoolMatrix' is not a member type of class 'QRCode.QRCode' This is when I tried the approach from the link that you provided, using The error is the same when using "import QRCode". Maybe there is something I am missing in the xcodebuild command, because I can build it through Xcode, but not when I want to create an archive, and then an xcframework. The framework is written in Swift but does support Obj-C. And as I said, forking and renaming the library in Package.swift file resolved my problem |
I've spent a bit of time trying to reproduce the issue with no luck. Can you please attach a minimal example project that shows the error? The information you've sent has not given any insight as to how your project is set up so I'm having issues understanding the underlying problem. Also :-
|
I've tested multiple times and finally found the problem when setting up the project that I wanted to send you. I used this command initially: xcodebuild -scheme "TestFramework" -sdk iphonesimulator -configuration Release archive -archivePath "~/Desktop/TestFramework-iphonesimulator.xcarchive" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES The problem is with the override command BUILD_LIBRARY_FOR_DISTRIBUTION. If this is set in the Build Settings to be true, and not using it in the terminal command, it builds the framework and can be used in Xcframework. If the command is used in the terminal, then it creates a problem that I've described. Here is a simple project TestFramework that you can use to test it. I have put back the option to "No" in the Build Settings. Please try the first command and then enable the build settings option and try it without that command in the terminal. Nonetheless, we can close this. |
@vlasty-proglove good news that you found a workaround. After some more digging, I've uncovered an existing bug in the Swift forums for this issue that matches the error you're seeing. Annoyingly, it was raised back in 2019 and still doesn't have a fix. There have been suggestions but nothing concrete at this point. The problem arises because So that means that it seems like the only clean solution (ie workaround) at this point is to rename the module within the library as you've suggested. I'm thinking using QRCodeKit as the module name -- as I mentioned earlier it's a significant breaking change for this library so I'll need to think about how to best handle it. |
@dagronf Thanks for the assistance on this. If you want to build the xcframework using the command line, most people are using it with the I noticed that it was working ok when not overriding that option in the command line. The flow would look like this. Go to Xcode > Select Target > Build Settings and set Build Libraries For Distribution to Yes on the Release configuration (or even Debug if somebody is working with it). I haven't tried a Configuration script since I am not using those but will try it when I get the chance. |
Hi,
I am currently working on an SDK, and I need this framework as a dependency.
The problem I am having is that it will not build as a dependency because of some name collisions.
This problem is only when building the framework in my case also an xcframework and I have QRCode as a dependency.
Mainly, the problem is that the library's name is the same as the main public class (QRCode).
The solution is to rename the library to for example "QRCodeLibrary", and also the Source folder to "Sources/QRCodeLibrary".
That means that the import statement would be
import QRCodeLibrary
, and it will create a breaking change only there.I will fork the library for now but can submit a PR for you to check what I mean.
The text was updated successfully, but these errors were encountered: