unsafeMutableAddressor : Swift.String, referenced from:..
The conslusion is: it is not going to work.
I report it as a bug to Apple, and got a response:
UI tests execute differently from Unit tests - Unit tests run inside your application process so they can access your application code. UI tests execute in a separate process, outside your application, so they can simulate how the user interacts with the application. It’s not expected that you will be able to access your app class from a UI test.
Singleton class in swift gives EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) error
The problem in your code is in this line
private var urlSession = URLSession(configuration: sharedInstance.urlConfig)
As when you create an instance of class then it's variables also get allocated in memory. But here you are trying to access a variable before it's initialisation complete.
To fix crash you can change your variable urlSession
to something like this:
private var urlSession = URLSession(configuration: URLSessionConfiguration.default)
What causes a SIGILL with an ILL_ILLTRP code on iOS?
I tried to understand what happened. I don’t have a solution, but a few ideas:
The stack trace (line 0) says the crash is in the CocoaLumberjack
swift code at line 73, where a Bool
var
asyncLoggingEnabled
should be accessed using an unsafeMutableAddressor
.
Apparently, this is the instruction
public var asyncLoggingEnabled = true
in this code at line 73.
I believe this var
is accessed using an UnsafeMutablePointer
(docs). Here, the app is
... responsible for handling the life cycle of any memory you work with
through unsafe pointers to avoid leaks or undefined behavior.
Particularly,
Many pointer operations must only be applied to pointers with memory
in a specific state—you must keep track of the state of the memory you
are working with and understand the changes to that state that
different operations perform. Memory can be untyped and uninitialized,
bound to a type and uninitialized, or bound to a type and initialized
to a value. Finally, memory that was allocated previously may have
been deallocated, leaving existing pointers referencing unallocated
memory.
I believe that your app crashed because the pointer used to access asyncLoggingEnabled
points to memory in an illegal state.
If this happens, a system trap should be executed to handle the situation, but it can only be executed if a trap handler for this type of exception has been installed. If this is not the case, an illegal trap (Exception Code: ILL_ILLTRP) is done that handles all not handled traps.
Probably, the memory could by chance also be in a legal state, depending on the execution history. Thus, the crash may happen or not.
To cut it short, I think this is a bug in CocoaLumberjack
.
Related Topics
Does Untimeintervalnotificationtrigger Nexttriggerdate() Give the Wrong Date
Why Does Type(Of:) Return Metatype, Rather Than T.Type
How to Add Multiple Values for One Key in a Dictionary Using Swift
Removing a Closure from an Array
Weak Method Argument Semantics
iOS Swift Didbegincontact Not Being Called
Using @Fetchrequest(Entity: ) for Swiftui MACos App Crashes
How to Subclass a Class Which Doesn't Have Any Designated Initializers
Make a Type Itself -- Not Its Instances -- Conform to a Protocol
Symbol Is Considered to Be an Identifier, Not an Operator
How to Make Embedded View Controller Part of the Responder Chain
Swiftui Widget iOS 14 Gradient Issue
Typecast Unsafemutablepointer<Void> to Unsafemutablepointer<#Struct Type#>
Swiftlint Overriding Project Settings Related to Spm
Not Getting Expected Delegate Calls When Trying to Restore In-App Purchases with Storekit