Closed swift-ci closed 2 months ago
Comment by Svyatoslav Scherbina (JIRA)
(Just in case) more "real-world" reproducer, that relies on "standard" frameworks instead of specific Objective-C code in the project:
import Contacts
// ...
async {
try await CNContactStore().requestAccess(for: .contacts)
print("OK")
}
Add NSContactsUsageDescription
to Info.plist
and run this code twice.
For the first time, it will request the access (doesn't matter if you grant it or not).
For the second time it seems to immediately call the completion handler, causing the crash.
@swift-ci create
By using Task
instead of async
in the OP steps to reproduce code and in Svyatoslav Scherbina's comment, I am unable to reproduce the issue in Xcode 15.4 (Swift 5.10). I think this issue has long been fixed and it should be closed.
Thank you @alobaili! I also cannot reproduce the issue with Swift 6.0.
Environment
Xcode 13.0 beta (13A5154h)Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, Concurrency | |Assignee | None | |Priority | Medium | md5: 014d4f80d630d5722a90259e25948a24Issue Description:
Steps to reproduce:
1. Create new "iOS App" project in Xcode (set "Interface" to "Storyboard", "Language" to "Swift")
2. Add Objective-C files:
Select main group in the project structure. Go to menu File -> New -> File... -> "Cocoa Touch Class". Set "Language" to "Objective-C", name the class "TestAsync", press Next, agree to create bridging header.
3. Add
#import "TestAsync.h"
to the bridging header.4. Add the following method to
TestAsync
implementation:Add the corresponding method declaration to
TestAsync.h
as well.5. Add the following code to the end of
ViewController.viewDidLoad
:6. Run the app on the simulator.
The app prints "OK" and crashes with:
If I define
testWithCompletionHandler
asthen the code works without crashes and prints "OK".