Post

Replies

Boosts

Views

Activity

Xcode 15.2 and Developper App Certificate
I develop an App for Mac and iPhone, and till now, I had no issue to test it on my iPhone. but this morning, I have the following message, when I try to run it on my iPhone: Failed to verify code signature .... (A valid provisioning profile for this executable was not found.) Verify that the Developer App certificate for your account is trusted on your device. Open Settings on the device and navigate to General -> VPN & Device Management, then select your Developer App certificate to trust it. I must precise that it works on the simulator. the version of Xcode is 15.2 and the version of iPhone is 17.2.1 when I go on Settings/VPN -> Device Management (on iPhone), I don't see any section for Developper App Certificate when I go to Devices and Simulators on Xcode, and list the Provisioning Profiles installed on my iPhone, I see the IOS Team Provisioning Profiled of my application but it still not work. What can I do?
3
0
1.1k
Jan ’24
Swiftui and verticalTraitClass
For my app working on iPhone and IPad, I have two different designs depending on the landscape or portrait orientation. But it's not so simple, because for iPad, the design is the same while in portrait or landscape orientation. So I thought to user verticalSizeClass. If it is compact, I apply portrait design, if it is Regular, I apply landscape design. So I introduce the environment variable: @Environment(\.verticalSizeClass) var verticalSizeClass: UserInterfaceSizeClass? And create the following modifier (found on Apple Developper Forum) struct DeviceRotationViewModifier: ViewModifier { let action: (UIDeviceOrientation) -> Void func body(content: Content) -> some View { content .onAppear() .onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in action(UIDevice.current.orientation) } } } // A View wrapper to make the modifier easier to use extension View { func onRotate(perform action: @escaping (UIDeviceOrientation) -> Void) -> some View { self.modifier(DeviceRotationViewModifier(action: action)) } } Implementing the OnRotate modifier on my contentView .onRotate { newOrientation in print(verticalSizeClass) } I find that the verticalSizeClass is not correct on first call of OnRotate (it's always regular). After when I change orientation, the verticalsizeClass becomes correct. What did I missed?
0
0
391
Sep ’23
SwiftUI Modifiers on generic Views
I created a control which group a TextField, a Text as the label of the TextField, and eventually a Text to signal an error The result will be something like that: To declare this control, I write the following Code: struct TextFieldWithError<T: Hashable>: View { var label: String @Binding var text: String @Binding var textError: String var focusId: T? @FocusState.Binding var focus: T? var body: some View { VStack { HStack { if layout == .hstack { Text(label) } if let focusId { TextField(label, text: $text) .focused($focus, equals: focusId) } else { TextField(label, text: $text) .modifier(TextFieldStyle()) } } if textError != "" { Spacer() .frame(height:2) HStack { Text(textError) .foregroundColor(.red) .frame(height: textError == "" ? 0 : 20) .animation(.default) } } } } } if I use a generic for my control, it's because I want to control focus with the .focused modifier and I didn't found another way to do this now, I want to control the width of the label with a modifier. I thought about writing .TextFieldWithErrorFrame(labelWidth: <some CGFloatvalue>) struct TextFieldWithErrorFrame: ViewModifier { varlabelWidth: CGFloat func body(content: Content) -> some View { content } } I think that in place of writing content in the body of my modifier, I have to write the same code that I wrote for the control body, applying a frame modifier on the Label. But I don't find the way of doing this. if I declare the modifier as this: struct TextFieldWithErrorFrame<T>: ViewModifier where T: Hashable { var width: CGFloat func body(content: TextFieldWithError<T>) -> some View { content } } I need to declare an type alias for the body, because I have the error: Type 'TextFieldWithErrorFrame' does not conform to protocol 'ViewModifier' if I use typealias Body = TextFieldWithErrorFrame<T> I have the same error and that's not all. how to rewrite the content in the body of the modifier?
0
0
665
Jun ’23
focused modifier
I'm trying to make a custom TextField which eventually show errors when loosing focus in a normal form, foreach TextField, I write: TextField(label, text: $text) .focused($checkoutInFocus, equals: <some Value>) Text(textError) .foregroundColor(.red) .frame(height: textError == "" ? 0 : 20) (I want to precise it's not all: I have many modifiers for the TextField and it becomes very difficult to read when there are many TextFields) So I thought it would be a good idea to make a special view for each Textfield: struct TextFieldWithError: View { var label: String @Binding var text: String @Binding var textError: String @FocusState.Binding var isFocused: Bool init(label: String, text: Binding<String>, textError: Binding<String>, isFocused: FocusState<Bool>.Binding) { self.label = label self._text = text self._textError = textError self._isFocused = isFocused } var body: some View { TextField(label, text: $text) .modifier(TextFieldStyle()) .focused($isFocused) Text(textError) .foregroundColor(.red) .frame(height: textError == "" ? 0 : 20) } } My problem is that I don't find the way to act on the focusState. In the mainView I write: TextFieldWithError(label: "Email", text: $email, textError: $emailError, isFocused: checkoutInFocus == .<some Value>) in place of the modifier .focused($checkoutInFocus, equals: .email) but the syntax is obviously not good: I get the error: Cannot convert value of type 'Bool' to expected argument type 'FocusState.Binding' Do you think there is a way?
3
0
1.2k
Jun ’23
Howto releaseData with UITableView prefetching
I develop an app with a UITableView extracting data from a web server. to spare communication between my app and my webserver, I calculate how many rows my tableView can display and I ask the web werver to send me a array containing this number of data. when prefetching,rows, if the ;data corresponding to the indexPath is not in memory, I call the web server, otherwise I extract the data from memory. everything works fine, but I notice that the amount of data grows at each call to the webserver, and is never released. to release some data, I thought using tableview(cancelPrefetchingForRowsAt), but i'm not sure it is the good way to do it. I'm not sure that indexPathes calld in the cancelPrefetching method correspond to rows that UITableView doesn't use
0
0
284
Feb ’23
custom keyboard and rightToLeft direction
I'm developping a hebrew custom keyboard (the way the wovels are handled in the apple hebrew keyboard is not satisfying for me). As the hebrew language is from right to left, I expect that when I type a letter the cursor position moves to the left of the text, but it is not the case: it stays on the right, while new typed caharcters will be correctly positionned (on the left of the last character). if I manually position the cursor on the left of the last character entered (using adjustTextPosition of textDocumentProxy) the next character whill not be on the left position, as expected but on the right position. how can I fix the problem, and have the cursor on the left after typing a character?
0
0
723
Feb ’23
Compiler problem
I develop a share extension for my app the app compile and runs with no problem, but when I add a share extension to my App, without changing anything to the code of apple, I have error: Unexpected input file: /Users/patricerapaport/Swift/Rangements/RangementsIOS/DEINIT_WARKING and unable to open dependencies file (/Users/patricerapaport/Swift/Rangements/RangementsIOS/Build/Intermediates.noindex/RangementsIOS.build/Debug-iphonesimulator/RangementsShareExt.build/Objects-normal/x86_64/RangementsShareExt-master-emit-module.d) I precise that my App and my extension share the same group app My version of Xcode is 14.1
2
0
881
Dec ’22
showing QLPreviewController in a containerView
I see there is not many answers about quicklook posts I have an IOS app which display items in a QLPreviewController and it works well when I presenty the QLPreviexwController. Now I want to change the presentation: I want a ViewController with 2 viewContainer: One for informations about the object represented by quicklook, and the other with the previewController itself. When I run the nw App, I don’t see the preview in the second viewContainer. The function numberOfPreviewItems is called, but previewItemAt is never called. Do you think it is not possible to show a quicklook item in a viewContainer?
0
0
1.1k
Dec ’22
Ios downloaded locations
I develop an App which has a quicklook preview for files located on a web server To realize this preview, I download the file and access it with a QLPreviewController When I use simulator, I can see the downloaded files somewhere in library/developper/coresimulator..... and so on of my mac, and I can manually delete them. But if I search these files on the IPhone simulator, I can't find them. What when I run the application on my real device? How will I be able to delete these files? because I think it take place in the IPhone
4
0
1.2k
Nov ’22
Using framework which use alamofire
I have a framework named NetworkFramework which uses alamofire. Of course, somewhere in my sources, I have : import Alamofire My framework has a podfile which contains: target 'NetworkFramework' do use_frameworks! # Pods for NetworkFramework pod 'Alamofire', '~> 5.5.0' end if I want to use this framework in an App I have 2 possibilities (if I don't mistake) import NetworkFramework and his sources in the app simply import NetworkFramework.framework In the first case, all is compiled and there is no problem. In the second case, when I try to compile the App, I got an error which is No such module Alamofire I don't understand why. Do I have to compile the App with the sources of the framework?
0
0
946
Nov ’22
scrollview layout
I am very confused about UIScrollview auto layout I want to make a very standard IOS Application with some textfields and textviews. When the keyboard appears, I want the current responder to be visible on screen. It seems to me very simple, There ara many posts on the subject, but I don't obtain the correct result, and I think it comes from the layout of my scrollview and it's contentView. For the layout, I do the following: The left, top, right and bottom of my UIscrollView is pinned on the view of the UIViewController. The left, top, right and bottom of the controlView is pinned on ContentLayoutGuide of the UIScrollview. And, as I want the scroll to be only vertical, I have the width of the Content View to be equal to the width of the FrameLayoutGuide of the UIScrollView. At this point, I have an error in interface Builder, which is: Scrollview needs constraint for Y position. After that, in IB, I position constraints of all the fields in the contentView. I still have the layout error in Interface Builder. Some posts say that the last subview in contentView as to be pinned to the bottom of the contentView. But I think it is not good, because it will give a height for the content view, or this height depends of the device to be used. So I click on the error in Interface Builder, then on "Add missing constraints", and the new constraint pin the bottom of contentView to bottom of FrameLayoutGuide of the UIScrollView. No error at this point, but if I run under simulator, I have the warning: "LayoutConstraints] Unable to simultaneously satisfy constraints." No Matters, I go on To eventually make the scroll when a UIControl becomes first responder, I write the following in my UIViewController: `class BaseViewController: UIViewController { // visibleRect is the part of the contentView which is visible on screen var visibleRect: CGRect! // scrollOrigin is the initial contentOffset of the scrollview var scrollOrigin: CGPoint! override func viewDidLoad() { super.viewDidLoad() registerKeyboardNotifications() Let kbdGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard(_:))) view.addGestureRecognizer(kbdGestureRecognizer) } func registerKeyboardNotifications() { NotificationCenter.default.addObserver(self, selector: #selector(adjustForKeyboard), name: UIResponder.keyboardWillHideNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(adjustForKeyboard), name: UIResponder.keyboardWillChangeFrameNotification, object: nil) } @objc func dismissKeyboard(_ sender: UITapGestureRecognizer) { view.endEditing(true) if let scrollview = scrollview, let scrollOrigin = scrollOrigin { scrollview.setContentOffset(scrollOrigin, animated: true) } } @objc func adjustForKeyboard(notification: Notification) { guard let keyboardValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return } let keyboardViewEndFrame = view.convert(keyboardValue.cgRectValue, from: view.window) if let scrollview = scrollview { visibleRect = scrollview.subviews[0].frame } else { visibleRect = view.frame } visibleRect.size.height -= keyboardViewEndFrame.size.height }` In adjustForKeyboard function, scrollview.subviews[0].frame as a negative y position. All UIControls are subclassed so that in becomeFirstResponder, it calls the following function of UIViewController: public func currentResponderChange(_ newResponder: UIResponder?) { currentResponder = newResponder if let scrollview = scrollview, let currentResponder = currentResponder as? UIView, currentResponder.isFirstResponder, let view = controllerView { if scrollOrigin == nil { scrollOrigin = scrollview.contentOffset } var frameConverted = view.convert(currentResponder.frame, from: view.window) // si le scroll est uniquement vertical, on met x à zéro frameConverted.origin.x = 0 if let scrollOffset = scrollOrigin { frameConverted.origin.y -= scrollOffset.y } if visibleRect.contains(frameConverted) { if let scrollOrigin = scrollOrigin { scrollview.setContentOffset(scrollOrigin, animated: true) } } else { var delta = (currentResponder.frame.origin.y+currentResponder.frame.size.height) - visibleRect.size.height //- scrollview.contentOffset.y if let scrollOrigin = scrollOrigin { delta -= scrollOrigin.y } scrollview.setContentOffset(CGPoint(x: 0, y: delta), animated: true) } } } It don't work, because of the visibleRect, which is not correct. And I think it comes from initial layout in Interface Builder. the view is effectively scrolled, but not for the correct amount Can someone helps?
2
0
807
Aug ’22
async await invalid conversion from throwing function
I'm complety lost with async await operation I have a subclass of UITextField which provide a verif method in the resignFirstResponder method, I call the verif Method and return true or false, depending of the result of the verif the verif method is asynchrone, because it can make call to a web server. My code is: import UIKit public enum VerifResult<S: NSString> { case success case failure(S) } @IBDesignable class TextField: UITextField { @IBInspectable var obligatoire: Bool = false override func resignFirstResponder() -> Bool { var bRes = false do { let res = try await withCheckedThrowingContinuation { continuation in let result = try await verif() continuation.resume(returning: result) } switch res { case .success: bRes = true case .failure(let msg): bRes = false } } catch { return false } return bRes } public func verif() async throws -> VerifResult<NSString> { if obligatoire && text == "" { return .failure("Zone obligatoire") } else { // make call to a webserver and return .sucess or .failure return .success } } } in the resignFirstResponder on the line try await, the compiler detects the error: Invalid conversion from throwing function of type '(CheckedContinuation<_, Error>) async throws -> Void' to non-throwing function type '(CheckedContinuation<T, Error>) -> Void' I'm lost, I don't understand why where is my mistake?
6
0
2.2k
Aug ’22
Howto remove coredata from ios app
I have an IOS application who uses coredata As I want to develop and App extension which needs to share coredata with my app(Yes, I made a group App), I thought a good solution would be to create a framework with the, coredata model. I did it, but after that the coredata of the main app is no longer necessary. and I think I made a mistake when removing the file xcdatamodel from my app. when I refer to an entity in the main application, it doesn't use the entity of the framework. when I right click on an entity instance in my main application, I see a file which is: entity+CoreDataClass and of course I don't find it in the finder. Did I made a mistake by simply remove the xcdatamodel from my App? Do I have something to clean?
0
0
738
Jul ’22
ipad constraint and orientations
I have an App for Iphone and Ipad. in my UIViewController, the subviews installed depend of the different classes (CR, RC, CC, RR) because possible widths of the view are not the same. This work very well on Iphone, because the width of the view is different, depending on the class (CR, RC, CC). But for Ipad, the class is RR, no matter the orientation. Or in portrait and landscape, of course, width is not the same. In Interface Builder, I don't find a way to have subviews installed for Ipad in landscape and not in Portrait. Is there a way to handle this, or do I have to handle this programatically?
3
0
1.4k
Jun ’22