mattgallagher / cwlutils Goto Github PK
View Code? Open in Web Editor NEWA collection of Swift utilities as documented on cocoawithlove.com
License: Other
A collection of Swift utilities as documented on cocoawithlove.com
License: Other
I've been looking at Exec
and can not figure out how to invokeAndWait
from the main thread; none of the cases seems to cover that.
(It's quite confusing that Exec.mainAsync.invokeAndWait
does not wait.)
This line crashes on M1 Macs because the try fails
CwlUtils/Sources/CwlUtils/CwlSysctl.swift
Line 164 in 0bfc458
I am experiencing occasional crashes when using this method, this is the relevant part of the stack trace:
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000185e41e64 __psynch_mutexwait + 8
1 libsystem_pthread.dylib 0x0000000185f0bda4 _pthread_mutex_lock_wait + 96
2 SolutoHomeKit 0x0000000100fcda34 0x100f84000 + 301620
3 SolutoHomeKit 0x0000000101064994 0x100f84000 + 919956
4 SolutoHomeKit 0x000000010106556c 0x100f84000 + 922988
5 SolutoHomeKit 0x0000000101080f80 0x100f84000 + 1036160
6 SolutoHomeKit 0x0000000101080f00 0x100f84000 + 1036032
I am trying to google it right now, see if someone experience something simillar - but thought it might be also good to ask here, in case someone already familiar with that issue. If I'll find something useful, I will update.
Thanks,
Omer
I'm testing this in iOS 11.2.1. When osRev is queried, preFlightResult
is equal to -1
and a POSIXErrorCode
is thrown. It's not clear to me how to debug this further.
Xcode 10 is in GM state.
After a lot of head scratching earlier today I found the cause of some unexpected timer behaviour originating in code I originally copied from your DispatchTimeInterval.toSeconds() extension. The bug still seems to be there, calculations here are not correct:
CwlUtils/Sources/CwlUtils/CwlDispatch.swift
Line 112 in ddeb12d
(lldb) po DispatchTimeInterval.milliseconds(1).toSeconds()
9.9999999999999995e-07
(lldb) po DispatchTimeInterval.microseconds(1).toSeconds()
0.001
I opted by changing the relevant cases in the switch:
case .milliseconds, .microseconds, .nanoseconds:
return (1.0 / Double(NSEC_PER_SEC)) * Double(toNanoseconds())
Thanks for sharing CwlUtils!
It took me a while to figure out why all of a sudden my pods wouldn't update: your last checkin removed the podspec.
Not sure why you removed support for Pods, but, it'd be great if you could update the README to mention this -- it still says pods are supported. It'd be even better if you could point out how to "migrate" from pods to swift package manager, or whatever you recommend as a migration path.
In step 3 you are referencing 'CwlSignal', even though I don't think CwlSignal is in play yet. Is this a copy/paste overlook ?
When I go to validate my app's IPA for release with Apple, it fails due to an issue it's finding with the Carthage-built version of CwlUtils.
"This bundle Payload/My_App.app/Frameworks/CwlUtils.framework is invalid. The Info.plist file is missing the required key: CFBundleVersion. Please find more information about CFBundleVersion at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleversion"
It looks like the Info.plist HAS CFBundleVersion
set to $(CURRENT_PROJECT_VERSION)
, which is standard.
However, CURRENT_PROJECT_VERSION
is not set in this project's build settings (project.pbxproj). I'm not well versed in setting up Carthage frameworks, but it seems like this current project version should be set.
I cannot produce a valid build for production with this issue as-is.
Hi,
Would you consider adding something similar to this:
extension AtomicBox<T> : CustomDebugStringConvertible
where T : CustomDebugStringConvertible {
var debugDescription: String {
let t = internalValue
return "AtomicBox(\(t.debugDescription))"
}
}
Scenario: I'm using AtomicBox to wrap some state in a state machine, and I need to log formatted debug info without deadlocking. The debug info is a snapshot in time, with no dependencies on it (except my understanding), so I don't need to wait for a mutex. The above would work for value types, but not class types, which is a problem - I don't know what syntax there is that would achieve where T : CustomDebugStringConvertible & !AnyObject
, and diverting CustomDebugStringConvertible & AnyObject
to a different extension leads to an implementation that is unsafe. Any thoughts on this? What pattern do you use instead?
Hello!
First of all, thanks for making CwlSysctl! Great tool :).
I wrote two helper functions that could be useful: one to convert the result of your sysctl into a struct and the other into an array of Int64. My goal was to be able to retrieve the result of sysctl kernel.boottime
.
I have no idea if the following code is the correct way to do it, or if it can be improved... I usually don't go that "far" down the rabbit hole :).
public func structFromSysctl<S>(levels: Int32..., as: S.Type = S.self) throws -> S {
let buffer = try sysctl(levels: levels)
return buffer.withUnsafeBytes() {
$0.load(as: S.self)
}
}
Usage:
let bootTime = try structFromSysctl(levels: CTL_KERN, KERN_BOOTTIME, as: timeval.self) // or
let bootTime: timeval = try structFromSysctl(levels: CTL_KERN, KERN_BOOTTIME)
print(bootTime) // timeval(tv_sec: 1499259206, tv_usec: 122778)
And for Int64 arrays:
public func intArrayFromSysctl(levels: Int32...) throws -> [Int64] {
let buffer = try sysctl(levels: levels)
if buffer.count % 8 != 0 {
throw SysctlError.invalidSize
}
return buffer.withUnsafeBytes { pointer in
(0..<(buffer.count / 8)).map { i in
pointer.load(fromByteOffset: i * 8, as: Int64.self)
}
}
}
let bootTime = try intArrayFromSysctl(levels: CTL_KERN, KERN_BOOTTIME)
print(bootTime) // [1499259206, 122778]
I can submit a pull request if my solution is acceptable.
Any framework (say F) that depends on https://github.com/mattgallagher/CwlUtils.git will use a dynamic link library if the CwlUtils is consumed as a swift package.
This creates a problem because when another application A consumed the framework F it doesn't get a copy of CwlUtils.
The workaround listed in the readme creates missing CwlFrameAddress issues in application A.
The solution is again to consume CwlUtils in application A. Looks like the SPM doesn't know how to deal the dynamic libraries.
I believe the line is here:
.library(name: "CwlUtils", type: .dynamic, targets: ["CwlUtils"]),
Does CwlUtils need to be dynamic?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.