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

Xcode 13: Compiler-Error UIApplication.shared #19

Closed
Feuerwerk opened this issue Jul 16, 2021 · 11 comments
Closed

Xcode 13: Compiler-Error UIApplication.shared #19

Feuerwerk opened this issue Jul 16, 2021 · 11 comments
Labels
bug Something isn't working

Comments

@Feuerwerk
Copy link
Contributor

The method

private func endEditing() -> Void {
UIApplication.shared.windows.filter{$0.isKeyWindow}.first?.endEditing(true)
}

throws a compiler error using BottomSheet in Xcode 13 Beta 3 for an iOS project (Deployment Target 15) saying that UIApplication extensions are not available for iOS and you should rely on ViewController functionality.

@lucaszischka
Copy link
Owner

Thank you for pointing this out.
Unfortunately I’m currently not committed to use the Xcode betas, because I had a lot of trouble last year and they completely broke developing and even some of my project.
As soon as Xcode 13 is finally released I will fix all build and design issues and test the project fully for iOS 15.

For now you can do your own testing and research and if you find a Solution working for iOS 13, 14 and 15 don’t hesitate to open a pull request.

I will leave this issue open, as it is technically a bug, but before the final release of Xcode 13 i won’t fix it.

Greetings Lucas

@lucaszischka lucaszischka added the bug Something isn't working label Jul 16, 2021
@Wouter01
Copy link

@lucaszischka
Copy link
Owner

@Wouter01 Yes thank you. I saw your fork, and if you could fix it (I’m unable to test it, because I’m not using Xcode 13) it would be nice if you would open a pull request.

Greetings Lucas

@Wouter01
Copy link

@Wouter01 Yes thank you. I saw your fork, and if you could fix it (I’m unable to test it, because I’m not using Xcode 13) it would be nice if you would open a pull request.

Greetings Lucas

I did have a look but wasn't able to fix it. I got it working on another library with this method, so it will probably be solvable in this way, but I currently do not have time to take a further look at it.

@lucaszischka
Copy link
Owner

Ah ok, no worries 👍

@Feuerwerk
Copy link
Contributor Author

I've tested it with the information in the twitter feed mentioned by @Wouter01 but this doesn't seem to work. As far as i understand this piece of code must be moved in a separate file which must be excluded from the iOSApplicationExtension-Target. I'm currently thinking of two files both containing only the function endEditing(). One containing the implementation as it is currently and one is empty (for the moment). Then the empty one must be used with the iOSApplicationExtension-Target and the other file must be used with all other targets. But i have little knowledge about the package-description to explicitly include / exclude a file from a specific target.

@lucaszischka
Copy link
Owner

Thank you all for your help regarding this problem.
As soon as Xcode 13 is released I will have a look and first try to fix it using @Wouter01 solution and if it doesn't work I will try to implement @Feuerwerk solution.
But maybe I will discover another way, with will work for every iOS version.

@Feuerwerk @Wouter01 could one of you please test this code and see if it works for now?

private func endEditing() -> Void {
     if #available(iOS 15, *) {
         //No solution right now
     } else {
          UIApplication.shared.windows.filter{$0.isKeyWindow}.first?.endEditing(true)
     }
}

Thank you,
Lucas

@Feuerwerk
Copy link
Contributor Author

@LucasMucGH I tested this already, doesn't work. because #available is a test at runtime but UIApplication.shared is not available at compile time.

@lucaszischka
Copy link
Owner

Ah ok, thank you.

@Feuerwerk
Copy link
Contributor Author

There is a discussion about this "feature" at swift.org
https://forums.swift.org/t/set-application-extension-api-only-on-a-spm-package/39333

@Feuerwerk
Copy link
Contributor Author

Feuerwerk commented Jul 20, 2021

I may have found a simple solution: #20
This is the method @Wouter01 mentioned, but now i understand its intended use.

lucaszischka added a commit that referenced this issue Dec 28, 2021
- Update Copyright
- Update swift-tools-version
- Update deprecated code (real fix for #19, replaces #20)
- Add `.absolutePositionValue` option (closes #37)
- Add `BottomSheetPositionAbsolute`
- Use explicit animations (fixes #31)
- Hide examples in ReadMe
- Implement and fix `.appleScrollBehavior` (closes #37)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants