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

Provide a sentry SPM package without UIKit #3460

Closed
Descartess opened this issue Nov 29, 2023 · 5 comments
Closed

Provide a sentry SPM package without UIKit #3460

Descartess opened this issue Nov 29, 2023 · 5 comments

Comments

@Descartess
Copy link

Problem Statement

We use sentry over SPM and we would like an out-of-the-box sentry package without UIKit available. Is this possible?

Solution Brainstorm

We could duplicate the current target in Package.swift and set relevant GCC_PRE_PROCESSOR_DEFINITIONS as follows

.target(
            name: "SentryNoUIKit",
            dependencies: ["SentryPrivate"],
            path: "Sources",
            sources: [
                "Sentry/",
                "SentryCrash/"
            ],
            publicHeadersPath: "Sentry/Public/",
            cxxSettings: [
                .define("SENTRY_NO_UIKIT", to: "1"),
                .define("GCC_ENABLE_CPP_EXCEPTIONS", to: "YES"),
                .headerSearchPath("Sentry/include"),
                .headerSearchPath("Sentry/include/HybridPublic"),
                .headerSearchPath("Sentry/Public"),
                .headerSearchPath("SentryCrash/Installations"),
                .headerSearchPath("SentryCrash/Recording"),
                .headerSearchPath("SentryCrash/Recording/Monitors"),
                .headerSearchPath("SentryCrash/Recording/Tools"),
                .headerSearchPath("SentryCrash/Reporting/Filters"),
                .headerSearchPath("SentryCrash/Reporting/Filters/Tools"),
                .headerSearchPath("SentryCrash/Reporting/Tools")
            ]
        ),
        ```

### Are you willing to submit a PR?

Yes
@philipphofmann
Copy link
Member

Since v 8.14.1, you should be able to use the SDK without linking UIKit. You shouldn't have to use an extra SPM package. Please reopen the issue if that doesn't solve your problem.

@getsantry getsantry bot removed the status in GitHub Issues with 👀 Nov 29, 2023
@philipphofmann philipphofmann closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2023
@github-project-automation github-project-automation bot moved this from Needs Discussion to Done in Mobile & Cross Platform SDK Nov 29, 2023
@Descartess
Copy link
Author

Does the SDK link UIKit by default? If yes, how can I turn it off in the context of app extensions and have it available within the main app?

Where does one set "SENTRY_NO_UIKIT=1" if sentry is added as a swift package?

@philipphofmann
Copy link
Member

@armcknight, you came up with the fix. I think nothing is required from the user side if I'm not mistaken. If not, can you please explain? We must put this info into the docs as well if we didn't do this already.

@armcknight
Copy link
Member

We did not implement support for SPM for this type of configuration yet. It's still basically an experimental feature that was only developed so far for one customer that does not use SPM.

I don't know for sure but seems like we'd need another target in the Package.swift that sets the alternate build configuration (Debug_without_UIKit/Release_without_UIKit). Or directly sets an unsafe build flag for the necessary config variable, but this would require not pinning a version number, but rather to a specific commit, or maybe branch, but then we'd have to maintain a separate type of release branch for this. See #3348 when we had to fix this when it broke SPM deploys.

We might have to refactor UIKit-based code into a separate target from the Sentry framework target, something like SentryUIKit, as we initially had discussed as a possibility, so it can be omitted from SPM linkages.

You're right about docs @philipphofmann, we should at least point out this limitation in CHANGELOG.

@philipphofmann
Copy link
Member

Yes, changelog makes sense 👍.

We might have to refactor UIKit-based code into a separate target from the Sentry framework target, something like SentryUIKit, as we initially had discussed as a possibility, so it can be omitted from SPM linkages.

Yes, the proper way to do this is to split Sentry into a core version without UIKit or other dependencies, something like SentryCore (I'm sure there could be a better name), and then have the default with UIKit. But that's a more significant refactoring.

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

No branches or pull requests

3 participants