Post not yet marked as solved
We have an Aggregate target with a custom Run Script build phase that consumes a JSON file in the project and outputs a .swift file and an .xcassets folder. However, getting our primary app target to see and include these output files has required some hacky measures (that I'd rather not delve into), and I'm wondering if there's something I'm missing.
What's the defacto way of ensuring that Build Phase output files get included as sources file in an app build?
I'm working on an API client for a REST service that uses a custom token-based authentiation scheme. The app hits a specificed authentication endpoint with a username and password, said endpoint returns a token that's good for X amount of time, and the app passes that token along with every subsequent request. When that token expires, we start over.Most literature out there tells me to manually set the Authorization header on my request, but official Apple documentation discourages this, as that header is meant to be 'owned' by the built-in HTTP loading system. That said, official documentation on the 'correct' way to do this is shockingly lacking, and the standard didReceiveChallenge callbacks seem better suited for non-custom Basic/Digest/etc authentication schemes. One thought I had was registering my own URLProtocol subclass to handle our custom flow. However, while I haven't had a chance to sit down and take a crack at that yet, my understanding from skimming these forums is that it's suffering from some bit-rot right now, so it 'might' (?) not be the best choice. That, and it's also not clear to me whether the rules around the Authorization header change when a custom URLProtocol is in play.So, community (paging eskimo in particular!), what's the correct way for me to go about this?
Post not yet marked as solved
What is deemed today as best practice for NSManagedObjectContext injection, namely for programmatic controllers?This past WWDC's Core Data Best Practices talk showed off a brief example where the main-thread context was passed into the view controller as a constructor parameter. However, my view controller is also going to perform a network fetch & upsert of the recieved payload into the Core Data store, so I'm going to need a background context. Do I:1. Inject both a main thread context and a background thread context into the view controller?2. Inject just the main thread context and have the VC create a background context that's a child of it?3. Assume the main thread context has automaticallyMergesChangesFromParent enabled and have the VC create a background context that refers directly to the main thread context's store coordinator?4. Inject the NSPersistentContainer?
Post not yet marked as solved
What are deemed the best practices for setting preferredContentSize? In particular:- Where is the best place to set it?- Are there any specific tips for setting it on UINavigationController content view controller?For context, we have a custom UIPresentationController that darkens/blurs the background and slides up the presented view controller as a sheet from the bottom. It also caps the height of the presented view controller to either the view controller's preferredContentSize.height or 1/3 the containerView's height, whichever is smaller. In this instance, we're using it with a UINavigationController that embeds a UITableViewController, with the preferredContentSize logic implemented in viewWillTransition as follows:override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
tableView.layoutIfNeeded()
var sectionRectSize = size
sectionRectSize.height = ceil(min(tableView.contentSize.height, size.height))
preferredContentSize = sectionRectSize
}Unfortunately, this approach has two problems:- It requires a tableView.layoutIfNeeded() is order to retrieve the correct content size.- UINavigationController only propogates the preferredContentSize change notification once. After that, further mutations to preferredContentSize on the content view controller do not get propogated back to the custom UIPresentationController.(The latter one is particularly nasty when iPad rotations get thrown into the mix. We currently do not ship with support for different iPad orientations, but this is something we very much want to address.)Are there better practices for setting preferredContentSize that can deal with my issues in a holistic way?
Post not yet marked as solved
We have some PDF assets (generated by Affinity Designer) in our catalog, but they seem to trigger Color Copied Images at runtime. Is this expected, or could this be a problem with how we're generating the PDFs in the first place?
Post not yet marked as solved
I have a custom UINavigationController subclass, one that uses an equivalent UINavigationItem subclass containing an additional two stored properties. The UINavigationController subclass displays additional UI elements in its root view depending on the value of these two new properties.However, while I can specify the UIViewControllers to use this UINavigationItem subclass in a XIB/Storyboard, I work on a team that has a very strong "no XIB/Storyboard" policy. As such, I'm trying to find a way to specify that my programmatic UIViewControllers should use this custom subclass for their navigationItems, but navigationItem is a get-only property.Without using XIBs/Storyboards, is there a way I can force this particular cluster of UIViewControllers to utlize this custom UINavigationItem subclass?(DISCLAIMER: I would strongly prefer NOT to fall back on associated objects or thread locals, if possible.)
Post not yet marked as solved
I'm making a strong effort to optimize my scrolling performance in a UITableViewController with some rather busy cells. Among my optimizations is differentiating between UIImageView.image and UIImageView.highlightedImage in my cells. This is to minimize alpha blending, as the original images have an alpha channel. The regular image is prerendered against a background matching the UITableViewCell's background color (white); the highlighted image retains the original image's alpha channel.This works great when highlighting the cell, which then navigates to the Details VC. However, popping back to the Master VC looks a little weird; when the cell deselects and animates the selectedBackgroundView out, the UIImageView flips from highlightedImage to image instantly. This creates the visual noise of opaque white appearing while the animation is in progress.Is there an easy way to:a) have the UIImageView naturally animate the cross dissolve of the image view alongside the deselect animation?orb) have the UIImageView wait for the deselect animation to finish before flipping from highlightedImage to image?As a hack right now, I've added a manual UIView.transition in UITableViewCell.setSelected(:highlighted:) with a baked-in duration of 1 second to swap the images manually. I'm not a fan of this, as it not only makes assumptions about the highlight/selection state, but it also requires additional code that's less obvious for others who will maintain my code long-term.What is the Right™ way to do this?(DISCLAIMER: For those who are probably thinking this is a premature optimization, the final design may have anywhere from two to ten images in each cell, all of them with the same alpha situation. Decent performance on older devices is indeed important to us.)
Post not yet marked as solved
I've noticed that when I use an image asset set to render as a Template Image, it's marked as red in the iOS simulator's Color Blended Layers analyzer (indicating that Alpha Blending is taking place). When I set it to render as Original Image, everything's green.Is this a bug, or is there some trick to preventing alpha blending when using a Template Image (one that I hope doesn't involve caching a pre-rasterized variant of the image in the specified tint color)?