bugfender / BugfenderSDK-iOS

Bugfender SDK for iOS, a remote logger tailor-made for mobile
https://bugfender.com
Other
75 stars 31 forks source link

APPLICATION_EXTENSION_API_ONLY setting #63

Open fortmarek opened 3 years ago

fortmarek commented 3 years ago

Hi! 👋

We are using your framework throughout our app and now we we'd like to use in our widget, too.

Now, widgets are more restrictive in what API you could use - eg if you used UIApplication.shared in your widget, it'd crash.

To make sure that this does not happen, it's recommended to set APPLICATION_EXTENSION_API_ONLY setting to true. With that turned on, xcodebuild statically checks your code for whether you use API not allowed in widget. It does so for transitive dependencies, too.

Since the check is done statically, it can not do that for dynamic frameworks. Thus, if you import a dynamic framework that does not have the aforementioned setting turned on, it'll warn you with a message linking against a dylib which is not safe for use in application extensions: ....

We integrate Bugfender via SPM - which imports libraries statically - but BugfenderLibrary imports BugfenderSDK dynamically, so we get that warning anyway.

As the BugfenderSDK framework is closed source, would it be possible to set APPLICATION_EXTENSION_API_ONLY to true?

FYI: we are using the latest version, 1.10.0

RubenVot commented 3 years ago

Hi @fortmarek, Thanks a lot for the exhaustive report. That's definitely a good idea, I will open a new ticket in the internal system and will try to discuss with the team asap.

I'm not sure if this can be helpful but in the release page you can download bugfender as static library as well: https://github.com/bugfender/BugfenderSDK-iOS/releases/tag/1.10.0 or following this link

fortmarek commented 3 years ago

Hi @RubenVot!

Thanks for the response! We're considering integrating bugfender manually to integrate it statically, but I'd rather not do so - is there any progress on this?

jgimenez commented 3 years ago

Our code actually uses UIApplication.shared, so we can not enable that flag for now. We'll need to find out if it's possible to just make some of the API unavailable to extensions.

olejnjak commented 3 years ago

Hello, how does it look few months later? It is pretty annoying to have 10+ warnings in project because of a single dependency and can easily cause that we will miss some really important warning.

By using the @available/#available directives it should be simple to mark functions that should not be available to app extensions.

@available(iOSApplicationExtension, unavailable)
public func onlyForAppsNotExtensions() {
...        
}

Then Xcode will not suggest that function in extensions and will not compile if used there giving error, it is not available in app extension.

Thanks.

jgimenez commented 2 years ago

Hi @olejnjak, there are deep implications so it's not that easy of a change, although we're working on it. Thanks for your patience.