Post not yet marked as solved
When I instantiate a DateFormatter, the compiler says the result is optional, and I must unwrap it.
When I do, the compiler says the result is not optional, and I must remove all those !'s and ?'s.
Should be right
let _yyyy_mm_dd: DateFormatter = {
let retval = DateFormatter()
retval.dateFormat = "yyyy-MM-dd"
return retval
}()
extension Date {
public var ymd: String {
_yyyy_mm_dd.string(from: self)
}
}
This has happened with a couple of other types, but DateFormatter is easiest to demonstrate.
(Apple has from time to time warned that leading underscores are sacred to its frameworks, but in this case, renaming the formatter yyyy_mm_dd had no effect.)
Without the bangs (!), as shown above, swiftc flags a syntax error::
error-support.swift:83:5 Value of optional type 'DateFormatter?' must be unwrapped to refer to member 'dateFormat' of wrapped base type 'DateFormatter'
- Chain the optional using '?' to access member 'dateFormat' only for non-'nil' base values
- Force-unwrap using '!' to abort execution if the optional value contains 'nil'
The compiler offers FIXMEs which do exactly as the message suggests.
Let's try putting a bang after the initializer:
let retval = DateFormatter()!
Now I get
error-support.swift:82:33 Cannot force unwrap value of non-optional type 'DateFormatter'`
I invoke DateFormatter twice, with the same results. Attempting to unwrap the non-optional DateFormatter is a straightforward syntax error. But not unwrapping is flagged as an error, too (though it's non-fatal).
This is in a project of about 6500 lines of Swift (counted by cloc, no comments). It works as expected in a playground.
Paradox
Sometimes these errors go away spontaneously. Sometimes they fail the build. Mostly, the build succeeds anyway; the false alarms disappear, then "Build Succeeded," then the error flags reappaer, but do not interfere with execution.
I've done Product → Clear All Issues. I've cleaned the Build Folder repeatedly. A few times I deleted the build directory. All remove the flags. but the next build command shows both success and the error flags.
Meditiation
DateFormatter is an immediate subclass of NSObject, and has no (visible) override for init(). In principle, one could argue that if [self init] could fail, then so should a direct descendant. There is a universe in which init() would be failable, but not this one. It's supposed to be special-cased.
Plea
Can you suggest a way to put a stop to these false-alarm errors? We're used to noisy log entries, occasionally nuisance warnings. There shouldn't be nuisance errors.
Environment
Xcode 14.2 (14C18)
macOS 13.2 Ventura
MacBook Pro 16" (2021), M1.Pro
Memory pressure < 35%, 550 GB free, CPUs maybe above 250% for an instant or two.
Post not yet marked as solved
I need to upgrade a legacy (kext-based) networked audio driver which uses a custom Ethernet link layer protocol.
As far as I understand, the current approach is to use a Driver Extension for the Core Audio portion and a Network Extension to handle the custom Ethernet protocol.
Is this correct? If so, how should the interface between the Core Audio Dext and the Network Extension be implemented?
Thanks!
Post not yet marked as solved
Hello. I'm trying to enrol for Apple Developer Program. I have a valid D-U-N-S number, but when I fill in Legal Entity Name I am unable to fill (or paste) quot symbols, what result in "The information you entered did not match your D&B profile. Before submitting your information, check your D&B profile. If you've recently changed your legal entity name, update your D&B profile."
My company Legal Entity Name - JSC "EXPERO".
Can this issue be fixed somehow, or maybe I need to contact d&b support about changing entity name (making it without quotes)?
Thank you.
Post not yet marked as solved
Hello,
How do we support behaviors in out custom parameters in FxPlug?
A simple example would simply be recreating the float parameter.
Once we have done that we would like to support multi-dimensional vectors of floats.
Thanks,
Nikki
Post not yet marked as solved
We'd like to change the name of our app within the App Store, but keep the existing name that displays when a user downloads the app. i.e. the App Store name and the name on the app when it's downloaded would be different. How can we do that?
Post not yet marked as solved
I have a combobox in a View Controller that I am trying to populate using an enum. I did some research and think I've done it correct but whenever the view controller launches, I get an error Illegal NSComboBox data source.
I thought it may be an issue with the ComboBox (It was copied from another one in the View Controller) so I tried creating one from scratch but I am getting the same thing. I can populate the ComboBox using the addItem no problem.
The Combobox does have Use Data Source selected in the Storyboard. Here is my code;
enum Server_Locations: String, CaseIterable {
case us = "United States"
case canada = "Canada"
case other = "Other"
}
class PreferenceController: BaseVC, NSComboBoxDelegate, NSComboBoxDataSource {
@IBOutlet weak var countryComboBox: NSComboBox!
override func viewDidLoad() {
super.viewDidLoad()
countryComboBox.dataSource = self
countryComboBox.delegate = self
numberOfItemsInComboBoxCell(aComboBox: countryComboBox)
comboBoxCell(aComboBox: countryComboBox, objectValueForItemAtIndex: 0)
}
func numberOfItemsInComboBoxCell(aComboBox: NSComboBox) -> Int {
return Server_Locations.allCases.count
}
func comboBoxCell(aComboBox: NSComboBox, objectValueForItemAtIndex index: Int) -> AnyObject {
return Server_Locations.allCases[index].rawValue as AnyObject
}
It seems pretty straightforward but I'm obviously doing something wrong? I think the issue is in the calls to numberOfItemsInComboBoxCell and comboBoxCell
I've checked some examples online and they have referencing outlets to the delegate and the dataSource but I am defining them in the viewDidLoad().
I'm using Swift 5 in Storyboard mode with XCode 14.2
Post not yet marked as solved
Hi, I was looking through the APIs, specifically for Apple Search Ads and saw that there seems to be an API available for this but I can't work out if you can get data from Search Ads Basic or if it's just for Search Ads Advanced.
Does anyone know if this API exposes data from the basic version of ASA or is it just for data held within the advanced version?
Documentation: https://developer.apple.com/documentation/apple_search_ads
Thanks
Post not yet marked as solved
App translocation, officially known as Gatekeeper path randomisation, comes up from time-to-time. The best resource to explain it, WWDC 2016 Session 706 What’s New in Security, is no longer available from Apple so I thought I’d post some notes here (r. 105455698 ).
Questions or comments? Start a new thread here on DevForums, applying the Gatekeeper tag so that I see it.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
App Translocation Notes
Gatekeeper path randomisation, more commonly known as app translocation, is a security feature on macOS 10.12 and later. When you run a newly downloaded app, the system executes the app from a randomised path. This prevents someone from taking an app that loads code from an app-relative path and repackaging it to load malicious code.
IMPORTANT The best way to prevent your app from being tricked into loading malicious code is to enable library validation. You get this by default once you enable the hardened runtime. Do not disable library validation unless your app needs to load in-process plug-ins from other third-party developers. If you have an in-process plug-in model, consider migrating to ExtensionKit.
The exact circumstances where the system translocates an app is not documented and has changed over time. It’s best to structure your app so that it works regardless of whether it’s translocated or not.
App Translocation Compatibility
Most apps run just fine when translocated. However, you can run into problems if you load resources relative to your app bundle. For example, consider a structure like this:
MyApp.app
Templates/
letter.myapp
envelope.myapp
birthday card.myapp
Such an app might try to find the Templates directory by:
Getting the path to the main bundle
Navigating from that using a relative path
This won’t work if the app is translocated.
The best way to avoid such problems is to embed these resources inside your app (following the rules in Placing Content in a Bundle, of course). If you need to make them easily accessible to the user, add your own UI for that. For a great example of this, run Pages and choose File > New.
App Translocation Limits
There is no supported way to detect if your app is being run translocated. If you search the ’net you’ll find lots of snippets that do this, but they all rely on implementation details that could change.
There is no supported way to determine the original (untranslocated) path of your app. Again, you’ll find lots of unsupported techniques for this out there on the ’net. Use them at your peril!
If you find yourself using these unsupported techniques, it’s time to sit down and rethink your options. Your best option here is to make your app work properly when translocated, as illustrated by the example in the previous section.
App Translocation in Action
The following steps explain how to trigger app translocation on macOS 13.0. Keep in mind that the specifics of app translocation are not documented and have changed over time, so you might see different behaviour on older or new systems:
To see app translocation in action:
Use Safari to download an app that’s packaged as a zip archive. My go-to choice for such tests is NetNewsWire, but any app will work.
Safari downloads the zip archive to the Downloads folder and then unpacks it (assuming your haven’t tweaked your preferences).
In Finder, navigate to the Downloads folder and launch the app.
When Gatekeeper presents its alert, approve the launch.
In Terminal, look at the path the app was launched from:
% ps xw | grep NetNewsWire
… /private/var/folders/wk/bqx_nk71457_g9yry9c_2ww80000gp/T/AppTranslocation/C863FADC-A711-49DD-B4D0-6BE679EE225D/d/NetNewsWire.app/Contents/MacOS/NetNewsWire
Note how the path isn’t ~/Downloads but something random. That’s why the official name for this feature is Gatekeeper path randomisation.
Quit the app.
Use Finder to relaunch it.
Repeat step 5:
% ps xw | grep NetNewsWire
… /private/var/folders/wk/bqx_nk71457_g9yry9c_2ww80000gp/T/AppTranslocation/C863FADC-A711-49DD-B4D0-6BE679EE225D/d/NetNewsWire.app/Contents/MacOS/NetNewsWire
The path is still randomised.
Quit the app again.
Use the Finder to move it to the desktop.
And relaunch it.
And repeat step 5 again:
% ps xw | grep NetNewsWire
… /Users/quinn/Desktop/NetNewsWire.app/Contents/MacOS/NetNewsWire
The act of moving the app has cleared the state that triggered app translocation.
Post not yet marked as solved
I'm setting up tests for my Xcode Multiplatform App. To create a test environment I created a docker image that I want to run an XCTestCase against. I understand I'd have to make sure Docker is running before running the test. That said I have a permission denied when trying to connect to the docker daemon socket.
Background: I'm using a makefile to store the commands and planned to run the docker build and docker run commands in the setUpWithError while running the docker kill command in tearDownWithError. To run the commands I used Process to execute the shell commands. I'm currently doing this is a test function to get it up and going.
Issue: When I try to run the docker command Xcode tells me that it doesn't give me the permission to run it:
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create?name=remarkable": dial unix /var/run/docker.sock: connect: operation not permitted.
See 'docker run --help'.
I only want to use Docker to run this specific XCTestCase. Is there anyway to run it from here JUST for the test? Or do I need to manually run docker and kill it before/after I run these tests?
Thanks for any help.
Post not yet marked as solved
During the video playback with the AVPlayer, our iOS and AppleTV apps set AVPlayerItem externalMetadata. Additionaly, the iOS app also sets the default MPNowPlayingInfoCenter nowPlayingInfo. The apps also register to MPRemoteCommands.
What works: The iOS NowPlayingInfo center is properly filled with the metadata, the remote commands work well and on AppleTV, using the AVPlayerViewController, the info tab shows the content metadata.
Problem: when AirPlaying the content to an AppleTV, the stream is properly played but no metadata are displayed on the AppleTV.
I've tried to set nowPlayingInfo on the avPlayerItem or using an MPNowPlayingSession (new with iOS/tvOS 16) but with no luck.
Can someone help me display the playerItem metadata on the AirPlay device?
Post not yet marked as solved
Hello Everyone, we are experiencing this same problem recently and could not come up with a solution. Basically the problem is that when autofill password is enabled and the same for the option in the preference to save the security password via iCloud we have the same problem posted by the OP in this thread:
https://developer.apple.com/forums/thread/716589?login=true&page=1#744911022
After filling the password field when we move to our confirm password field, the iOS system shows the same action sheet attached from the OP (String password or Other Options) and if we choose the Other Options action and then Choose My Own Password both field (Password & Confirm Password) will be emptied.
We have already tried the suggestions provided in the thread linked above but nothing seems to work.
Is this a normal behavior and we as engineers have the responsability
to cache the password typed by the user when dealing with iCloud
security password & autofill password preferences options or is this
a strange behavior?
Thank you everyone for the time, if you have any further question don't esitate to ask
Post not yet marked as solved
Hi,
I don't remember how to get the URL of the notarization log given the Request Identifier. How do I get this URL from the command line (maybe with an xcrun command) ?
Thanks for help
S.
Post not yet marked as solved
My app has a debugging mode in which it invokes 'leaks' on itself. I am now seeing this message on stderr:
Target process is an ancestor and permitting live process for ancestors so not generating a corpse to save resources by default.
This sort of makes sense, but I would like a more detailed explanation. Is there some option I should be sending to 'leaks' to operate in a better mode? Should I be invoking it differently?
Post not yet marked as solved
My app creates new subscription groups via the app store connect api. Our end users subscribe to creators. Each creator has their own subscription group within app store connect. We will create hundreds, even thousands of subscription groups via the api over time.
Does Apple have to approve each subscription group before they can be accessed via the app by end users? Or do they just approve the first one and allow us to create new subscriptions groups in real time -- over time via the API without additional approvals?
Post not yet marked as solved
Hi,
I would like to deploy an application for our employees, knowing that the phones belong to the employees and not to the company, so I cannot add them in Apple Business Manager.
Can you tell me how I can publish my application (outside of TestFlight) in a simple way?
Cordially,
Khalil
Post not yet marked as solved
With the recent update to Xcode 14.1 (also seen on Xcode 14.2), the project files get modified automatically every time it is opened. This behaviour is not seen in Xcode 13.4.1.
Our project files are sorted alphabetically. Whenever the workspace or .xcodeproj is opened using Xcode 14.1 or 14.2, the pbxproj gets modified and the file references gets sorted based on the alphabetic order of the unique reference identifier as show in the below attachment. Is there a way to prevent this ? If this is a bug on the recent version of Xcode, ie 14.1 or 14.2, could you please acknowledge and address this in the next version ?
Post not yet marked as solved
On the systems with FileVault enabled, the LaunchDaemons and system extensions start after the first user login.
But I expect that they will launch before LaunchAgents and other user services.
When I use endpoint security as a LaunchDaemon, it launches after some LaunchAgents in 100% of cases.
When I use endpoint security as a system extension with the flag NSEndpointSecurityEarlyBoot, it launches after some LaunchAgents in 90% of cases.
This behavior looks like a system issue because the flag NSEndpointSecurityEarlyBoot should guarantee an earlier start than other services.
Post not yet marked as solved
I have an Intent that creates a list of items for the user to select from and use the .requestDisambiguation() call return to the user. The list is displayed in the shortcuts app but when using Siri only the dialog is said to the user. I need the among values to also be read out loud. Any suggestions.
let item = try await $itemInfo.requestDisambiguation(
among: infoList,
dialog: IntentDialog("Which item?")
)
Post not yet marked as solved
When playing an HLS/FairPlay VOD content, the playback position sometimes jumps to 0 during the transition between local and external playback (and the other way around). The app does nothing during the transition, apart from responding to ContentKeySession key requests.
It is not systematic but occurs quite often. When the issue occurs, the playback sometimes resumes to the position where it was before the transition but usually it does not.
Most of the time, when the issue occur, the iOS app periodic time observer gets triggered and the AVPlayerItem currentTime() has the specific value 0.001s.
Here is an extract of our iOS app logs with the value of AVPlayerItem.currentTime() when the AVPlayer PeriodicTimeObserver is triggered:
📘 [8:21:54.520] Did update playback time: 4512.001719539
📘 [8:21:55.472] Did update playback time: 4512.958677777778
📗 [8:21:55.497] Player external playback active changed to: true
📘 [8:21:57.674] Did update playback time: 4512.001897709
📘 [8:21:57.779] Did update playback time: 4511.974062125
📘 [8:21:57.800] Did update playback time: 4511.995523418
📘 [8:21:57.805] Did update playback time: 4512.001181626
📘 [8:21:58.806] Did update playback time: 4513.001841876
📘 [8:21:59.794] Did update playback time: 4514.001132625
📘 [8:22:00.795] Did update playback time: 4515.001653707
📘 [8:22:01.562] Did update playback time: 4515.766148708
📗 [8:22:01.679] Player external playback active changed to: false
📘 [8:22:01.683] Did update playback time: 0.001
📘 [8:22:01.700] Did update playback time: 4510.0
📘 [8:22:01.737] Did update playback time: 4510.0
📘 [8:22:01.988] Did update playback time: 4509.956132376
📘 [8:22:01.990] Did update playback time: 4509.958216834
📘 [8:22:03.033] Did update playback time: 4511.0015079
📘 [8:22:04.033] Did update playback time: 4512.001688753
📘 [8:22:05.033] Did update playback time: 4513.001998495
📘 [8:22:06.033] Did update playback time: 4514.001205557
📘 [8:22:06.045] Did update playback time: 4514.0325555555555
📗 [8:22:06.080] Player external playback active changed to: true
📘 [8:22:06.800] Did update playback time: 0.0
📘 [8:22:06.814] Did update playback time: 0.0
📘 [8:22:08.168] Did update playback time: 0.002258708
📘 [8:22:08.218] Did update playback time: -0.075460416
📘 [8:22:08.237] Did update playback time: -0.063310916
📘 [8:22:09.298] Did update playback time: 1.001932292
📘 [8:22:10.295] Did update playback time: 2.003054584
📘 [8:22:11.302] Did update playback time: 3.001831125
📘 [8:22:12.301] Did update playback time: 4.001488001
Local -> AirPlay: no issue
AirPlay -> Local: the issue occurs temporarily and the playback approximately returns to its position before the transition
Local -> AirPlay: the issue occurs permanently and the playback continues from the beginning of the stream.
I've filed a feedback for this issue with both iOS device and AppleTV sysdiagnoses: https://feedbackassistant.apple.com/feedback/11990309
Post not yet marked as solved
Hello everyone,
How are you ?
Sorry for the bother but I have a circular reference error on my xcode and as I am new to it, I don't know how to solve it.
Here is the code:
let Trainings = [
Trainings(trainingsname: "Inbox", image: "envelope", school: "kjj"),
Trainings(trainingsname: "VIP", image: "star", school: ""),
Trainings(trainingsname: "Drafts", image: "doc", school: "fed.idserve.net"),
Trainings(trainingsname: "Sent", image: "paperplane", school: "fed.idserve.net"),
Trainings(trainingsname: "Junk", image: "xmark.bin", school: "fed.idserve.net"),
Trainings(trainingsname: "Bin", image: "trash", school: "fed.idserve.net")
]
What should I do to fix this please ?
Thanks
Cheers