Question around using KMMBridge to publish a libra...
# touchlab-tools
s
Question around using KMMBridge to publish a library through SPM. I think I got everything running well. Publishing to Github Packages, I can import the dependency to my iOS project, all is looking great. But then on the iOS side, when running locally it's fine, but when our CI tries to build the app to publish to the store, we are getting the following error:
Copy code
Invalid bundle structure. The "<http://Iosapp.app/Frameworks/ourkmplibrary.framework/ourkmplibrary|Iosapp.app/Frameworks/ourkmplibrary.framework/ourkmplibrary>" binary file is not permitted. Your app cannot contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. For details, visit: <https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle>
Does this ring a bell at all? Trying to look up this issue, I am only finding this super old issue which is marked as "fixed" but I am not really sure what the fix here is. And we are using
isStatic = true
too, which maybe we should not? I am not sure, the KMMBridge samples have it set to true so I did the same. I also briefly discussed this here, but in my Xcode I can't quite find the place where I would even be able to edit this. In "Dependencies > General > Frameworks and Libraries > " I can see our library there, but I do not see an option to embed it or not, there's just no option there.
Little update, turning it to a non static library, so removing the line
isStatic = true
seems to satisfy our CI, but I still feel like I am doing something else wrong somehow
Nah, we are getting crashes like
Symbol not found: _OBJC_CLASS_$libraryNameSomeTypeInside
when doing this. Back to the drawing board, super confused what I am doing wrong here, after following the entire KMMBridge setup docs from start to finish.
i
Did you use the lib which reference from local but not from GitHub url?
s
Do you mean for the second error or for the
binary file is not permitted...
error? In both cases, those errors have happened either in CI or by my iOS colleague, so it was 100% fetching the library from GitHub url and not locally. With that said, after some trial and error from my iOS colleague the
Symbol not found: _OBJC_CLASS_$libraryNameSomeTypeInside
error has disappeared, but I do not really know why it was there in the first place 🤷 And I still have not managed to figure out a way to make this work with
isStatic = true
😅
i
image.png
this what’s i get from my project
and kmp part:
image.png
image.png
s
Our project also uses https://github.com/tuist/tuist so I suppose it may be part of why some things are not exactly the same as what you see here. the library dependency does not show up in "Package Dependencies" just like none of the dependencies we bring in do, they are configured in a different way I suppose, I am not super familiar with Tuist to be honest. But hey, it could be what is going wrong here, that I need to somehow tell Tuist to do this linking properly 👀
i
Tuist could be the reason… i’m not using that so it’s hard to say what’s going there. but you can try the project without Tuist first then.
s
Yup, the hard part there is that this all works locally, with or without Tuist. It fails specifically when we try to push this build to the app store/testflight, where we get the aforementioned crash. So that's incredibly harder to test on a new project. And getting rid of Tuist in the real project to try this out is kinda like saying let's switch to maven from Gradle, not an easy nor a quick task 😅 But thanks for sticking with me here, I guess I got more things to test out 🤷‍♂️
🫡 1
I would still love to hear from anyone else if they’ve had issue with providing frameworks through KMMBridge with SPM when having
isStatic = true
on their build configuration. If nobody has, maybe it’s just something on our end completely and I should stop asking around here 😅
k
I didn't see this thread until now. Just some quick thoughts (I'm deep in something else right now).
Copy code
Invalid bundle structure. The "<http://Iosapp.app/Frameworks/ourkmplibrary.framework/ourkmplibrary|Iosapp.app/Frameworks/ourkmplibrary.framework/ourkmplibrary>" binary file is not permitted. Your app cannot contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. For details, visit: <https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle>
This path,
<http://Iosapp.app/Frameworks/ourkmplibrary.framework/ourkmplibrary|Iosapp.app/Frameworks/ourkmplibrary.framework/ourkmplibrary>
, implies the framework is being embedded in the app, but it's a static framework, so it shouldn't work that way.
Dynamic frameworks should be embedded in the app bundle.
I generally make static frameworks unless there's a reason I can't, and you shouldn't have issues like this regardless of which way you choose (obviously "shouldn't" is the key word here)
I'm aware of Tuist but have not configured it. I would make sure it's not configured to try to embed your framework.
It probably works locally because the binary file is just stuffed in there, but the server scan gets upset because you have a binary just "hanging out" that shouldn't be there:
binary file is not permitted. Your app cannot contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles.
So, in summary, the build is trying to stuff the framework in there like it's a dynamic framework, but the build uses it like a static framework (which it is), and you wind up with a static framework bundle stuffed into the app package, and it shouldn't be there.
🌟 1
s
Hey thanks for getting back to me here. I think I am sufficiently following what you are trying to say here. That has been my understanding too in general, that I should not have to be forced to have it be a dynamic framework. The more I look into this the more I think I understand that this is not on the KMMBridge side at all, but what Tuist is doing. I also unfortunately have a super rudimentary understanding of Tuist myself too, but I feel like that is exactly what I must fix before I come back here. Seeing “I would make sure it’s not configured to try to embed your framework.” I think does equip me with a better idea of what to take with me to my fellow iOS devs and/or the Tuist maintainers to hopefully help me out to avoid doing that exactly. I will try to get back into this at some point to properly fix this, since now we turned it into a dynamic one and it works, so you know how it is, if it works with the dynamic approach now everyone is scared of touching it 😅
Really really appreciate you helping out here, if I do end up making this work I will 100% get back to you here. I don’t know how popular Tuist is really in the iOS world, but it would be nice to be able to tell you after all this that “yeah, works with Tuist too, just gotta do X” 😄