Dive into the world of programming languages used for app development.

All subtopics

Post

Replies

Boosts

Views

Activity

Module build on Apple Swift version 5.7.1 is not supported with compiler Apple Swift version 5.8
Failed to build module 'ComplyCubeMobileSDK'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)', while this compiler is 'Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)'). Please select a toolchain which matches the SDK.
0
0
424
Oct ’23
Starting with iOS Dev.
I am starting with programming. I changed career of late. I learnt basics of python very recently. I am keen to work as iOS developer in future. There's ambiguity how to kickstart my journey of programming and app dev. I need suggestion regarding what resources to follow. It's hard to do it without proper and directed guidance. In Book store, I could see books. I downloaded two of them, one is Develop in Swift Fundamentals and the other book is Develop in Swift Explorations. I am confused which one to read first. Is there some other good resources available online? Some YT channel I could refer? Please help me!
3
0
875
Oct ’23
NEHotspotNetwork.fetchCurrent is giving nil values everytime
I'm trying to fetch current connected network (WiFi or hotspot or MobileNetwork). I'm using the below code snippet NEHotspotNetwork.fetchCurrent { hotspotNetwork in print("Network Information") print(hotspotNetwork?.ssid) print(hotspotNetwork?.isSecure ?? true) print(hotspotNetwork?.bssid) print(hotspotNetwork?.securityType) print(hotspotNetwork?.signalStrength) I'm able to get the wi fi details. but one thing I noticed that it is giving every network as a UnSecure network whether it is password protected or not.How can we differentiate secure network and Unsecure network. And after some time, all of sudden, it stop giving all the values i.e. for each(ssid, isSecure, bssid, securityType, signalStrength) It gives nil values. Can anyone help me upstanding this. Thanks in advance.
2
0
497
Oct ’23
XML signing in Mac Os using swift
I want to sign xml file using enveloped signature approach in swift. The example original xml file could be like below <?xml version="1.0" encoding="ISO-8859-1"?> <Envelope xmlns="http://example.org/envelope"> <Body> Olá mundo </Body> </Envelope> After signature, the xml file would be like this <?xml version="1.0" encoding="ISO-8859-1"?> <Envelope xmlns="http://example.org/envelope"> <Body> Olá mundo </Body> <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> <SignedInfo> <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /> <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /> <Reference URI=""> <Transforms> <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /> </Transforms> <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> <DigestValue>????</DigestValue> </Reference> </SignedInfo> <SignatureValue>????</SignatureValue> <KeyInfo> <KeyValue> <RSAKeyValue>????</RSAKeyValue> </KeyValue> </KeyInfo> </Signature> </Envelope> Here the steps are encrypt using sha1WithRSAEncryption signature algorithm (rsa-sha1), which uses the SHA-1 message digest algorithm and RSA PKCS#1v1.5 to create the signature. Get the digest value using SHA-1 Canonicalization will be according to Canonical XML Version 1.0 or c14n rules. Is there any library in swift or objective c which i can use for this purpose? I am currently using AEXML to parse, read and write xml file. But for canonical conversion and other steps stated above which library i can use? For Your reference in C#, Cryptography.Xml provides all those functionalities. The below code in C# do the signing part of XML. SignedXml signedXml = new SignedXml(xmlDocument); signedXml.SigningKey = certificate.PrivateKey; Reference reference = new Reference(); reference.Uri = ""; //"#" + procedureSerial; reference.Type = reason; reference.Id = DateTime.UtcNow.Ticks.ToString(); // Add an enveloped transformation to the reference. XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform(true); reference.AddTransform(env); // Add the reference to the SignedXml object. signedXml.AddReference(reference); //canonicalize XmlDsigC14NTransform c14t = new XmlDsigC14NTransform(); reference.AddTransform(c14t); KeyInfo keyInfo = new KeyInfo(); KeyInfoX509Data keyInfoData = new KeyInfoX509Data(certificate); KeyInfoName kin = new KeyInfoName(); kin.Value = certificate.FriendlyName; RSA rsa = (RSA)certificate.PublicKey.Key; RSAKeyValue rkv = new RSAKeyValue(rsa); keyInfo.AddClause(rkv); keyInfo.AddClause(kin); keyInfo.AddClause(keyInfoData); signedXml.KeyInfo = keyInfo; // Compute the signature. signedXml.ComputeSignature(); // Get the XML representation of the signature and save // it to an XmlElement object. XmlElement xmlDigitalSignature = signedXml.GetXml(); xmlDocument.DocumentElement.AppendChild( xmlDocument.ImportNode(xmlDigitalSignature, true) ); I want to do same functionalities using swift or objective C to sign xml file in MacOS. Could you please suggest any library regarding this?
2
0
835
Oct ’23
PropertyListDecoder and .strings file
I have the following code: let file = "/path/to/en.lproj/Localizable.strings" let dec = PropertyListDecoder() var f: PropertyListSerialization.PropertyListFormat = .openStep do { //let data = strings.data(using: .utf8)! let data = try Data(contentsOf: URL(fileURLWithPath: file)) let list = try dec.decode([String: String].self, from: data, format: &f) print("foramt:", f.rawValue) list.forEach { print($0.key, $0.value) } } catch { print(error) } It seems PropertyListDecoder can correctly decode .strings file format; detected format is openStep (value is 1). But I am note sure because I couldn't find any docs on PropertyListDecoder about .strings file. Can anyone confirm this?
1
0
325
Oct ’23
URLSessionWebSocketTask custom close code
Is there a good way to access the web socket task actual close code? when looking at the task delegate: urlSession(_ session: URLSession, webSocketTask: URLSessionWebSocketTask, didCloseWith closeCode: URLSessionWebSocketTask.CloseCode, reason: Data?) I can see my custom code _closeCode = (long long) 4231 but the delegate (and the task's) closeCode variable is an enum (URLSessionWebSocketTask.CloseCode) so it have a fallback to the default invalid (0) for unknown values. I wonder if using webSocketTask.value(forKey: "_closeCode") Count as accessing private api, or if there is a cleaner way to access this raw value.
3
0
622
Oct ’23
Code in Scrumdinger content view.swift not matching lesson code. Help!
I'm just starting to learn Swift and I'm using the "Using Stacks to Create Views" learning module and I'm stuck in section 2 (Compose views) step 1 and the problem that I am having is that the code that is on the right hand section of the learning module is not the same code that I have in my Xcode contentview.swift in the ScrumdingerApp project. https://developer.apple.com/tutorials/app-dev-training/using-stacks-to-arrange-views I'm kind of embarassed as I should be zipping right through this part.. The code in the lesson module is like this - import SwiftUI struct ContentView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundColor(.accentColor) Text("Hello, world!") } .padding() } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } and the code in my Scrumdinger contentview.swift is much longer and looks like this - this is what I downloaded>> // // ContentView.swift // Scrumdinger // // Created by Chet Shannon on 10/22/23. // import SwiftUI import CoreData struct ContentView: View { @Environment(.managedObjectContext) private var viewContext @FetchRequest( sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)], animation: .default) private var items: FetchedResults<Item> var body: some View { NavigationView { List { ForEach(items) { item in NavigationLink { Text("Item at \(item.timestamp!, formatter: itemFormatter)") } label: { Text(item.timestamp!, formatter: itemFormatter) } } .onDelete(perform: deleteItems) } .toolbar { ToolbarItem(placement: .navigationBarTrailing) { EditButton() } ToolbarItem { Button(action: addItem) { Label("Add Item", systemImage: "plus") } } } Text("Select an item") } } private func addItem() { withAnimation { let newItem = Item(context: viewContext) newItem.timestamp = Date() do { try viewContext.save() } catch { // Replace this implementation with code to handle the error appropriately. // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. let nsError = error as NSError fatalError("Unresolved error \(nsError), \(nsError.userInfo)") } } } private func deleteItems(offsets: IndexSet) { withAnimation { offsets.map { items[$0] }.forEach(viewContext.delete) do { try viewContext.save() } catch { // Replace this implementation with code to handle the error appropriately. // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. let nsError = error as NSError fatalError("Unresolved error \(nsError), \(nsError.userInfo)") } } } } private let itemFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateStyle = .short formatter.timeStyle = .medium return formatter }() #Preview { ContentView().environment(.managedObjectContext, PersistenceController.preview.container.viewContext) }
0
0
392
Oct ’23
BGProcessingTask expirationHandler - Do i MUST finish background work? or will it can be resumed later?
I'm building a BGProcessingTask that may take more then 5 minutes to complete. The processing task runs on a Singleton object that can be accessed (or even started) when the app is on foreground. When the task expirationHandler is called, do i must finish my background work before calling task.setTaskCompleted(success: false)? I would like to have the background work suspended not cancelled. So when i reschedule another background processing task later or the app moves to foreground the same background task will continue. Is it ok practice? Will iOS might kill the background process (and the app) if not finished work before calling task.setTaskCompleted()? Or can i trust it will only get suspended and be able to resume later? Kind Regards
1
0
479
Oct ’23
NaN value when predict with model resnet
Coremltools: 6.2.0 When I run coreml model in python result is good: {'var_840': array([[-8.15439941e+02, 2.88793579e+02, -3.83110474e+02, -8.95208740e+02, -3.53131561e+02, -3.65339783e+02, -4.94590851e+02, 6.24686813e+01, -5.92614822e+01, -9.67470627e+01, -4.30247498e+02, -9.27047348e+01, 2.19661942e+01, -2.96691345e+02, -4.26566772e+02........ But when I run on xcode so result look like: [-inf,inf,nan,-inf,nan,nan,nan,nan,nan,-inf,-inf,-inf,-inf,-inf,-inf,nan,-inf,-inf,nan,-inf,nan,nan,-inf,nan,-inf,-inf,-inf,nan,nan,nan,nan,nan,nan,nan,nan,nan,nan,-inf,nan,nan,nan,nan,-inf,nan,-inf ....... Step1: Convert Resnet50 to coreml: import torch import torchvision # Load a pre-trained version of MobileNetV2 model. torch_model = torchvision.models.resnet50(pretrained=True) # Set the model in evaluation mode. torch_model.eval() # Trace the model with random data. example_input = torch.rand(1, 3, 224, 224) traced_model = torch.jit.trace(torch_model, example_input) out = traced_model(example_input) # Download class labels in ImageNetLabel.txt. # Set the image scale and bias for input image preprocessing. import coremltools as ct image_input = ct.ImageType(shape=example_input.shape, ) # Using image_input in the inputs parameter: # Convert to Core ML using the Unified Conversion API. model = ct.convert( traced_model, inputs=[image_input], compute_units=ct.ComputeUnit.CPU_ONLY, ) # Save the converted model. model.save("resnettest.mlmodel") # Print a confirmation message. print('model converted and saved') Step2: Test model coreml in python: import coremltools as ct import PIL import numpy as np # Load the model model = ct.models.MLModel('/Users/ngoclh/Downloads/resnettest.mlmodel') print(model) img_path = "/Users/ngoclh/gitlocal/DetectCirtochApp/DetectCirtochApp/resources/image.jpg" img = PIL.Image.open(img_path) img = img.resize([224, 224], PIL.Image.ANTIALIAS) coreml_out_dict = model.predict({"input_1" : img}) print(coreml_out_dict) Step3: Test coreml model in Xcode: func getFeature() { do { let deepLab = try VGG_emb.init() //mobilenet_emb.init()//cirtorch_emb.init() let image = UIImage(named: "image.jpg") let pixBuf = image!.pixelBuffer(width: 224, height: 224)! guard let output = try? deepLab.prediction(input_1: pixBuf) else { return } let names = output.featureNames print("ngoc names: ", names) for name in names { let feature = output.featureValue(for: name) print("ngoc feature: ", feature) } } catch { print(error) } }
1
0
771
Oct ’23
Keychain return different key when switching branches
Currently I found a wired issue on my application. The code basically unchanged for months. But suddenly when I switching to a different branch (a bit older), then back to the latest develop branch, the keychain returns a different encryption key. The keychain implementation remains the same for long time. Wondering if anyone can give some insights about it.
0
0
221
Oct ’23
err:[Room Congruence] isIrDataUserDataDictionaryStructurallyValid: IRData User Data invalid - underlying CF object is nil.
mac mini 2018, MAC OS Ventura 13.5.2, Xcode 15.0 using SpriteKit im running my game app in iPhone SE(3rd gen) device(not simulator) with IOS 17 and getting the following error in console: [Room Congruence] isIrDataUserDataDictionaryStructurallyValid: IRData User Data invalid - underlying CF object is nil. the error is showing only(one time) when user have started a game, but not showing if user select to play again. the error is showing among the following console errs: getFilePtr: error -1 getting file status [Room Congruence] isIrDataUserDataDictionaryStructurallyValid: IRData User Data invalid - underlying CF object is nil. [0x159dec540|RoomCongruence::Processor|Processor] One or more of the chosen IR Presets does not contain room congruence data or the data is corrupted. app have been tested on IOS 15 and 16 but not showing this error. appreciate any help, i can provide any other data as necessary. Sorry if im may be missing any info or data necessary this my first time posting here, thanks.
0
1
645
Oct ’23
err: [0x159dec540|RoomCongruence::Processor|Processor] One or more of the chosen IR Presets does not contain room congruence data or the data is corrupted.
mac mini 2018, MAC OS Ventura 13.5.2, Xcode 15.0 im running my game app in iPhone SE(3rd gen) device(not simulator) with IOS 17 and getting the following error in console: [0x159dec540|RoomCongruence::Processor|Processor] One or more of the chosen IR Presets does not contain room congruence data or the data is corrupted. err shows in console among this other errs messages: getFilePtr: error -1 getting file status [Room Congruence] isIrDataUserDataDictionaryStructurallyValid: IRData User Data invalid - underlying CF object is nil. [0x159dec540|RoomCongruence::Processor|Processor] One or more of the chosen IR Presets does not contain room congruence data or the data is corrupted. the error is showing only(one time) when user have started a game, but not showing if user select to play again. app have been tested on IOS 15 and 16 but not showing this error. appreciate any help, i can provide any other data as necessary. Sorry if im may be missing any info or data necessary this my first time posting here, thanks.
0
0
659
Oct ’23
Can't expand nested Swift macros
Anyone else having trouble getting Xcode to expand nested Swift macros? The outer macro expands fine, but when I try to expand the inner macro it just beeps. My macro is used like this: @ThrowingImplementation(MyError.unimplemented) protocol MyProtocol { func something() throws } expanding first to this: @ThrowingExtension(MyError.unimplemented) protocol ThrowingMyProtocol: MyProtocol { // func something() throws } ...which is supposed to expand to this: extension ThrowingMyProtocol { func something() throws { throw MyError.unimplemented } } but I can't get Xcode to expand this second macro. I have to use a nested macro because only an extension macro can introduce an extension. The function is included as a comment so the extension macro can see it. I have unit tests for both macros, and in the tests everything is fine. My problem is that, in some cases, when I do struct MyThing: ThrowingMyProtocol {} I get an error that it does not conform to MyProtocol even though that macro-generated extension should have taken care of implementing all functions. Not being able to expand the nested macro makes it hard to diagnose why this is happening. (this is with Xcode 15.0.1)
3
1
901
Oct ’23
Setup Cpp-Swift Interoperability using CMake
I have been using the Cpp-Swift Interoperability in Xcode15 for direct communication between Cpp and Swift code. It required a few Build settings changes for the Swift Compiler, creating clang modules(module map file) to access cpp code in swift, specifying module map path to the swift compiler etc. I wanted to use this interoperability feature in my visual studio project which is using Cmake. I want to build via cmake, using Xcode generator. Prior to Swift5.9, we were using a ObjC bridging header whose support was provided in the Cmake using the Xcode attribute flag 'XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER'. Similarly we were specifying the generated header using the attribute 'XCODE_ATTRIBUTE_SWIFT_OBJC_INTERFACE_HEADER_NAME' I m not able to find similar Xcode attribute property flags for my Cmake to enable this interoperability. What are the changes that we need to make in the Cmake(using Xcode generator) for this new interoperability to work. Can someone help with this?
1
0
540
Oct ’23
Help - Cannot convert value of type 'String' to expected argument type 'OpenAISwift.Config'
Newbie coder here, using most recent Xcode and iOS 17 to build an app using Adam Rushy openaiswift tutorial. The app is entirely built and everything functions except this: Cannot convert value of type 'String' to expected argument type 'OpenAISwift.Config' So I cannot build the project, it refers to this line of code: func setup () { client = OpenAISwift(config: "removed api key for public view)") } func send(text: String, in the tutorial it said use authToken which Xcode said was wrong and must be config, so I changed it but it still doesn't work. Any help appreciated
1
0
1.5k
Oct ’23
Xcode Playgrounds + Xcode 15
We are in class working with Develop in Swift Explorations. We created a new playground file to create a learning playground for notes and exercises and since the update to Xcode 15, it is running extremely sluggish and slow. Playground file is build for iOS and using Simulator for iPhone 15. We also tried to run for Mac and same issues. In addition, the Macbook Air M2s are running VERY hot - which is unusual.
4
0
1.2k
Oct ’23