sentry-cocoa
sentry-cocoa copied to clipboard
Support for Sentry as a static lib
People that have Apps that require Sentry to be a static lib need to update the Xcode project file and compile it on every SDK update, making it harder to Bump the SDK often.
Can we make it possible thru a configuration so it's a bit less painful than now?
I know we used to have Sentry as a static lib but I don't remember why we've changed it, the output of this issue could be just explaining the trade-off and why we've decided to drop it.
This would be really amazing, I'd love to have a cmake or command line thing I can run that would make the xcode project static. I'd just never figured out what these are without manually opening xcode and changing the properties.
Projects like unreal engine really struggle with xcode frameworks and prefer static linked libs.
@marandaneto I am looking into integrating iOS SDK but we don't support any of the installation method described here https://docs.sentry.io/platforms/apple/guides/ios/install/ . It would certainly be helpful if we can get a static lib (.a) that I can just link against.
@marandaneto I am looking into integrating iOS SDK but we don't support any of the installation method described here https://docs.sentry.io/platforms/apple/guides/ios/install/ . It would certainly be helpful if we can get a static lib (.a) that I can just link against.
Curious if building from source is an option to you? At least until we add a static lib as a release target.
Sure 2 questions : 1. How do I build from source? 2. I would like to build based on last stable release. Can you please point me to commit which was the base for last sentry stable release for iOS?
Sure 2 questions : 1. How do I build from source? 2. I would like to build based on last stable release. Can you please point me to commit which was the base for last sentry stable release for iOS?
You can see our build configuration here: https://github.com/getsentry/sentry-cocoa/blob/741aa6d130e7637b67bf7a6f2ec22a7c8c5511d2/.github/workflows/buildandtest.yml#L39-L46
I suggest pulling the repo at a specific tag (a release we cut) which will help keeping track of what features and bugfixes you've included. It'll help troubleshooting in case you report an error and call out the SDK version (which is kept in sync with the tagged releases).
Latest release is: https://github.com/getsentry/sentry-cocoa/releases/tag/7.0.3
Checking build configuration. what is the output of building the repo this way(does it output .a or iOS framework that we can include in our project?)? or are you suggesting building along with our source code(that we do not want to do)?
Also, is there an ETA when we would have static lib support?
We currently build a framework. So this issue can stay open until we add static lib support.
My suggestion was that you could try to build a static lib by yourselves, until we ship the feature.
There's no ETA for this feature at this point.
We need this for Unity too.
Haven't tested this yet, but it seems like one could just duplicate the Sentry target in Sentry.xcodeproj and then set productType to com.apple.product-type.library.static in the .pbxproj? I imagine the less hacky version would use a variable for keeping the sources & headers consistent rather than duplicating
https://github.com/Jarred-Sumner/sentry-cocoa-static/releases/tag/7.7.0
@bruno-garcia and @bitsandfoxes, I think you both mentioned we would need this for Unity, and this issue could block you. Is this true?
We made it work without the need for a static lib.
I have created a CMake project that makes it possible to build as a static library. If there is interest in this I can make that available.
@m-kuhn, yes, please share it with us. That would be lovely.
Here you go:
https://github.com/opengisch/QField/tree/master/vcpkg/overlay/sentry-cocoa
It's written for building in vcpkg, but the CMakeFile.txt in there can be separated with minimal changes. Ideally it could even be moved to this repository here. One thing that needs mentioning is the following line https://github.com/opengisch/QField/blob/11b69f9256309bc2c3866c20989d7d935090b66e/vcpkg/overlay/sentry-cocoa/SentryCocoaConfig.cmake.in#L17
The linker needs an extra hint to include all symbols, as some classes get loaded dynamically on runtime and therefore the linker doesn't know that these need to be included at link time.
When using SPM or CocoaPods you can use Sentry as a static lib. I'm closing this.
@philipphofmann do you have links to how it is solved there? I'm wondering if the approach above is "best practice" or if there are alternative/better ways. Thanks.
This should work for CocoaPods
use_frameworks! :linkage => :static
target 'YourApp' do
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-cocoa.git', :tag => '8.20.0'
end
For SPM, the default is static, if I'm not mistaken, @brustolin?
I wonder mostly how they build with it statically, if it's also using LINKER:-force_load,${_IMPORT_PREFIX}/lib/libsentry_cocoa.a as in https://github.com/getsentry/sentry-cocoa/issues/1062#issuecomment-1231305956 or if there's a different approach.
For SPM, the default is static, if I'm not mistaken, @brustolin?
Yes. That's my understanding too. If you add sentry to your project with SPM, when its get symbolicated, its appear as code from your own binary, that indicates it was linked as a static lib.
If Im not mistaken cocoapod without the use_framework is also static by default.