Welcome to the Apple Developer Forums

Post your questions, exchange knowledge, and connect with fellow developers and Apple engineers on a variety of software development topics.

For questions about using Apple hardware and services, visit Apple Support Communities

Posts

Sort by:
Post not yet marked as solved
0 Replies
13 Views
My Mac app uses a WKWebView to load and display a PDF file from an URL with the following source in Swift: let webView = WKWebView(frame: view.bounds) webView.load(URLRequest(url: URL(string: "https://www.africau.edu/images/default/sample.pdf")!)) view = webView Unfortunately, the "Download" button of the embedded PDF Preview does not work (see below screenshot). My App sandbox has the file access permission for the "Downloads" folder set to Read/write. What am I missing in order to make the download button work?
Posted
by
Post not yet marked as solved
0 Replies
19 Views
Hi all, I am creating a little mobile game app, where users can sign in with their Apple ID (Sign in with Apple). During the onboarding, I also set some UserDefaults in @ AppStorage. As I code the signOut() feature, I am wondering if I need to set all the user back to their original "" or nil. I understand that for my deleteAccount() feature I will do this, but do I also have to do this for signOut()? The main reason I can think of having to do this, is if users change their Apple ID on the same device, re-download the app and then sign in - in which case the user defaults may be the same as set using the old Apple ID, right? So my question is, does an app downloaded on the same device but with a different apple ID keep the original UserDefaults set for that app? Having to set UserDefaults to nil is no big issue, but from a code efficiency standpoint was wondering if it was necessary. Thank you for your help :)
Posted
by
Post not yet marked as solved
1 Replies
26 Views
I have two arrays, I call a separate VC and change the General array to Motivation by clicking the button. When I return to the VC on which UIViewCollection, the displayed array element remains equal to the index of the previous one. How do I start displaying the array from scratch? VC UIcollectionView class MainViewController: UIViewController, UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout {       @IBOutlet weak var collectionView: UICollectionView!       var generalQuote = [     Text(text: "general0", name: "quote0"),     Text(text: "general1", name: "quote1"),     Text(text: "general2", name: "quote2"),     Text(text: "general3", name: "quote3"),     Text(text: "general4", name: "quote4"),   ]   var motivationQuoute = [     Text(text: "motivation0", name: "quote0"),     Text(text: "motivation1", name: "quote1"),   ]   var arrayQuote = [Text]()   enum Theme {     case general, motivation   }   var currentTheme: Theme = .general       var quoutesInTheme = 0       override func viewDidLoad() {     super.viewDidLoad()     self.collectionView.register(UINib(nibName: "ProductCell", bundle: nil),forCellWithReuseIdentifier: "ProductCell")     self.collectionView.dataSource = self     self.collectionView.delegate = self   }   override func viewWillAppear(_ animated: Bool) {     checkCurrentTheme()     print("Updated")   }   func checkCurrentTheme() {     switch currentTheme {     case .general:       print("Current theme General")       quoutesInTheme = generalQuote.count       arrayQuote = generalQuote     case .motivation:       print("Current theme Motivation")       arrayQuote = motivationQuoute       quoutesInTheme = motivationQuoute.count     }   }   func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {     quoutesInTheme = arrayQuote.count     return quoutesInTheme   }       func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {     let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ProductCell", for: indexPath) as! ProductCell     let quotes: Text     quotes = arrayQuote[indexPath.item]     cell.setupCell(text: quotes)     return cell   }   func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize   {     let guide = view.safeAreaLayoutGuide     let width = guide.layoutFrame.size.width     let height = guide.layoutFrame.size.height     return CGSize(width: width, height: height)   }   func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {      return 5   } } VC with Buttons class choiceThemeQuoteViewController: UIViewController {      @IBOutlet weak var general: UIButton!   @IBOutlet weak var motivation: UIButton!       override func viewDidLoad() {     super.viewDidLoad()   }   @IBAction func generalButton(_ sender: Any) {     if let presenter = presentingViewController as? MainViewController {       presenter.currentTheme = .general       presenter.collectionView.reloadData()     }     dismiss(animated: true, completion: nil)   }       @IBAction func motivationButton(_ sender: Any) {     if let presenter = presentingViewController as? MainViewController {       presenter.currentTheme = .motivation       presenter.collectionView.reloadData()     }     dismiss(animated: true, completion: nil)   } }
Posted
by
Post not yet marked as solved
1 Replies
22 Views
Is it possible to combine two NSImages, one on top of another, specifying a blend mode? I have two images I would like to overlay, then display in an NSImageView. I appreciate any guidance. Thanks
Posted
by
Post not yet marked as solved
1 Replies
22 Views
Hello, I am a beginner on swiftUI and I would like to match a 2 elements of a list according to their location ("place" in my code). I'm trying to make a home automation application, so when we add a device by giving it its location (in deviceList), it will be assigned to the desired room. I tried to put : if room.place == device.place {at different location but it doesn't work. I put you some pictures without theif to understand: [ListView] (https://i.stack.imgur.com/zzSZz.png) [DeviceView] (https://i.stack.imgur.com/Mn6Am.png) [RoomView] (https://i.stack.imgur.com/Q5w8y.png) Thanks
Posted
by
Post not yet marked as solved
1 Replies
24 Views
Hi everyone, My App is a slot casino game. You get free coins (or you can purchase them via in app purchases) to spin in 6 differently themed rooms. I also have a 'Diamond' loyalty system. Every 3 hours, a Diamond is generated which the User can click on to collect. Once the user collects enough Diamonds, he can then redeem those Diamonds for a amazon gift card. These cards are already pre-purchased by my company. They are not sold to the User. I have recently been rejected from the App store because of 3.1.1. Here is what the person reviewing states: Hello, Thank you for providing this information. Regarding 3.1.1, we understand that gift cards are all pre-purchased in your app. However, gift cards that can be redeemed for digital content and services to be used in other apps or on third-party platforms is considering not compliant to App Store Guideline 3.1.1. To resolve this issue, it would be appropriate to please remove any content or features that sell digital items, codes, currencies or gift cards for digital content to be used in other apps or third-party platforms. We look forward to reviewing your resubmitted app. "To resolve, please remove any content or features that SELL digital items, codes, etc." We do not sell. There are many similar Apps out there like mine. Lucky Solitaire: Win Cash ShopKick InboxDollars And many, many more. I can find them all if need be. Can anyone provide me with a suggestion on how to approach this review process? This is a core function of my game and I would like to keep it intact. I just don't understand how I am violating the process with many other apps doing the exact same thing.
Posted
by
Post not yet marked as solved
0 Replies
16 Views
Has anyone see this constantly show up, it comes 5-10 of times on every MusicKit request, although the requests gets proper responses, I'm not sure if this error is important or not? [Default] <ICUserIdentityStoreACAccountBackend: 0x281f47660> Failed to register for account monitoring. err=Error Domain=com.apple.accounts Code=7 "(null)"
Posted
by
Post not yet marked as solved
0 Replies
27 Views
Hello, I am interested in the new MacBook Pro with the M2 Pro Processor. However, I need OpenGL on the laptop I am getting. Therefore, I wanted to ask which version of OpenGL is supported on this Mac and what might happen in the future.
Posted
by
Post not yet marked as solved
0 Replies
19 Views
Past 8-9 months we've been working on Arduino/ ESP32 with no issues, but after upgrading the OS the port stopped showing up under /dev/tty.cuserial. We tried to install the driver from Silicon Labs CP210x VCP Driver for MacOS(installed w/ no issues) but in the system information, we are seeing the S/w is sitting under disabled S/w list com.silabs.driver.CP210xVCPDriver: unknown. How can we fix this and get it out of disabled S/w?
Posted
by
Post not yet marked as solved
0 Replies
41 Views
Hey, I'm really new to CloudKit. When I test my app in development it works fine. So I pushed my schema changes to production. But then my app does not work with CloudKit anymore, in the logs I see some BAD_REQUEST messages. So I logged one of my production devices and get the following error message: CKError 0x28331e4f0: "Invalid Arguments" (12/2006); server message = "Cannot create or modify field 'CD_finishedReadingTimestamp' in record 'CD_BookAnalyticalData' in production schema"; op = xxxxxx; uuid = 9xxxxxxx> ... 5 "Batch Request Failed" CKError's omited ... Any help is appreciated! Thank you!
Posted
by
Post not yet marked as solved
0 Replies
36 Views
Hi, I'm writing a command line program with Swift Package Manager that uses Contacts API to automatically add phonetic names for the contacts. However, I found I was unable to do so for contacts that has notes. First, when I was trying to enumerate the contacts, there is a strange error output: 2023-01-22 18:58:36.085525+0800 PhoneticNames[18591:98356] [core] Attempted to register account monitor for types client is not authorized to access: {( "com.apple.account.CardDAV", "com.apple.account.Exchange", "com.apple.account.LDAP" )} 2023-01-22 18:58:36.085580+0800 PhoneticNames[18591:98356] [accounts] CNAccountCollectionUpdateWatcher 0x6000003ccc40: Store registration failed: Error Domain=com.apple.accounts Code=7 "(null)" 2023-01-22 18:58:36.085606+0800 PhoneticNames[18591:98356] [accounts] CNAccountCollectionUpdateWatcher 0x6000003ccc40: Update event received, but store registration failed. This event will be handled, but the behavior is undefined. 2023-01-22 18:58:36.136236+0800 PhoneticNames[18591:98344] [api] Attempt to read notes by an unentitled app According to this document, I need to add the notes entitlement only if I was requesting the note field with CNContactNoteKey. However, I was not requesting it and I still get that "Attempt to read notes by an unentitled app" error. Here is my code for enumerating the contacts: let keys: [CNKeyDescriptor] = [CNContactFormatter.descriptorForRequiredKeys(for: .fullName), CNContactFormatter.descriptorForRequiredKeys(for: .phoneticFullName)] let fetchRequest = CNContactFetchRequest(keysToFetch: keys as [CNKeyDescriptor]) fetchRequest.mutableObjects = true do { try store.enumerateContacts(with: fetchRequest) { (contact, stop) in contacts.append(contact.mutableCopy() as! CNMutableContact) } } catch { print("unable to list contacts. \(error)") } And this is how I update the contacts later: let saveRequest = CNSaveRequest() contact.phoneticFamilyName = phoneticFamilyName contact.phoneticMiddleName = phoneticMiddleName contact.phoneticGivenName = phoneticGivenName saveRequest.update(contact) do { try store.execute(saveRequest) } catch { print("Fail to execute store request: \(error)") } This code works as expected for contacts without the note field. But for contact with a non-empty note field, the saveRequest fails and outputs the following error: 2023-01-22 18:58:36.197026+0800 PhoneticNames[18591:98344] [error] error: Unhandled error occurred during faulting: Error Domain=NSCocoaErrorDomain Code=134092 "(null)" ({ }) CoreData: error: Unhandled error occurred during faulting: Error Domain=NSCocoaErrorDomain Code=134092 "(null)" ({ }) 2023-01-22 18:58:36.201308+0800 PhoneticNames[18591:98344] [plugin] CDX_AB_GetGroupCollectionPath: nil group 2023-01-22 18:58:36.201353+0800 PhoneticNames[18591:98344] [plugin] CDX_AB_GetGroupCollectionPath: nil group In debugging mode inside Xcode, the contact will still be updated with phoetic names. But if I execute the compiled release binary in terminal, the output will be: CoreData: error: Unhandled error occurred during faulting: Error Domain=NSCocoaErrorDomain Code=134092 "(null)" ({ }) Fail to execute store request: Error Domain=NSCocoaErrorDomain Code=134092 "(null)" UserInfo={NSUnderlyingException=Unhandled error (NSCocoaErrorDomain, 134092) occurred during faulting and was thrown: Error Domain=NSCocoaErrorDomain Code=134092 "(null)", NSUnderlyingError=0x600002ee05d0 {Error Domain=NSCocoaErrorDomain Code=134092 "(null)"}} The contact will not be updated in this case. I looked for all the documents but couldn't find anything about NSCocoaErrorDomain Code 134092. Can you please give me some clues about the aforementioned behaviors?
Posted
by
Post not yet marked as solved
1 Replies
26 Views
I'm writing an app that uses text to speech. On the physical Iphone 12 it works but on the simulator I don't get any speech from my app. I tried the following to enable. Settings -> Accessebility -> "Spoken Content" -> "Speak Selecton" to ON (green) in Voices I added the German Anna that I use on my Iphone with the downloaded enhancements. The speech test works in this menu but not in my app. What am I missing ? Cheers, Gerhard
Posted
by
Post not yet marked as solved
0 Replies
23 Views
In my application which records the video from any device and saving in aws server, and admin can play recorded videos from any os/ device. After the ios updated on Dec 14 2022, my video component is messed up, I cannot record or play video from apple devices. As I cannot write entire project code, I have the code in the below link [https://github.com/amran-quantum/videoplayertesting/blob/main/index.html) This video is playing in mac chrome but NOT in mac safari and any of the iphone devices. I am struggling since 15 days.
Posted
by
Post not yet marked as solved
0 Replies
46 Views
my code func placeObjectAtImageTracking(object: ModelEntity, imageAnchor: ARImageAnchor) -> AnchorEntity {     let imageAnchorEntity = AnchorEntity(anchor: imageAnchor) return imageAnchorEntity } in this code, AnchorEntity(anchor: imageAnchor) is occuring error when i changed xcode setting device. It's fine when I set it to my real phone, but when I change it to the simulator, the following error appears. No exact matches in call to initializer  how to solve it?
Posted
by
Post not yet marked as solved
0 Replies
41 Views
I have a simple UITextView with a custom NSLayoutManager in my app. The UITextView have a tap gesture and when you tap on UITextView it animates off the screen. My problem is that when you tap on the UITextView the entire text disappears. After debugging for a while I think it has something to do with NSTextContainer which I pass to the UITextView because If I don't pass it everything works fine. I thought it had to do something with my custom NSLayoutManager but then I tested it with a default NSLayoutManger and it is still giving the same issue. Can you please tell me what is going wrong? I have attached a sample code for your reference. I have slowed down the animation so can see what is wrong. class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() setUpTextView() } private func setUpTextView() { let rect = CGRect(origin: CGPoint(x: view.frame.origin.x, y: view.frame.origin.y + 50 ), size: CGSize(width: view.frame.width, height: view.frame.height - 50 ) ) let textView = MyTextView(frame: rect) textView.backgroundColor = .gray textView.layer.cornerRadius = 15 textView.textContainerInset.left = view.frame.width * 0.05 textView.textContainerInset.right = view.frame.width * 0.05 textView.textContainerInset.top = view.frame.height * 0.05 textView.textContainerInset.bottom = view.frame.height * 0.05 let string = "The Ultimate Fighting Championship is an American mixed martial arts promotion company based in Las Vegas, Nevada." let attributedText = NSAttributedString(string: string, attributes: [ .font: UIFont.systemFont(ofSize: 24, weight: .semibold), .foregroundColor: UIColor.white ]) textView.attributedText = attributedText textView.isScrollEnabled = false textView.isEditable = false textView.isSelectable = false view.addSubview(textView) } } MyTextView class MyTextView: UITextView { override init(frame: CGRect, textContainer: NSTextContainer?) { let textStorage = NSTextStorage() let layoutManager = NSLayoutManager() textStorage.addLayoutManager(layoutManager) let textContainer = NSTextContainer(size: frame.size) layoutManager.addTextContainer(textContainer) super.init(frame: frame, textContainer: textContainer) addGesture() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } private func addGesture() { let gesture = UITapGestureRecognizer(target: self, action: #selector(handleTap)) addGestureRecognizer(gesture) } @objc func handleTap(gesture: UITapGestureRecognizer) { UIView.animate(withDuration: 10, delay: 0) { self.transform = CGAffineTransform(translationX: 0, y: self.frame.height) } } }
Posted
by
Post not yet marked as solved
0 Replies
50 Views
In the viewer, the model looks great. I then bring it into the scene and it looks great. But I want to change the material programmatically. Yet this makes it look ugly. It's a physically based light model and a metallic material. Yet renders like a relatively flat phong. The detail of the other maps is there. The color is just flat and off. To eliminate all other variables, I started applying my programmatic material right after creating the node. The material is intended to be the exact same as the one I set in the viewer. Yet I get the same ugly result when I set it to the programmatically created version. Then I only changed the diffuse contents. And this looks great. Hopefully this isn't a stupid question as I can't find any similar complaints. But what parameter is being set in the viewer that I am missing in the SCNMaterial? The following is my attempt to copy all the settings from my viewer and repeat it in code. Nothing has really changed anything from just setting the usual content values: let material = SCNMaterial()         material.lightingModel = .physicallyBased         let matScale: Float = 1.0///25.4         material.isDoubleSided = false         material.diffuse.contents = UIImage(named: "basecolor.png")         //material.diffuse.contentsTransform = SCNMatrix4MakeScale(matScale, matScale, matScale)         material.diffuse.wrapS = .repeat         material.diffuse.wrapT = .repeat         material.diffuse.mipFilter = .nearest         material.diffuse.magnificationFilter = .linear         material.diffuse.minificationFilter = .linear         material.diffuse.mappingChannel = 0         material.diffuse.maxAnisotropy = 1.0         material.metalness.contents = UIImage(named: "scuffed_metalic.png")         material.metalness.wrapS = .repeat         material.metalness.wrapT = .repeat         material.metalness.mipFilter = .nearest         material.metalness.magnificationFilter = .linear         material.metalness.minificationFilter = .linear         material.metalness.mappingChannel = 0         material.metalness.maxAnisotropy = 1.0         material.roughness.contents = UIImage(named: "scuffed_roughness.png")         material.roughness.wrapS = .repeat         material.roughness.wrapT = .repeat         material.roughness.mipFilter = .nearest         material.roughness.magnificationFilter = .linear         material.roughness.minificationFilter = .linear         material.roughness.mappingChannel = 0         material.roughness.maxAnisotropy = 1.0         material.normal.contents = UIImage(named: "scuffed_normal.png")         material.normal.wrapS = .repeat         material.normal.wrapT = .repeat         material.normal.mipFilter = .nearest         material.normal.magnificationFilter = .linear         material.normal.minificationFilter = .linear         material.normal.mappingChannel = 0         material.normal.maxAnisotropy = 1.0         material.metalness.intensity = 1.0         material.roughness.intensity = 1.0//0.0//0.3         material.normal.intensity = 1.0         material.diffuse.intensity = 1.0        material.multiply.contents = UIColor.white         material.multiply.intensity = 1.0         material.transparent.contents = UIColor.white         material.transparent.intensity = 1.0         material.clearCoatNormal.contents = UIColor.white         material.clearCoatNormal.intensity = 1.0         material.locksAmbientWithDiffuse = true         material.emission.contents = UIColor.black         material.emission.intensity = 1.0         material.selfIllumination.contents = UIColor.black         material.selfIllumination.intensity = 1.0         material.clearCoatRoughness.contents = UIColor.black         material.clearCoatRoughness.intensity = 1.0         material.displacement.contents = UIColor.black         material.displacement.intensity = 1.0         material.transparencyMode = .default         material.shininess = 1.0         material.fresnelExponent = 0.0         material.cullMode = .back         material.blendMode = .alpha         material.writesToDepthBuffer = true         material.readsFromDepthBuffer = true         material.locksAmbientWithDiffuse = true         material.isLitPerPixel = true
Posted
by
Post not yet marked as solved
0 Replies
44 Views
Hello, In my app, I have a timer. When the app is in the foreground, everything is good. Timer runs. When the app goes to background, the timer stops. This is surely the iOS shuts down the app. I read multiple documents and pages about the background tasks and background task strategies. However, none of them are able to describe a scenario which is similar to Apple’s Stopwatch or Alarm or Timer. How can I achieve a similar functionality? Thanks.
Posted
by
Post not yet marked as solved
0 Replies
50 Views
Despite upgrading to the latest version iOS 16.2 mobile internet issues are still present. As soon as I leave home/office with Wi-fi connection I lose internet immediately. I’m unable to brows. None of the web pages would open. Also, sometimes the mobile internet appears to slow down so significantly only apps like WhatsApp appears to work🥺even google maps won’t work. The signal is perfect so that’s not the problem. The only way to get mobile internet back is to restart the phone 5-10 times and then you may get lucky. I’m using iPhone XS Max and was thinking of getting the latest phone but this appears to be a software issue so no point until it’s fixed. Please look into it it’s very exhausting. Thank you.
Posted
by
Post not yet marked as solved
0 Replies
57 Views
Here is a link of the same question on Apple support link, they directed me here to get help. Long story short, there is a lot of intel binaries on my M1 Mac due to transitioning from Intel Mac. What's the best way to replace them all with universal or M1 binaries with homebrew? Manually reinstalling everything seems tedious. I am surprised that during Time Machine porting session it didn't automatically download M1 versions tbh.
Post not yet marked as solved
0 Replies
42 Views
Hi, so I am new to SwiftUI and I have my image picker working on the ContentView and right now I want to select the photo library button and camera button and bring the image to a new page/viewer, but I cannot seem to find the coe for that. Does anyone know at string to do make that happen? Thank you! // // ContentView.swift // test app // // Created by Bella L on 1/18/23. // import SwiftUI struct ContentView: View {       @State private var isShowPhotoLibrary = false   @State private var image = UIImage()   @Environment(.openURL) var openURL   @State private var selected: Bool = false       var body: some View {     VStack {       //Link to website       Link(destination: URL(string:"")!, label: {         Text("Website")           .font(.system(size: 20))           .frame(width: 75, height: 50)           .foregroundColor(.white)           .background(Color("Dark"))           .cornerRadius(20)           .offset(x:125,y:1000)       })               //This is the text that is being labeled       Text("Welcome")         .foregroundColor(.black)         .offset(x:0,y:655)         .font(.system(size:30))       Text("Project")         .foregroundColor(.black)         .offset(x:0,y:670)         .font(.system(size:20))              //This is the logo image       Image("MainImage")         .resizable()         .scaledToFit()         .offset(x:0,y:250)         .frame(width: 300.0, height: 300.0)            //This begins the image picker and camera function       //This first one is the camera underneath       Image(uiImage: self.image)         .resizable()         .scaledToFill()         .frame(minWidth: 0, maxWidth: .infinity)         .edgesIgnoringSafeArea(.all)             Button(action: {         self.isShowPhotoLibrary = true       }) {         HStack {           Image(systemName: "camera")             .padding(.leading, -36.5)             .font(.system(size: 25))                       Text("Photo library")             .font(.headline)         }         .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: 50)         .background(Color("Dark"))         .foregroundColor(.white)         .cornerRadius(20)         .padding(.horizontal)         .offset(x:0, y:-20)       }      //Right here begins the photo library and image picker       Image(uiImage: self.image)         .resizable()         .scaledToFill()         .frame(minWidth: 0, maxWidth: .infinity)         .edgesIgnoringSafeArea(.all)               Button(action: {         self.isShowPhotoLibrary = true       }) {         HStack {                       Image(systemName: "photo")             .font(.system(size: 25))                       Text("Camera")             .font(.headline)         }         .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: 50)         .background(Color("Dark"))         .foregroundColor(.white)         .cornerRadius(20)         .padding(.horizontal)         .offset(x:0,y:-400)       }     }     //This is where it actually begins to run the actual thing: This is the code that shows what happens when you are selecting an image     .sheet(isPresented: $isShowPhotoLibrary) {       ImagePicker(sourceType: .photoLibrary, selectedImage: self.$image)                    }          .sheet(isPresented: $isShowPhotoLibrary) {       ImagePicker(sourceType: .camera, selectedImage: self.$image)     }         }           struct ContentView_Previews: PreviewProvider {     static var previews: some View {       ContentView()     }   } }
Posted
by

Pinned Posts

Categories

See all