Swift is a powerful and intuitive programming language for Apple platforms and beyond.

Posts under Swift tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Symbol breadcrumb
Using Xcode (or Instruments), is there a way to know all the functions/symbols that are touched by a line of code? struct Test { private func intro() { } func partOne() { intro() } func partTwo() { partOne() } func partThree() { partTwo() print(credits) } private var credits: String { "" } } let test = Test() test.partTwo() // partTwo, partOne, intro test.partThree() // partThree, partTwo, partOne, intro, credits
3
0
1k
Jul ’23
hello, i am finding Swift Bluetooth Classic communication sample code.
i am coding swift Bluetooth classic Communication program. my app need to communicate with esp32 with Bluetooth classic. but i didn't know how i can do this. there are so many sample code that use Bluetooth Low Energy communication with Swift or SwiftUI but i can't find Bluetooth classic with swift or swiftui. i think apple doesn't support Bluetooth Classic Communication . for example, they doesn't explain well about "Using core bluetooth classic" guide at their document at apple web site.
0
0
450
Jul ’23
iOS 14.4.0 Vector Kit Crash
Getting the crash only in iOS 14.x and i cannot identify the reason. Log: Crashed: com.apple.main-thread 0 VectorKit 0x324360 md::FrameGraphUtils::prepareGraphBuilderForRenderTarget(md::FrameGraphBuilder*, ggl::RenderTarget*, geo::StringLiteral, geo::StringLiteral, geo::StringLiteral) + 72 1 VectorKit 0x526f20 md::PassList::didPrepareForLayout(md::LayoutContext const&, md::Renderer&) + 276 2 VectorKit 0x526f20 md::PassList::didPrepareForLayout(md::LayoutContext const&, md::Renderer&) + 276 3 VectorKit 0x99dc4 md::CartographicRenderer::layout(md::LayoutContext&) + 120 4 VectorKit 0x8e2ac md::MapEngine::layoutScene(double, bool) + 664 5 VectorKit 0x8de5c -[_MapEngineRenderQueueSource renderQueueForTimestamp:] + 60 6 VectorKit 0x8ddf4 -[MDDisplayLayer _renderQueueForTimestamp:prepareHandler:] + 36 7 VectorKit 0x8ddc0 -[MDDisplayLayer renderQueueForTimestamp:] + 48 8 VectorKit 0x8d028 -[MetalLayer _onTimerFired:withPresent:] + 256 9 VectorKit 0x8c7b4 md::MapEngine::renderScene(double, std::__1::function<void ()>) + 100 10 VectorKit 0xca7a8 md::MapEngine::onRenderTimerFired(double) + 344 11 VectorKit 0x4ab388 std::__1::function<void (double)>::operator()(double) const + 48 12 VectorKit 0xca594 ggl::RunLoop::_RunLoopCallbacker::callback(double) + 144 13 VectorKit 0x63c2b8 ___ZN3ggl11DisplayLinkC2ENSt3__18functionIFvdEEE_block_invoke_2 + 92 14 libdispatch.dylib 0x4420 _dispatch_client_callout + 20 15 libdispatch.dylib 0x779c _dispatch_continuation_pop + 416 16 libdispatch.dylib 0x19298 _dispatch_source_invoke + 1260 17 libdispatch.dylib 0x11d04 _dispatch_main_queue_callback_4CF + 556 18 CoreFoundation 0xc39ec CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 19 CoreFoundation 0x82878 __CFRunLoopRun + 2508 20 CoreFoundation 0x81740 CFRunLoopRunSpecific + 600 21 HIToolbox 0x315c4 RunCurrentEventLoopInMode + 292 22 HIToolbox 0x313f4 ReceiveNextEventCommon + 688 23 HIToolbox 0x31124 _BlockUntilNextEventMatchingListInModeWithFilter + 76 24 AppKit 0x4182c _DPSNextEvent + 868 25 AppKit 0x401ac -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1312 26 AppKit 0x32060 -[NSApplication run] + 600 27 AppKit 0x3804 NSApplicationMain + 1064 28 AppKit 0x2f56d4 _NSApplicationMainWithInfoDictionary + 22 29 UIKitMacHelper 0x4fc4 UINSApplicationMain + 1276 30 UIKitCore 0x2a60 UIApplicationMain + 164 31 libswiftUIKit.dylib 0x13688 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 104 32 BilliyoClinicalPDN 0x1b898 main + 4377884824 (GoalProgressHeader.swift:4377884824) 33 libdyld.dylib 0x16f34 start + 4 Thread 0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352 2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8 Thread 0 libsystem_pthread.dylib 0x1d8c qos_class_main + 98 Thread 0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352 2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8 Thread 0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352 2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8 com.apple.uikit.eventfetch-thread 0 libsystem_kernel.dylib 0xce8 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x1098 mach_msg + 76 2 CoreFoundation 0x83e98 __CFRunLoopServiceMachPort + 380 3 CoreFoundation 0x8236c __CFRunLoopRun + 1216 4 CoreFoundation 0x81740 CFRunLoopRunSpecific + 600 5 Foundation 0x64a88 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 232 6 Foundation 0xf3254 -[NSRunLoop(NSRunLoop) runUntilDate:] + 124 7 UIKitCore 0x3ff4 -[UIEventFetcher threadMain] + 156 8 Foundation 0x5d0f4 NSThread__start + 864 9 libsystem_pthread.dylib 0x706c _pthread_start + 320 10 libsystem_pthread.dylib 0x1da0 thread_start + 8 Thread 0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352 2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8 Thread 0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352 2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8 Thread 0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352 2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8 Thread 0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352 2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8 Thread 0 libsystem_kernel.dylib 0x29c4 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0x30ac _pthread_wqthread + 352 2 libsystem_pthread.dylib 0x1d94 start_wqthread + 8 com.google.firebase.crashlytics.MachExceptionServer 0 FirebaseCrashlytics 0x1ef98 FIRCLSProcessRecordAllThreads + 184 1 FirebaseCrashlytics 0x1f378 FIRCLSProcessRecordAllThreads + 1176 2 FirebaseCrashlytics 0x16618 FIRCLSHandler + 48 3 FirebaseCrashlytics 0x18dd8 FIRCLSMachExceptionServer + 688 4 libsystem_pthread.dylib 0x706c _pthread_start + 320 5 libsystem_pthread.dylib 0x1da0 thread_start + 8 com.apple.NSURLConnectionLoader 0 libsystem_kernel.dylib 0xce8 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x1098 mach_msg + 76 2 CoreFoundation 0x83e98 __CFRunLoopServiceMachPort + 380 3 CoreFoundation 0x8236c __CFRunLoopRun + 1216 4 CoreFoundation 0x81740 CFRunLoopRunSpecific + 600 5 CFNetwork 0x24c7d0 _CFURLStorageSessionCopyCache + 36132 6 Foundation 0x5d0f4 NSThread__start + 864 7 libsystem_pthread.dylib 0x706c _pthread_start + 320 8 libsystem_pthread.dylib 0x1da0 thread_start + 8
1
0
417
Jul ’23
Arduino HM-10 Bluetooth with iOS : Connected, but it doesn't send values
I'm trying to make an iOS (SwiftUI based) app to connect the arduino and send the current latitude value of ios to arduino. I successfully made the view that allow user to select the bluetooth device, and the UUID/name of the device is successfully displayed. Also, the arduino device detects connection (I used LiquidCrystal to display serial and it says "OK+CONN" and "OK+LOST" if connection was lost.), but when I click "fetch location" button, nothing happens on arduino side. The code is in stackoverflow due to character limits: https://stackoverflow.com/questions/76752529/arduino-hm-10-bluetooth-with-ios-connected-but-it-doesnt-send-values
0
0
628
Jul ’23
Got compile error while trying to process a rectangle type of detection instead of QR
I was switching the Detector scanner from QR to Rectangle type of detection but on Rectangle type of detection I cannot take the feature.messageString out of CIRectangleFeature, while on CIQRCodeFeature it works. Only what I had changed was ofType: CIDetectorTypeQRCode into CIDetectorTypeRectangle and features as? [CIQRCodeFeature] into features as? [CIRectangleFeature] here is the code func processQRCodeImage(_ image: UIImage) { var qrCodeLink = "" let detector: CIDetector = CIDetector(ofType: CIDetectorTypeRectangle, context: nil, options: [CIDetectorAccuracy: CIDetectorAccuracyHigh])! let ciImage: CIImage = CIImage(image: image)! let features = detector.features(in: ciImage) if let features = features as? [CIRectangleFeature] { for feature in features { qrCodeLink += feature.messageString! // Value of type 'CIRectangleFeature' has no member 'messageString' COMPILE ERROR } } if qrCodeLink.isEmpty { failedQRCoderead() } else { found(code: qrCodeLink) onBackPressed?() } }
0
0
486
Jul ’23
AVAssetTrack nominalFrameRate is always 30 for high speed videos
For some reason the AVAssetTrack nominalFrameRate is always 30 for high speed videos. 120 FPS and 240 FPS videos' nominalFrameRate property is always 30. However, 60 FPS videos' nominalFrameRate is 60. I'm reading in the video url through the PHPickerViewController. I have a configuration for the picker set up as follows. configuration = PHPickerConfiguration(photoLibrary: PHPhotoLibrary.shared()) configuration.filter = .videos configuration.selectionLimit = 0 and the gathering of the picker results as follows func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { for result in results { var currentVideo = Video() let provider = result.itemProvider provider.loadFileRepresentation(forTypeIdentifier: "public.movie") { url, error in guard error == nil else { return } guard let url = url else {return} // create a new filename let fileName = "\(Int(Date().timeIntervalSince1970)).\(url.pathExtension)" let newUrl = URL(fileURLWithPath: NSTemporaryDirectory() + fileName) // copy item to APP Storage try? FileManager.default.copyItem(at: url, to: newUrl) currentVideo.url = newUrl.absoluteString self.parent.selectedVideos.append(currentVideo) } } // Set isPresented to false because picking has finished. parent.isPresented = false } I'm creating an AVAsset and AVAssetTrack to check the FPS of the video as follows. var asset: AVAsset? = AVAsset(url: url) if let asset = asset, let videoTrack = try? await asset.loadTracks(withMediaType: .video).last { let size = try? await videoTrack.load(.naturalSize) let fps = try? await videoTrack.load(.nominalFrameRate) let duration = try? await test.load(.duration) print(fps) // This shows 30 for 120 fps and 240 fps videos } I'm not sure if there's some other configuration that needs to be set to handle high speed videos or what. I'm really confused.
1
0
443
Jul ’23
Fallback to English if preferred language isn't supported
I have an app that supports English and Arabic. If a German user has Arabic in the languages for their iPhone, the app is switching to Arabic, since that language is one of their languages. How do I get it to only use the top most language (their most preferred language) they have set? So a German user that does not have English in their languages or maybe has it below Arabic, will still get English as their language
3
0
559
Jul ’23
UInt64 and shifts
I must be missing something simple here. I have an application I'm writing and having trouble with shifts and 64 bit unsigned integers. Here's some playground code: import UIKit let a: UInt64 = 0xFFFFFFFF00000000 let b: UInt64 = 0x0000000000000000 print(String(format: "a = 0x%016X", a)) print(String(format: "b = 0x%016X", b)) print(String(format: "a | b = 0x%016X", a | b)) It produces this output: a = 0x0000000000000000 b = 0x0000000000000000 a | b = 0x0000000000000000 Why is "a" not equal to 0xFFFFFFFF00000000? I'm using XCode 14.3.1. I also found issues shifting a byte into the upper 32 bits of a UInt64: let c: UInt64 = 0x00000000000000FF let d: UInt64 = 0x0000000000000000 print(String(format: "c = 0x%016X", c)) print(String(format: "d = 0x%016X", d)) print(String(format: "d | (c << 32) = 0x%016X", d | (c << 32))) This produces this output: c = 0x00000000000000FF d = 0x0000000000000000 d | (c << 32) = 0x0000000000000000
1
0
244
Jul ’23
Kitchen service
From the fantastic video: https://developer.apple.com/videos/play/wwdc2023/10170/?time=298, would you have a downloadable link to that kitchen service project? I'm trying to understand how the method: func handleShift<Orders>(orders: Orders) async throws is called? Because the video shows it to be called this way: for cook in staff.keys { group.addTask { try await cook.handleShift() } } without arguments ... Many thanks!
2
0
644
Jul ’23
Sign in with Apple button dark mode in Swift
I implemented Sign in with Apple but in all cases the button is always black. I would like to show it in light/ dark mode depending on the phone settings. This is my code: class MyAuthorizationAppleIDButton: UIButton { private var authorizationButton: ASAuthorizationAppleIDButton! @IBInspectable var cornerRadius: CGFloat = 3.0 @IBInspectable var authButtonType: Int = ASAuthorizationAppleIDButton.ButtonType.default.rawValue @IBInspectable var authButtonStyle: Int = ASAuthorizationAppleIDButton.Style.black.rawValue override public init(frame: CGRect) { super.init(frame: frame) } required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } override public func draw(_ rect: CGRect) { super.draw(rect) // Create ASAuthorizationAppleIDButton authorizationButton = ASAuthorizationAppleIDButton(authorizationButtonType: .signIn, authorizationButtonStyle: .black) let type = ASAuthorizationAppleIDButton.ButtonType.init(rawValue: authButtonType) ?? .default let style = ASAuthorizationAppleIDButton.Style.init(rawValue: authButtonStyle) ?? .black authorizationButton = ASAuthorizationAppleIDButton(authorizationButtonType: type, authorizationButtonStyle: style) authorizationButton.cornerRadius = cornerRadius // Show authorizationButton addSubview(authorizationButton) // Use auto layout to make authorizationButton follow the MyAuthorizationAppleIDButton's dimension authorizationButton.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ authorizationButton.topAnchor.constraint(equalTo: self.topAnchor, constant: 0.0), authorizationButton.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 0.0), authorizationButton.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: 0.0), authorizationButton.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: 0.0), ]) } } So basically with the code above, I can set on Storyboard the style of the button but it seems that even if I change the value at my code, the result is based on what I chose on Storyboard's variable. Is there any solution where I would be able to show the button in light/ dark mode depending on the phone settings ?
1
1
730
Jul ’23
How to make my bundle run when an agent system tries screen sharing or remote management, so that I can provide second step verification by using my custom bundle?
I'm a beginner in swift. Ways I tried: Tried adding a command line tool DNC observer to call a function when any screen sharing notification triggers, but later came to know that screen sharing doesn’t give any notifications. import OSLog import Foundation os_log("TecMFA:: Starting screen sharing finder.") let dnc = DistributedNotificationCenter.default() dnc.addObserver( forName: .init("com.apple.screensharing.server"), // tried many notification names like com.apple.screensharing.curtain etc. object: nil, queue: .main ) { notification in os_log("TecMFA:: Started screen sharing deamon.") } dispatchMain() Created a server using vapor as following //configure.swift import Vapor func routes(_ app: Application) throws { // Define a route to handle POST requests to "/login" app.post("login") { req -> HTTPStatus in // Read the username and password from the request body guard let loginData = try? req.content.decode(LoginData.self) else { // Failed to parse request body or invalid data return .badRequest } let username = loginData.username let password = loginData.password print(username) print(password) // Do something with the username and password print("Received login request with username: \(username) and password: \(password)") // Return a success response return .ok } } // Define a struct to represent the request body data struct LoginData: Content { let username: String let password: String } // routes.swift import Vapor import Foundation func getLocalIPAddress() -> String? { let task = Process() task.launchPath = "/usr/sbin/ipconfig" task.arguments = ["getifaddr", "en0"] // Use "en0" for Wi-Fi, "en1" for Ethernet let pipe = Pipe() task.standardOutput = pipe task.launch() let data = pipe.fileHandleForReading.readDataToEndOfFile() let output = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .whitespacesAndNewlines) return output } // Called before your application initializes. public func configure(_ app: Application) throws { // Register routes try routes(app) // Get the local IP address guard let localIPAddress = getLocalIPAddress() else { fatalError("Unable to get the local IP address.") } // Update the server configuration to bind to the local IP address and desired port app.http.server.configuration.hostname = localIPAddress app.http.server.configuration.port = 8080 } It didn't work when same port numbers. I tried using different port numbers but the request comes through port 5900, so 8080 cannot access it, so it didn't work either. Any corrections and suggestions are welcome.
3
1
449
Jul ’23
SQLite - Testing for existence of a table
I am learning how to access SQLite without the use of Swift Data. I have a function that tests to see if a table exists and it works. The problem is that I do not understand why it works. It is my understanding that the SELECT statement returns a 0 if the table does not exist and 1 if it does. But the API step statement returns 101 (SQLITE_Done) if the table does not exist. But if the table does exist it does not return 101. Per the SQLite documentation it would appear that 101 means the operation has completed. What am I missing here and is there a way to capture the underlying SQLite 0 or 1 which would allow me to test for that? Below is my function. func doesTableExist(db: OpaquePointer?) -> Bool { var tableExists: Bool = true let testForTable = """ SELECT name FROM sqlite_master WHERE type='table' AND name='Contact'; """ var testForTablePtr: OpaquePointer? if sqlite3_prepare_v2(db, testForTable, -1, &testForTablePtr, nil) == SQLITE_OK { if sqlite3_step(testForTablePtr) == SQLITE_DONE { tableExists = false } } else { print("unable to compile sql statement testing to see if table exists") } return tableExists }
1
0
824
Jul ’23
Xcode 15 beta 5 error: Invalid Swift parseable output message (malformed JSON)
This is new in Xcode 15 beta 5. Command SwiftCompile emitted errors but did not return a nonzero exit code to indicate failure. error: Invalid Swift parseable output message (malformed JSON): `0` (in target 'HiCoffee' from project 'HiCoffee') error: Invalid Swift parseable output message (malformed JSON): `1` (in target 'HiCoffee' from project 'HiCoffee') error: Invalid Swift parseable output message (malformed JSON): `{ "kind": "finished", ` (in target 'HiCoffee' from project 'HiCoffee') "name": "compile", "pid": -1139, "process": { "real_pid": 95136 }, "exit-status": 0 } Command SwiftCompile emitted errors but did not return a nonzero exit code to indicate failure
7
2
986
Aug ’23
"Paused on iPad"
Hello guys! I am trying to run my application on a physical iPad device. The app is successfully installed and when I run the code, it "Builds successfully", but when it starts, the screen is just dark and on the Xcode file it says "Paused app on iPad". i don't know what else to do. can anyone help me with this? Thank you!
2
0
363
Jul ’23
String.init(_cocoaString:) crash on iOS 17 Beta
Recently, we are testing our app on iOS 17, and found a weird crash that occurred on iOS 17, not on iOS 16 and below. Here's the stack: the sha512 is a function we wrote for the String extension: public extension String { var sha512: String? { return self.data(using: .utf8).map { NSData(data: $0).sha512() } } } We cannot find any mistake from the code above, and the code works well on iOS 16 and below (packaged by Xcode 14.2). And it also works on: iOS 17 simulator running from Xcode 14.2. iOS 17 simulator running from Xcode 15 Beta 4. iOS 17 beta 3/4 real device running from Xcode 15 Beta 4 (debug). It doesn't works on: packaged by Xcode 14.2 and running on iOS 17 beta real device. not tested: packaged by Xcode 15 Beta and running on iOS 17 beta real device. Is that an iOS 17 bug? Or anyone may know how to fix that? I will very appreciate your advice, thank you.
3
0
580
Aug ’23
@EnvironmentObject inside NavigationSplitView not available
As a developer, I have been using SwiftUI to build applications, and I have come across a specific scenario that seems to be causing some unexpected behaviour. When utilizing the @EnvironmentObject property wrapper to pass an object through the view hierarchy, I noticed that it becomes inaccessible after pushing and presenting the second view inside a NavigationStack. (which is inside a NavigationSplitView). To illustrate the problem, consider the following scenario: I have a Router class that conforms to ObservableObject, and it holds a NavigationPath to manage navigation within the app. The SettingsView is a SwiftUI view that uses NavigationStack to display different views based on user interactions. Inside this view, I use @EnvironmentObject to pass the Router object. Within the SettingsView, I have a button that, when clicked, programmatically pushes a new destination (AdvancedView) to the Router object using router.push(.advanced). In the AdvancedView I have a Button and a NavigationLink which both should lead to LogsView. When tapping on the Button (which programmatically pushes a new destination to the NavigationPath) the app crashes with the error that the @EnvironmentObject is not acccessbile. When tapping on the NavigationLink (which SwiftUI handles by itself) the app does NOT crash and can successfully push the value (.logs) to the NavigationPath (meaning it indeed has access to the @EnvironmentObject). The issue arises when I use the manually created button to navigate to the LogsView. In this scenario, the Router object, which was previously accessible through the @EnvironmentObject, becomes inaccessible on the AdvancedView. However, when I use the NavigationLink, the Router object is still accessible, and everything works as expected. To summarize: When using NavigationLink, the @EnvironmentObject (Router in this case) is accessible on the destination view (LogsView). When manually navigating using a button, the @EnvironmentObject (Router) is not accessible on the destination view (LogsView) after pushing and presenting the second view. // // ContentView.swift // ViewTester // // Created by Luca Archidiacono on 27.03.23. // import SwiftUI struct ListItem: Identifiable { let id = UUID() let title: String let description: String } enum MenuItem: Identifiable { case settings var id: Self { return self } var title: String { switch self { case .settings: return "settings" } } } struct ContentView: View { let menuItems: [MenuItem] = [.settings] @State var selected: MenuItem? = .settings var body: some View { NavigationSplitView { List(menuItems, selection: $selected) { selected in Text(selected.title) } .navigationTitle("Menu") } detail: { if let selected = selected { switch selected { case .settings: SettingsView() } } } } } enum Destination: Hashable { case advanced case logs } final class Router: ObservableObject { @Published var path = NavigationPath() func push(_ destination: Destination) { path.append(destination) } } struct SettingsView: View { @StateObject private var router = Router() var body: some View { NavigationStack(path: $router.path) { ZStack { Button("Advanced") { router.push(.advanced) } } .navigationDestination(for: Destination.self) { destination in switch destination { case .advanced: AdvancedView() case .logs: LogsView() } } } .environmentObject(router) } } struct AdvancedView: View { @EnvironmentObject private var router: Router var body: some View { // 1. This does not work somehow eventhough we passed router as EnvironmentObject on the NavigationStack. Button("Manual Logs") { router.push(.logs) } // 2. This somehow works, and it even pushes to the NavigationPath, which means SwiftUI should know about Router as EnvironmentObject NavigationLink(value: Destination.logs) { Text("NavigationLink Logs") } } } struct LogsView: View { var body: some View { Text("Logs") } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
0
3
560
Jul ’23
DeefaceLab: MacOs Gui port
I've been trying to get the bash/script version of DeepFaceLab to work with Apple Silicon Macs, but this was original a Windows project that even now has non-existent support for MacOs/Apple Silicon. I am thinking of converting everything into a native macOS app using Swift, specifically optimized for Apple Silicon GPUs. Here's what I got from ChatGPT. Any help/advice on how to do this would be greatly appreciated. I don't have any Swift programming experience, but I have experience with some coding and can generally figure things out. I know that this is probably not feasible for a single individual with little programming experience, but I wanted to throw this out there to see what others think. Thank you Here's a high-level overview of the steps involved in porting DeepFaceLab to Swift with a graphical UI: Understand DeepFaceLab: Thoroughly study the DeepFaceLab project, its Python scripts, and the overall architecture to grasp its functionalities and dependencies. Choose a Swift Framework: Decide on the UI framework you want to use for the macOS app. SwiftUI is Apple's latest UI framework that works across all Apple platforms, including macOS. Alternatively, you can use AppKit for a more traditional approach. Rewrite Python to Swift: Convert the Python code from DeepFaceLab into Swift. You'll need to rewrite all the image processing, deep learning, and video manipulation code in Swift, potentially using third-party Swift libraries or native macOS frameworks. Deep Learning Integration: Replace the Python-based deep learning library used in DeepFaceLab with an appropriate Swift-compatible deep learning framework. TensorFlow and PyTorch both offer Swift APIs, but you may need to adapt the specific model implementation to Swift. Image Processing: Find equivalent Swift libraries or frameworks for image processing tasks used in DeepFaceLab. UI Development: Design and implement the graphical user interface using SwiftUI or AppKit. You'll need to create views, controls, and navigation elements to interact with the underlying Swift code. Integration: Connect the Swift code with the UI components, ensuring that actions in the GUI trigger the appropriate Swift functions and display results back to the user. Testing and Debugging: Rigorously test the Swift application and debug any issues that arise during the porting process. Optimization: Ensure that the Swift app performs efficiently and effectively on macOS devices.
0
0
476
Jul ’23
A function declaration without a prototype is deprecated in all versions of C for RCT_EXTERN_MODULE
After updating to xcode 14.3 with RN 0.69.9, my project can't build anymore. It's throwing the error for all of my custom view managers. The error i'm getting is: A function declaration without a prototype is deprecated in all versions of C when I'm using RCT_EXTERN_MODULE Output of npx react-native info: System: OS: macOS 13.4.1 CPU: (8) arm64 Apple M1 Pro Memory: 77.59 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.13.1/bin/yarn npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm Watchman: 2023.07.10.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.12.1 - /Users/avarisco/.rvm/gems/ruby-2.7.4/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 Android SDK: Not Found IDEs: Android Studio: Not Found Xcode: 14.3/14E222b - /usr/bin/xcodebuild Languages: Java: Not Found npmPackages: @react-native-community/cli: Not Found react: 18.0.0 => 18.0.0 react-native: 0.69.9 => 0.69.9 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
0
0
953
Jul ’23