Will there be any restrictions/Limitations on publishing iOS applications that internally run Python scripts on the App Store during the Apple Review process?
Dive into the world of programming languages used for app development.
Post
Replies
Boosts
Views
Activity
Hello -
I’m creating an app that needs to copy ColorSync profiles to the /Library/ColorSync/Profiles directory on macOS and was wondering what is the correct / sanctioned way to write to the /Library directory is?
The app won’t be in the App Store. The app needs to run on Big Sur through Sonoma.
I spent some time working with ColorSyncProfileInstall() but that seems to want to ask the user permission every single time the function is called - and this app can install up to 25 profiles at a time. (There are actually hundreds of profiles that can be chosen that will come from a server).
I’m currently looking at using SMJobBless but that sure seems like using an atomic bomb to swat a mosquito. Any thoughts if SMJobBless is the right way to go? (SMAppService for 13 and on).
Thanks!
Hi, I was wondering if it was possible to get a notification when there is a change to the forced defaults that my app uses. This forced defaults are sent via MDM using the com.apple.ManagedClient.preferences payload type. I've seen that UserDefaults.didChangeNotification is available but it only works if the change is made from inside the app and not if the payload gets updated by the MDM.
class MySettings {
private let defaults = UserDefaults(suiteName: "com.myapp.app.mysettings")
init() {
// Somehow register for notifications
}
func defaultsChanged() {
// This would be called when the defaults change
}
}
import UIKit
import PDFKit
import MobileCoreServices
import UniformTypeIdentifiers
class ViewController: UIViewController, PDFViewDelegate, UIDocumentPickerDelegate, UITableViewDataSource, UITableViewDelegate {
let pdfView = PDFView()
var PDFFiles: [URL] = []
var tableView: UITableView!
var tableDataSource: MyTableDataSource!
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = "test"
self.navigationController?.setNavigationBarHidden(false, animated: false)
view.backgroundColor = UIColor.white
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Import", image: UIImage(systemName: "square.and.arrow.down"), target: self, action: #selector(importButton))
// TableView Setup
tableView = UITableView(frame: view.bounds)
tableView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
tableDataSource = MyTableDataSource()
tableView.dataSource = tableDataSource
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "PDFCell")
tableView.delegate = self
view.addSubview(tableView)
}
@objc private func importButton() {
let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.data], asCopy: true)
documentPicker.delegate = self
documentPicker.allowsMultipleSelection = true
present(documentPicker, animated: true, completion: nil)
}
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
for url in urls {
print("Imported file URL: \(url)")
PDFFiles.append(url)
}
print("Numbers of files after import: \(PDFFiles.count)")
DispatchQueue.main.async { [weak self] in
self?.tableView.reloadData()
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return PDFFiles.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "PDFCell", for: indexPath)
let fileName = PDFFiles[indexPath.row].lastPathComponent
cell.textLabel?.text = fileName
return cell
}
}
This is my code and I am getting this error.
The view service did terminate with error: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method}
can I get some help?
I'm currently working on a SwiftUI widget and have run into an unexpected issue. The image displays as expected (and worked correctly on iOS16), however on iOS17 I have unwanted padding on the left and right of my background image and can't figure out the cause. The padding appears even though I haven't explicitly added any to the design. This behaviour exists even if I have a solid coloured background. It's as though the ZStack doesn't fill the entire widget of the widget space.
Here's a snippet of the code I'm working with:
case .systemMedium:
ZStack {
Image(uiImage: entry.tripImg ?? UIImage())
.resizable()
.scaledToFill()
Text("BG image should fill")
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
I've tried various solutions to remove the padding, but nothing seems to work. I'm not sure if it's a default SwiftUI behavior or if I've missed something in my code.
Has anyone else encountered this issue with SwiftUI widgets? I'd appreciate any insights or advice on how to resolve this.
Thank you in advance!
HI, i am new to IOS development.
I work with Xcode 15.0, and IOS 17.0.3
I want to write an app to control a small robot using bluetooth.
I get the following error message :
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSBluetoothAlwaysUsageDescription key with a string value explaining to the user how the app uses this data.
However, in my infpo.plist, i have the following settings :
<dict>
<key>NSBluetoothAlwaysUsageDescription</key>
<array>
<string>This application requires Bluetooth to connect to the roboter</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
</array>
</dict>
</dict>
</dict>
The project section looks like this :
Any ideas ?
Hello Apple Developer Forum community,
I'm exploring the possibilities of mixing Swift and C++ for a project that involves VisionOS. The Swift official documentation on Mixing Swift and C++ mentions that C++ interoperability is supported for development and deployment on all platforms that Swift supports.
I would like to confirm whether this support extends to VisionOS. Does VisionOS allow the use of C++ APIs, and how can various C++ APIs be effectively imported and used in Swift for VisionOS development?
If anyone has experience or insights related to mixing Swift and C++ specifically for VisionOS, I would greatly appreciate your guidance and advice.
Thank you for your assistance.
Best regards,
I am trying to load two immersive spaces and I am getting errors because of trying to have both open at the same time. Is the only way in this case to create multiple Volumetric Windows to display 3D models on the stage? Or is there a way to maintain two immersive spaces at once? As far as I know, there are only three ways to display 3D models: Windows, Volumetric Windows, and Immersive Spaces.
I'm facing an issue with background scanning of Bluetooth on devices with iOS 15.7.3. I'm developing an application that needs to discover BLE devices even in the background mode. However, the didDiscover method is not getting called during background scanning.
Here's what I've already checked and configured in my project:
Appropriate permissions for Bluetooth usage and background processing are in place.
Flags in the project settings for background processing are configured correctly.
I've verified that BLE devices are set up for advertising in the background.
There are no physical obstacles or interference; devices and BLE devices are in an open environment.
Additional details and conditions:
The application initiates background scanning in the applicationDidEnterBackground method.
At the beginning of the test, the BLE device is not accessible. I bring it near the iPhone after approximately 5 minutes of the app being in the background.
If I don't move the BLE device away from the iPhone, it is detected almost immediately after the app goes into the background, but only once.
The phone screen doesn't lock during the test.
The CBCentralManagerOptionRestoreIdentifierKey option is used in the CBCentralManager.
On an iPhone 12 mini with iOS 16.3.1, background scanning works, but the device is found only once for call scanForPeripherals method.
The following filters are used: CBUUID(string: "330C5AD1-7261-4F06-B87C-0F6342365C2E") and CBUUID(string: "4c6607e0-2c3d-4fca-b201-0246773d6e9c").
If during the test you go to the Bluetooth settings of the iPhone (where there is a search for devices), the didDiscover method begins to report found devices
Advertisement data for BLE looks like this
7 elements
0 : 2 elements
key : "kCBAdvDataServiceUUIDs"
value : 1 element
0 : 4C6607E0-2C3D-4FCA-B201-0246773D6E9C
1 : 2 elements
key : "kCBAdvDataRxSecondaryPHY"
value : 0
2 : 2 elements
key : "kCBAdvDataTimestamp"
value : 719149435.0168051
3 : 2 elements
key : "kCBAdvDataLocalName"
value : GB3_0CCE
4 : 2 elements
key : "kCBAdvDataRxPrimaryPHY"
value : 0
5 : 2 elements
key : "kCBAdvDataServiceData"
value : 1 element
0 : 2 elements
key : 330C5AD1-7261-4F06-B87C-0F6342365C2E
value : \<01020304\>
6 : 2 elements
key : "kCBAdvDataIsConnectable"
value : 1
Here is a link to the repository with the test application. This is a test application that I use for testing. The repository contains code that is not needed for testing. The required classes for testing are AppConfiguration, BackgroundScanManager, and BackgroundBLEManager.
After bringing the BLE device near the iPhone, I wait for approximately 15-20 minutes.
Please, help me understand why the didDiscover method is not being called in the background mode on iOS 15.7.3. Perhaps someone has encountered a similar problem and can provide advice or recommendations?
Thank you very much!
Trying to integrate the new screencapturekit into our application.
The stand alone test we made works fine, however when integrated, when we start the stream capture we get this error in the logs
(ScreenCaptureKit) [ERROR] _SCStream_RemoteAudioQueueOperationHandlerWithError:1032 Error received from the remote queue -16665
Any insights what might be causing this?
this is what we're passing addStreamOutput
private let sampleQueue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".SampleQueue")
self.stream = SCStream(filter: filter, configuration: self.streamConfig, delegate: self)
do {
try self.stream?.addStreamOutput(self, type: .screen, sampleHandlerQueue: self.sampleQueue)
}
We have the whole handlers and what not, pretty much verbatim from the apple provided sample
I have a WatchOS app with scrollable views. Depending on the state of the app I would like to receive crown rotation events.
To achieve this behavior I have set up a timer that calls the focus() method of the crownSequencer.
In the Apple Watch simulator in XCode the app behaves consistently and there are no problems. However, some users (not all) report that rotating the crown does not work. What could be the reason for this behavior?
Here is the relevant code:
import WatchKit
import Foundation
import HealthKit
class MyInterfaceController: WKInterfaceController {
var controlTimer: Timer?;
var restTimer: Timer?;
var timer: Timer?;
override func awake(withContext context: Any?) {
super.awake(withContext: context)
setupTimers()
}
override func willActivate() {
super.willActivate()
setupTimers()
}
override func didAppear() {
super.didAppear()
setupTimers()
}
func setupTimers() {
clearTimers()
restTimer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true, block: { _ in
// Do something
});
timer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true, block: { _ in
// Do something
});
controlTimer = Timer.scheduledTimer(withTimeInterval: 0.2, repeats: true, block: { _ in
if (someCondition == false) {
self.crownSequencer.resignFocus()
} else {
self.crownSequencer.delegate = self
self.crownSequencer.focus()
}
});
}
func clearTimers() {
controlTimer?.invalidate()
controlTimer = nil
restTimer?.invalidate()
restTimer = nil
timer?.invalidate()
timer = nil
}
}
extension MyInterfaceController : WKCrownDelegate {
func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double) {
if (rotationalDelta > 0.2) {
// Do something
} else if (rotationalDelta < -0.2) {
// Do something
}
}
}
Environment→
・Device: iPad 9th generation
・OS: iOS17.0.3
・Printer model: EPSON PX-S730
What I want→
I would like to programmatically use the AirPrint API to directly print from my application to a selected printer specifying the printing as single-side
Current issues →
After updating the iOS from 16.6.1 to 17 version, when printing programmatically using the AirPrint API, even setting the print options as single-side, it end up printing on double- side.
Issue description→
When I run the code below on iOS16.6.1, it prints on single-side,** but after updating to iOS17.0.3, It’s always printing on double-sides.**
Also, the Apple Developer Documentation says that the print method disables duplex printing and it's describe in below URL:
https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/1618174-print
Test code:
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.jobName = "Print Job"
printController.printInfo = printInfo
let pdfURL = Bundle.main.url(forResource: "sample", withExtension: "pdf")!
printController.printingItem = pdfURL
let printer = UIPrinter(url: printerUrl)
printController.print(to: printer, completionHandler: { [self] printController, completed, error in
if(error != nil){
print("error")
}else if completed{
print("completed")
}else{
print("cancel")
}
})
Does anyone knows if it's a bug in iOS17 or am I missing something?
Environment→
・Device: iPad 9th generation
・OS:**iOS17.0.3
・Printer model:EPSON PX-S730
What I want→
I would like to return an error when I submit a printing job, if the printer is not properly connected to the same WIFI as iPad(iOS17).
Current issues→
When I run the below code in iOS17, I was able to successfully submit a print job to printer and, printer returns completed(true) as the result. In iOS16 print job return as an error to the same below code.
Problem Description→
In iOS 16.6.1 when you know the correct printer access URL and submit a print job without connecting to the same WIFI as the printer, job return as an error.(return to the error code segment in the below code)
But after I updated the app to iOS 17.0.3 and run the same job, it's not returning as an error.(it returns to the completed block in the below code segment and completed Boolean value is true. )
When you check the "Print Summary" window in iPad, the status of the print job is Waiting.
So I would like to handle this process in the same way like iOS16 in iOS17. I would like to Print Job to return as a error when printer and iPad not connected to same WIFI(error like "cannot connect to the printer")
Test code:
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.jobName = "Print Job"
printController.printInfo = printInfo
let pdfURL = Bundle.main.url(forResource: "sample", withExtension: "pdf")!
printController.printingItem = pdfURL
let printer = UIPrinter(url: printerUrl)
printController.print(to: printer, completionHandler: { [self] printController, completed, error in
if(error != nil){
print("error")
}else if completed{
print("completed")
}else{
print("cancel")
}
})
Does anyone knows if it's a bug in iOS17 or am I missing something?
I use NSPersistentCloudKitContainer to fetch/sync data across multiple devices with the same iCloud account.
/// ...
container = NSPersistentCloudKitContainer(name: containerName)
let description = container.persistentStoreDescriptions.first
description?.setOption(
true as NSNumber,
forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)
description?.setOption(
true as NSNumber,
forKey: NSPersistentHistoryTrackingKey)
let viewContext = container.viewContext
viewContext.automaticallyMergesChangesFromParent = true
viewContext.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump
NotificationCenter.default.addObserver(
forName: .NSPersistentStoreRemoteChange, object: container.persistentStoreCoordinator,
queue: .main
) { _ in
Task { @MainActor [weak self] in
// fetch new data and update widgets with it
// ... viewContext.fetch ...
// WidgetCenter.shared.reloadAllTimelines()
}
}
}
/// ...
Everything works fine when my app in the foreground. How can I achieve the same when my app is closed/ in the background? I know that CloudKit can send silent push notification which can wake up my app but I've never seen the implementation of it using CoreData NSPersistentCloudKitContainer
In Shortcuts, the Show Result action has two features that I cannot reproduce in my swift code.
Show Result can connect to the previous action's result automatically when it's added. In my code, I added inputConnectionBehavior: .connectToPreviousIntentResult to my parameter, but it won't work.
@Parameter(title: "input", supportedTypeIdentifiers: ["public.plain-text"], inputConnectionBehavior: .connectToPreviousIntentResult)
var input: IntentFile
The click of Result slot in Show Result allows users to select variable. In my code, the click of MyParameter will open the FileDialog rather than selecting variables.
So in whatever way I tried, I cannot make my action work exactly like the Show Result does.
I have a need to interoperate between cpp and swift. Here when we return a 'String' type from swift to cpp, the type that we receive in cpp is 'swift::string'.
I wanted to convert 'swift::string' to char* in cpp. Any help on how can this be achieved in cpp?
Hi Quinn,
I have a macOS App (SwiftUI) which scans for available WifiNetworks using
CWWiFiClient.shared().interface().scanForNetworks(withSSID: nil)
The app is sandboxed and has "Outgoing Connections" (Client) checked.
The app is Launched via a "LaunchAgents".
During app init() I kickoff the scanForNetworks in a background thread. I do receive WifiNetworks but when I look at the SSID quite often all of the SSIDs are nil.
If I loop the scanForNetworks() a few times with a delay of 1 second after a few tries the SSIDs will no longer be nil.
Any idea why this happens?
Should I file a bug report or is that expected behavior
Thanks very much,
Martin (your old friend from Germany)
In other languages, I am able to get current function's name using some kind of so-called reflection API. Does Swift provide similar API?
Error: The application's Info.plist does not contain a valid CFBundleVersion. Ensure your bundle contains a valid CFBundleVersion.
Hi all, I am new to app development, and all of a sudden after build successful, while launching the simulators (I have an app with iPhone and companion Watch app) the error appear.
I have added the version and the versionShort into the info.plist file, however I have noticed that in the DerivedData folder, there is a info.plist file that is different from the one I have in the project.
Please help.
I am currently writing an agent for endpoint security. I cannot connect the application and the xpc service. I start the plist with launchctl and then open the application, but it does not connect and the application runs dysfunctionally. I leave the code of the ViewController in the application and the XPCConnection in the xpc service below.
Note: I create the XPC service in Xcode like a normal application and write it as a service application with "Application is background only"
ViewController.swift
func establishConnection() {
XPCConnection.shared.connectToDaemon(bundle: Bundle.main, delegate: self) { success in
DispatchQueue.main.async { [self] in
if !success {
controlButton.isEnabled = false
configMenuStatus(start: false, stop: false)
alertWithError(error: "Unable to start monitoring for broken connection with daemon.")
} else {
Logger(.Info, "Connect to daemon successfully.")
}
}
}
}
XPCConnection.swift
func connectToDaemon(bundle: Bundle, delegate: ClientXPCProtocol, handler: @escaping (Bool) -> Void) {
guard connection == nil else {
Logger(.Info, "Client already connected.")
handler(true)
return
}
guard getMachServiceName(from: bundle) == ClientBundle else {
handler(false)
return
}
let newConnection = NSXPCConnection(machServiceName: DaemonBundle)
newConnection.exportedObject = delegate
newConnection.exportedInterface = NSXPCInterface(with: ClientXPCProtocol.self)
newConnection.remoteObjectInterface = NSXPCInterface(with: DaemonXPCProtocol.self)
newConnection.invalidationHandler = {
self.connection = nil
Logger(.Info, "Daemon disconnected.")
handler(false)
}
newConnection.interruptionHandler = {
self.connection = nil
Logger(.Error, "Daemon interrupted.")
handler(false)
}
connection = newConnection
newConnection.resume()
let proxy = newConnection.remoteObjectProxyWithErrorHandler { error in
Logger(.Error, "Failed to connect with error [\(error)]")
self.connection?.invalidate()
self.connection = nil
handler(false)
} as? DaemonXPCProtocol
proxy!.connectResponse(handler)
handler(true)
}
This is the error photo, the application continues to work
First, I checked to see if I had made a mistake in the bundle identifier, but I could not find an error, and then I realized that I had not run the launchd service. Then I ran it, but it did not make any sense. What I am trying to do is to connect and run the network extension and endpoint security with this service, but the xpc service does not connect to each other.