iOS is the operating system for iPhone.

iOS Documentation

Posts under iOS tag

2,758 Posts
Sort by:
Post marked as solved
2 Replies
111 Views
Summary Hello Apple Developers, I've made a custom UITableViewCell that includes a UITextField and UILabel. When I run the simulation the UITableViewCells pop up with the UILabel and the UITextField, but the UITextField isn't clickable so the user can't enter information. Please help me figure out the problem. Thank You! Sampson What I want: What I have: Screenshot Details: As you can see when I tap on the cell the UITextField isn't selected. I even added placeholder text to the UITextField to see if I am selecting the UITextField and the keyboard just isn't popping up, but still nothing. Relevant Code: UHTextField import UIKit class UHTextField: UITextField { override init(frame: CGRect) { super.init(frame: frame) configure() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } convenience init(placeholder: String) { self.init(frame: .zero) self.placeholder = placeholder } private func configure() { translatesAutoresizingMaskIntoConstraints = false borderStyle = .none textColor = .label tintColor = .blue textAlignment = .left font = UIFont.preferredFont(forTextStyle: .body) adjustsFontSizeToFitWidth = true minimumFontSize = 12 backgroundColor = .tertiarySystemBackground autocorrectionType = .no } } UHTableTextFieldCell import UIKit class UHTableTextFieldCell: UITableViewCell, UITextFieldDelegate { static let reuseID = "TextFieldCell" let titleLabel = UHTitleLabel(textAlignment: .center, fontSize: 16, textColor: .label) let tableTextField = UHTextField() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) configure() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } func set(title: String) { titleLabel.text = title tableTextField.placeholder = "Enter " + title } private func configure() { addSubviews(titleLabel, tableTextField) let padding: CGFloat = 12 NSLayoutConstraint.activate([ titleLabel.centerYAnchor.constraint(equalTo: centerYAnchor), titleLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: padding), titleLabel.heightAnchor.constraint(equalToConstant: 20), titleLabel.widthAnchor.constraint(equalToConstant: 80), tableTextField.centerYAnchor.constraint(equalTo: centerYAnchor), tableTextField.leadingAnchor.constraint(equalTo: titleLabel.trailingAnchor, constant: 24), tableTextField.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -padding), tableTextField.heightAnchor.constraint(equalToConstant: 20) ]) } } LoginViewController class LoginViewController: UIViewController, UITextFieldDelegate { let tableView = UITableView() let loginTableTitle = ["Username", "Password"] override func viewDidLoad() { super.viewDidLoad() configureTableView() updateUI() createDismissKeyboardTapGesture() } func createDismissKeyboardTapGesture() { // create the tap gesture recognizer let tap = UITapGestureRecognizer(target: self.view, action: #selector(UIView.endEditing)) // add it to the view (Could also add this to an image or anything) view.addGestureRecognizer(tap) } func configureTableView() { view.addSubview(tableView) tableView.layer.borderWidth = 1 tableView.layer.borderColor = UIColor.systemBackground.cgColor tableView.layer.cornerRadius = 10 tableView.clipsToBounds = true tableView.rowHeight = 44 tableView.delegate = self tableView.dataSource = self tableView.translatesAutoresizingMaskIntoConstraints = false tableView.removeExcessCells() NSLayoutConstraint.activate([ tableView.topAnchor.constraint(equalTo: loginTitleLabel.bottomAnchor, constant: padding), tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: padding), tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -padding), tableView.heightAnchor.constraint(equalToConstant: 88) ]) tableView.register(UHTableTextFieldCell.self, forCellReuseIdentifier: UHTableTextFieldCell.reuseID) } func updateUI() { DispatchQueue.main.async { self.tableView.reloadData() self.view.bringSubviewToFront(self.tableView) } } } extension LoginViewController: UITableViewDelegate, UITableViewDataSource{ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 2 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: UHTableTextFieldCell.reuseID, for: indexPath) as! UHTableTextFieldCell let titles = loginTableTitle[indexPath.row] cell.set(title: titles) cell.titleLabel.font = UIFont.systemFont(ofSize: 16, weight: .bold) cell.tableTextField.delegate = self return cell } } Again thank you all so much for your help. If you need more clarification on this let me know.
Posted Last updated
.
Post not yet marked as solved
0 Replies
31 Views
In Xcode Version 15.3 (15E204a) I am getting this warning: Class AKAlertImageURLProvider is implemented in both /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AuthKit.framework/AuthKit (0x123719508) /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AuthKitUI.framework/AuthKitUI One of the two will be used. Which one is undefined. and also objc[2875]: Class AKBiometricRatchetUtility is implemented in both /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AuthKit.framework/AuthKit (0x12371ab10) and /Library/Developer/CoreSimulator/Volumes/iOS_21E213/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AuthKitUI.framework/AuthKitUI (0x152a1d810). One of the two will be used. Which one is undefined.
Posted Last updated
.
Post not yet marked as solved
1 Replies
39 Views
I'm currently trying to develop a l2cap demo application where I want to send data to a bluetooth chip over l2cap. I'm able to send several packet from the iPhone to the bluetooth chip. The chip send back credits and the iPhone continue to send data. After a moment suddenly the outputstream crash and rise a error that I'm not able to interpret. here is the error raised : /Users/13fmeyer/Documents/Screenshot 2024-05-07 at 15.15.37.png Here is the section of the code that manage the write : /Users/13fmeyer/Documents/Screenshot 2024-05-07 at 15.16.49.png and the write method : /Users/13fmeyer/Documents/Screenshot 2024-05-07 at 15.17.20.png Finally it close the act connection and stop the transmission. Does somebody have any idea about what happen ?
Posted
by fmeyer.
Last updated
.
Post not yet marked as solved
1 Replies
24 Views
I'm trying to get my iOS app ready for distribution, but after running Product->Archive and clicking Validate App, XCode does a few steps of validation and then crashes without finishing. Here's the top of the crash log, I can reproduce easily and get the full report if needed. This is a blocker for me and I really need a solution. Translated Report (Full Report Below) ------------------------------------- Process: Xcode [93086] Path: /Applications/Xcode.app/Contents/MacOS/Xcode Identifier: com.apple.dt.Xcode Version: 15.3 (22618) Build Info: IDEApplication-22618000000000000~2 (15E204a) App Item ID: 497799835 App External ID: 863955376 Code Type: ARM-64 (Native) Parent Process: launchd [1] User ID: 501 Date/Time: 2024-05-07 09:20:28.9493 +0200 OS Version: macOS 14.4.1 (23E224) Report Version: 12 Anonymous UUID: 3BF4943C-9199-C215-F9AB-59223913BAC9 Sleep/Wake UUID: 0AFCFDE1-E734-4B4D-88F6-72BC777F81CB Time Awake Since Boot: 650000 seconds Time Since Wake: 2935 seconds System Integrity Protection: enabled Crashed Thread: 0 Dispatch queue: archive info plist lock Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 6 Abort trap: 6 Terminating Process: Xcode [93086] Application Specific Information: com.apple.main-thread abort() called Application Specific Signatures: NSInvalidArgumentException Application Specific Backtrace 0: 0 CoreFoundation 0x000000019d59eccc __exceptionPreprocess + 176 1 DVTFoundation 0x00000001044dcbc4 DVTFailureHintExceptionPreprocessor + 388 2 libobjc.A.dylib 0x000000019d086788 objc_exception_throw + 60 3 CoreFoundation 0x000000019d4b67d0 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 728 4 CoreFoundation 0x000000019d4b64cc +[NSDictionary dictionaryWithObjects:forKeys:count:] + 52 5 IDEFoundation 0x0000000109a58a34 -[IDEArchiveDistributionRecord dictionaryRepresentation] + 296 6 IDEFoundation 0x0000000109a3a21c __31-[IDEArchive setDistributions:]_block_invoke + 16 7 DVTFoundation 0x00000001044d4700 -[NSArray(DVTFoundationClassAdditions) dvt_arrayByApplyingBlock:] + 224 8 IDEFoundation 0x0000000109a3a1ac -[IDEArchive setDistributions:] + 84 9 Foundation 0x000000019e624370 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 608 10 Foundation 0x000000019e64da24 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 64 11 Foundation 0x000000019e667688 _NSSetObjectValueAndNotify + 284 12 IDEFoundation 0x0000000109a39fa4 __36-[IDEArchive addDistribution:error:]_block_invoke + 156 13 libdispatch.dylib 0x000000019d29a3e8 _dispatch_client_callout + 20 14 libdispatch.dylib 0x000000019d2a98d8 _dispatch_lane_barrier_sync_invoke_and_complete + 56 15 DVTFoundation 0x000000010452127c DVTDispatchBarrierSync + 148 16 DVTFoundation 0x00000001044fd024 -[DVTDispatchLock performLockedBlock:] + 60 17 IDEFoundation 0x0000000109a39dcc -[IDEArchive addDistribution:error:] + 200 18 IDEFoundation 0x00000001099e05f4 __41-[IDEDistributionValidationStep validate]_block_invoke + 116 19 DVTFoundation 0x0000000104520598 __DVT_CALLING_CLIENT_BLOCK__ + 16 20 DVTFoundation 0x0000000104520d70 __DVTSyncPerformBlock_block_invoke + 68 21 CoreFoundation 0x000000019d529a48 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28 22 CoreFoundation 0x000000019d52995c __CFRunLoopDoBlocks + 356 23 CoreFoundation 0x000000019d528dec __CFRunLoopRun + 2440 24 CoreFoundation 0x000000019d527e0c CFRunLoopRunSpecific + 608 25 HIToolbox 0x00000001a7cc3000 RunC
Posted
by hrydgard.
Last updated
.
Post not yet marked as solved
0 Replies
17 Views
import SwiftUI import TipKit @main struct TipKit_WithPresentPageApp: App { var body: some Scene { WindowGroup { ContentView() .task { try? Tips.resetDatastore() try? Tips.configure([ .datastoreLocation(.applicationDefault) ]) } } } } import SwiftUI struct ContentView: View { @State private var isPresented: Bool = false var body: some View { NavigationStack { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) .popoverTip(MyTip()) .padding(100) Button("Hit Me!") { isPresented.toggle() // When the TipKit notification appears, the 'present sheet' button will be non-functional. (iPhone SE and simulator devices) } .padding() .sheet(isPresented: $isPresented) { PresentPage() } } } } } import SwiftUI struct PresentPage: View { var body: some View { Text("Hello, world again!") .font(.title) } } import TipKit struct MyTip: Tip { var title: Text { Text("Test") } var message: Text? { Text("Hi") } } When the TipKit notification appears, the 'present sheet' button will be non-functional. (iPhoneSE Landscape Right) When using the iPhone SE (Landscape Right) or its simulator (iPhone SE Landscape Right), running iOS 17.2. Whenever the TipKit notification is triggered and displayed on the screen, the 'present sheet' button, which is typically used for presenting a new sheet within the app, becomes non-functional. Device: iPhoneSE iOS 17.2 Does anyone know how to bypass this bug? Thank you.
Posted Last updated
.
Post not yet marked as solved
0 Replies
18 Views
The app downloads assets consisting of custom fonts using tags from On-Demand Resources, registers them in the system font, and provides them to other apps such as Freeform through UIFontPickerViewController. Custom Fonts that were applied well until iOS 16 appear as Helvetica starting from iOS 17 and cannot be used. As the font list appears in the device's Settings > General > Font, the font downloaded from On-Demand Resources is registered in the system font. It has been confirmed to occur particularly frequently starting from iPhone 15 and iOS 17 and above. The app requests download from On-Demand Resources with NSBundleResourceRequest along with tags, receives assets in response with conditionally beginAccessingResources and beginAccessingResources, and then registers them in the system using CTFontManagerRegisterFontURLs.
Posted Last updated
.
Post not yet marked as solved
0 Replies
28 Views
My project was working fine on xcode 14 for ios 16 simulators and real devices with all setup and pods, recently i updated system for xcode 15, and sicne then on build getting this error for simulator and real devices - Driver threw unknown argument: '-bvvutkjqcsvcmlfdhxkrjtgqdzeg/Build/Intermediates.noindex/' without emitting errors. i did everyting - clean ,deep clean, restart, update cocoapod, all pods update, deintegrate - install again, delete cache, delete derived data btw - this- bvvutkjqcsvcmlfdhxkrjtgqdzeg/Build/Intermediates.noindex/ is a file getting generated in derived data - and in log getting this also - error: Driver threw unknown argument: '-bvvutkjqcsvcmlfdhxkrjtgqdzeg/Build/Intermediates.noindex/' without emitting errors. (in target 'fabfinance' from project ' ') this is my pod file - # Uncomment the next line to define a global platform for your project # platform :ios, '13.0' target 'fabfinance' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! # Pods for fabfinance pod 'Alamofire' pod 'SwiftyJSON' pod 'PopupDialog' pod 'JMImageCache' #pod 'Firebase/Analytics' #pod 'Firebase/Messaging' #pod 'Firebase/Crashlytics' #pod 'Firebase/Core' #pod 'Firebase/Auth' pod 'SOTabBar' pod 'MaterialComponents' pod 'IQKeyboardManagerSwift' pod 'DropDown' pod 'DLRadioButton', '~> 1.4' pod 'ADCountryPicker', '~> 2.1.0' pod 'MDFInternationalization' pod 'SDWebImage' pod 'ProgressHUD' pod 'DatePickerDialog' pod 'PhoneNumberKit' pod 'Charts' target 'fabfinanceTests' do inherit! :search_paths # Pods for testing end target 'fabfinanceUITests' do # Pods for testing end end post_install do |installer| installer.generated_projects.each do |project| project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' end end end end
Posted Last updated
.
Post not yet marked as solved
2 Replies
89 Views
I am trying to create an iOS app where I need to immediately know when the iPhone is unlocked. Let's say I want to print a log on the Xcode console whenever the phone is unlocked. From my app, how do I detect if the phone is unlocked? Some code pointers will be highly appreciated. I am a newbie in iOS/APP development. It should work even if my app is not running. Is it even possible to do so?
Posted Last updated
.
Post not yet marked as solved
0 Replies
56 Views
Ever since I received the latest Beta update I have not been able to use CarPlay via a cord to my car (I've tried multiple cords with the same result). It has been working as expected since I bought the car a few years ago. I've tried multiple other Apple phones and they have no issue, so I know it's not my car's software. I have called apple support and they gave me instructions on how to uninstall the Beta software, which has also not been successful. I entered a ticket for this issue on April 22nd, but haven't heard anything back. Anyone have suggestions on how I can get my CarPlay to work? or how to uninstall successfully from the Beta ios?
Posted Last updated
.
Post not yet marked as solved
1 Replies
86 Views
Hello, I'll be objective: when I compile any APP in my XCode and transfer the APP to my iPhone, including the test APP "Hello world!", whether via network or USB cable, when I open the APP it simply doesn't work and the iPhone crashes. Only that. My XCode is 15.3, iPhone 14 Pro Max, IOS 17.5, macOS latest version.
Posted Last updated
.
Post not yet marked as solved
0 Replies
51 Views
I am looking forward to develop an ecommerce IOS application. When I conducted my research for the same I found that offshore developers are offering solutions in quite less price compare to onshore developers. At the same time I also have some doubts over offshore development such as reliability, quality, collaboration and more.. Anyone can suggest me what would be the best in long term.
Posted Last updated
.
Post not yet marked as solved
0 Replies
59 Views
Our current status is that after three minutes or more in the background, re-opening the app is a restart. Most of the users are claiming that they were automatically redirected to the home page of our app after a certain period of inactivity in the app. I recently upgraded my Xcode version from 12.4 to 15.3. I did not experience the problem with Xcode 12.4. It is an enterprise application, and the majority of users report restart issues. It occurred at random, and the user device contained only our application, with no other app like entertainment or gaming apps. However, I notice that many other apps are running in the background for an extended period of time (such as 20 minutes or 30 minutes). When I open the app, the same page sometimes appears in the background or the app is refreshed (like, Medium) I am not sure how they do it; I follow Apple. The rules did not do anything after entering the background. Is there anything Apple could do? How can I resolve this issue? Or it is default iOS behaviour. Please provide any documentation related to this. Please help me resolve this issue. Note: iOS device Version 15 to 17 is the latest
Posted Last updated
.
Post not yet marked as solved
1 Replies
86 Views
Hi everyone, I'm working on an iOS app where I need to implement content filtering functionality. I've successfully implemented a network extension target in my iOS app to filter data locally. However, I'm now aiming to extend this functionality to filter content over HTTPS. Currently, I'm utilizing a local data source for filtering, but I want to explore options for filtering content directly over HTTPS connections, like this URL: https://dns.nextdns.io/46d65d. I've reviewed the available Apple APIs and documentation but haven't found a straightforward solution for HTTPS content filtering. Can anyone provide guidance or suggest any relevant resources for implementing HTTPS content filtering within a network extension target on iOS? Any help or insights would be greatly appreciated! Thank you in advance!
Posted Last updated
.
Post not yet marked as solved
0 Replies
57 Views
I want to change the display language, particularly for week and the year and date on MultiDatePicker. By adjusting the locale, the year and date can be changed. However, I'm unable to change the display for week . I've tried several methods, such as setting the calendar and adjusting the time zone, but none of them seem to work. Are there any good way to solve it?
Posted
by hcrane.
Last updated
.
Post not yet marked as solved
0 Replies
101 Views
I created a PWA that requires access to users' geolocation to perform a certain action in the system. The correct operation would be the user opens the application, and then the operating system prompts them to allow sharing their exact location with the PWA. However, this is not happening with a few users who have iPhone 11 or XR. I tested it on iPhones 14, 13, 11 Pro, and even iPhone 6, and it works as expected. I directly spoke with a user who was experiencing the problem and conducted some tests. I checked if location access was allowed in the settings. I verified if Safari was accepting with the option to always ask selected. In the settings of my system's website, I checked if location access was allowed with the option to always ask chosen. We changed all prompting options to allow. We opened the following site https://whatpwacando.today/ and found that geolocation was also not possible. Everything indicates that the issue lies with these users' phones; however, other geolocation methods work fine, as other geolocation apps function properly. This leads me to think that it might be a problem with Safari not working properly with the HTML Geolocation API. I'm not sure if there are any more advanced settings that could help or if anyone else has encountered this issue.
Posted
by dariel26.
Last updated
.
Post not yet marked as solved
0 Replies
124 Views
I added debug break point to the first line of MyDeviceActivityMonitor.swift, it never got trigger. I am able to launch the app, select discouraged and encouraged app. discouraged apps are getting restricted which is expected. but device activity extension is never called. I have all the permission and certificate. I created an app group. import SwiftUI import FamilyControls import ManagedSettings @main struct GetALifeApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate @StateObject var model = MyModel.shared @StateObject var store = ManagedSettingsStore() var body: some Scene { WindowGroup { ContentView() .environmentObject(model) .environmentObject(store) } } } class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { initiateAsyncSetup() MySchedule.setSchedule() return true } private func initiateAsyncSetup() { Task { do { try await AuthorizationCenter.shared.requestAuthorization(for: .individual) } catch { print("Error during asynchronous setup: \(error)") } } } } import Foundation import FamilyControls import ManagedSettings private let _MyModel = MyModel() class MyModel: ObservableObject { let store = ManagedSettingsStore() @Published var selectionToDiscourage: FamilyActivitySelection @Published var selectionToEncourage: FamilyActivitySelection init() { selectionToDiscourage = FamilyActivitySelection() selectionToEncourage = FamilyActivitySelection() } class var shared: MyModel { return _MyModel } func setShieldRestrictions() { let applications = MyModel.shared.selectionToDiscourage store.shield.applications = applications.applicationTokens.isEmpty ? nil : applications.applicationTokens store.shield.applicationCategories = applications.categoryTokens.isEmpty ? nil : ShieldSettings.ActivityCategoryPolicy.specific(applications.categoryTokens) } } import Foundation import DeviceActivity extension DeviceActivityName { static let daily = Self("daily") } extension DeviceActivityEvent.Name { static let encouraged = Self("encouraged") } let schedule = DeviceActivitySchedule( intervalStart: DateComponents(hour: 0, minute: 0), intervalEnd: DateComponents(hour: 23, minute: 59), repeats: true ) class MySchedule { static public func setSchedule() { print("Setting schedule...") print("Hour is: ", Calendar.current.dateComponents([.hour, .minute], from: Date()).hour!) let events: [DeviceActivityEvent.Name: DeviceActivityEvent] = [ .encouraged: DeviceActivityEvent( applications: MyModel.shared.selectionToEncourage.applicationTokens, threshold: DateComponents(second: 2) ) ] let center = DeviceActivityCenter() do { print("Try to start monitoring...") print(events) try center.startMonitoring(.daily, during: schedule, events: events) } catch { print("Error monitoring schedule: ", error) } } } import SwiftUI struct ContentView: View { @State private var isDiscouragedPresented = false @State private var isEncouragedPresented = false @EnvironmentObject var model: MyModel var body: some View { VStack { Button("Select Apps to Discourage") { isDiscouragedPresented = true } .familyActivityPicker(isPresented: $isDiscouragedPresented, selection: $model.selectionToDiscourage) Button("Select Apps to Encourage") { isEncouragedPresented = true } .familyActivityPicker(isPresented: $isEncouragedPresented, selection: $model.selectionToEncourage) } .onChange(of: model.selectionToDiscourage) { MyModel.shared.setShieldRestrictions() } .onChange(of: model.selectionToEncourage) { MySchedule.setSchedule() } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() .environmentObject(MyModel()) } } import Foundation import DeviceActivity import ManagedSettings class MyDeviceActivityMonitor: DeviceActivityMonitor { let store = ManagedSettingsStore() override func intervalDidStart(for activity: DeviceActivityName) { print("intervalDidStart") super.intervalDidStart(for: activity) store.shield.applications = nil print("intervalDidStart") } override func intervalDidEnd(for activity: DeviceActivityName) { super.intervalDidEnd(for: activity) } override func eventDidReachThreshold(_ event: DeviceActivityEvent.Name, activity: DeviceActivityName) { super.eventDidReachThreshold(event, activity: activity) print("used encouraged") store.shield.applications = nil } override func intervalWillStartWarning(for activity: DeviceActivityName) { super.intervalWillStartWarning(for: activity) // Handle the warning before the interval starts. } override func intervalWillEndWarning(for activity: DeviceActivityName) { super.intervalWillEndWarning(for: activity) // Handle the warning before the interval ends. } override func eventWillReachThresholdWarning(_ event: DeviceActivityEvent.Name, activity: DeviceActivityName) { super.eventWillReachThresholdWarning(event, activity: activity) // Handle the warning before the event reaches its threshold. } }
Posted Last updated
.
Post not yet marked as solved
0 Replies
68 Views
I am new to swift. This is my first app. What an i doing wrong. Device activity monitor extension is never being called. When i launch the app, I am able to pick the discouraged and encouraged apps. It immediately restrict the discouraged app which is expected. But the extension is never called. import SwiftUI import FamilyControls import ManagedSettings @main struct GetALifeApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate @StateObject var model = MyModel.shared @StateObject var store = ManagedSettingsStore() var body: some Scene { WindowGroup { ContentView() .environmentObject(model) .environmentObject(store) } } } class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { initiateAsyncSetup() return true } private func initiateAsyncSetup() { Task { do { try await AuthorizationCenter.shared.requestAuthorization(for: .individual) MySchedule.setSchedule() } catch { print("Error during asynchronous setup: \(error)") } } } } import Foundation import FamilyControls import ManagedSettings private let _MyModel = MyModel() class MyModel: ObservableObject { let store = ManagedSettingsStore() @Published var selectionToDiscourage: FamilyActivitySelection @Published var selectionToEncourage: FamilyActivitySelection init() { selectionToDiscourage = FamilyActivitySelection() selectionToEncourage = FamilyActivitySelection() } class var shared: MyModel { return _MyModel } func setShieldRestrictions() { let applications = MyModel.shared.selectionToDiscourage store.shield.applications = applications.applicationTokens.isEmpty ? nil : applications.applicationTokens store.shield.applicationCategories = applications.categoryTokens.isEmpty ? nil : ShieldSettings.ActivityCategoryPolicy.specific(applications.categoryTokens) } } import Foundation import DeviceActivity extension DeviceActivityName { static let daily = Self("daily") } extension DeviceActivityEvent.Name { static let encouraged = Self("encouraged") } let schedule = DeviceActivitySchedule( intervalStart: DateComponents(hour: 0, minute: 0), intervalEnd: DateComponents(hour: 23, minute: 59), repeats: true ) class MySchedule { static public func setSchedule() { print("Setting schedule...") print("Hour is: ", Calendar.current.dateComponents([.hour, .minute], from: Date()).hour!) let events: [DeviceActivityEvent.Name: DeviceActivityEvent] = [ .encouraged: DeviceActivityEvent( applications: MyModel.shared.selectionToEncourage.applicationTokens, threshold: DateComponents(second: 2) ) ] let center = DeviceActivityCenter() do { print("Try to start monitoring...") try center.startMonitoring(.daily, during: schedule, events: events) } catch { print("Error monitoring schedule: ", error) } } } import SwiftUI struct ContentView: View { @State private var isDiscouragedPresented = false @State private var isEncouragedPresented = false @EnvironmentObject var model: MyModel var body: some View { VStack { Button("Select Apps to Discourage") { isDiscouragedPresented = true } .familyActivityPicker(isPresented: $isDiscouragedPresented, selection: $model.selectionToDiscourage) Button("Select Apps to Encourage") { isEncouragedPresented = true } .familyActivityPicker(isPresented: $isEncouragedPresented, selection: $model.selectionToEncourage) } .onChange(of: model.selectionToDiscourage) { newSelection in MyModel.shared.setShieldRestrictions() } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() .environmentObject(MyModel()) } } import Foundation import DeviceActivity import ManagedSettings class MyDeviceActivityMonitor: DeviceActivityMonitor { let store = ManagedSettingsStore() override func intervalDidStart(for activity: DeviceActivityName) { print("intervalDidStart") super.intervalDidStart(for: activity) store.shield.applications = nil print("intervalDidStart") } override func intervalDidEnd(for activity: DeviceActivityName) { super.intervalDidEnd(for: activity) } override func eventDidReachThreshold(_ event: DeviceActivityEvent.Name, activity: DeviceActivityName) { super.eventDidReachThreshold(event, activity: activity) print("used encouraged") store.shield.applications = nil } override func intervalWillStartWarning(for activity: DeviceActivityName) { super.intervalWillStartWarning(for: activity) // Handle the warning before the interval starts. } override func intervalWillEndWarning(for activity: DeviceActivityName) { super.intervalWillEndWarning(for: activity) // Handle the warning before the interval ends. } override func eventWillReachThresholdWarning(_ event: DeviceActivityEvent.Name, activity: DeviceActivityName) { super.eventWillReachThresholdWarning(event, activity: activity) // Handle the warning before the event reaches its threshold. } }
Posted Last updated
.
Post not yet marked as solved
0 Replies
52 Views
I have added the Journaling Suggestions capability and now I am trying to import journaling suggestions in my app so I can use it, but I am getting the ' No such Module' error, I have quit Xcode and opened it again, I am getting the same issue . I am running Xcode version 15.3
Posted Last updated
.
Post marked as solved
1 Replies
132 Views
Hello. I'm trying to copy files to iOS device into my app's data container from mac and I can't get user name right. What is my user name? I have tried user name as I see it in Settings and also tried my apple ID with no luck. I use the following command: xcrun devicectl device copy to --device VALID_DEVICE_ID --domain-type appDataContainer --user "WHAT SHOULD BE HERE?" --domain-identifier VALID_BUNDLE_ID --source Data.zip --destination Documents/Data.zip Thank you in advance!
Posted
by xAlexDevx.
Last updated
.
Post not yet marked as solved
2 Replies
116 Views
I am trying to disable the screenshot on iOS app but apple does not expose any api for this. Due to which I added a workaround when iPhone will try to take screenshot we have a textfield in secured way which will cover the whole screen and screenshot will be blank. Does anyone tried the same approach to avoid screenshot? if yes did apple act against those application or they reject if they find. It will be great help if Apple can provide us some insight on it.
Posted Last updated
.