I'm getting this error when attempting to upload an iOS app to iTunes Connect. I've tried using Transporter, and get the same result.I've also tried uploading a new version of an app that uploaded correctly in November and got the same result.Does anyone have any suggestions for possible causes for this error?thanks,
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
When I:
open a simulator (eg iPhone 15, iOS 17.0)
open the Photos app
tap on an image (either one that comes included, or something I've saved to PhotoRoll)
tap Edit
I see the typical Photos Edit view with two key differences.
the image is not visible, the middle of the view is all black
there are now Cancel/Done/Dismiss buttons. I need to force quit to get back to the Springboard (Is that still the correct term?)
Am I doing something wrong, or should the simulator's Photo's app be providing a better edit experience?
Hello folks,
I'm attempting to implement some swiftUI UI code to support filtering of a list.
One part of the filtering involves displaying one checkbox for each case/value of an enum (TangleType below)
TangleFilter is a model class that includes an array of TangleTypeFilter objects (each owning a single bool value and a binding)
Expected behaviour: when user taps a checkbox, the checkbox toggles the display and the filter model object toggles its value.
Actual behaviour: the model is updating appropriately, however the UI is not updating. (the single filter below the list does in fact behave correctly
any and all guidance greatly appreciated
Mike
struct ContentView: View {
@State var isChecked: Bool = false
@ObservedObject var filter = TangleFilter()
@ObservedObject var singleFilter: TangleTypeFilter
init() {
self.singleFilter = TangleTypeFilter(tangleType: .grid)
}
var body: some View {
VStack{
List(filter.tangleTypes, id: \.self) {tangleTypeFilter in
HStack {
// when uncommented the following line returns the following
// compile error:
// Use of unresolved identifier '$tangleTypeFilter'
// CheckBox(isChecked: $tangleTypeFilter.isChecked)
CheckBox(isChecked: tangleTypeFilter.binding)
Text("checked? \(tangleTypeFilter.isChecked.description)")
}
}
CheckBox(isChecked: $singleFilter.isChecked)
}
}
}
struct CheckBox: View {
@Binding var isChecked: Bool {
didSet {
print("setting isChecked: \(isChecked)")
}
}
var imageName: String {
return isChecked ? "checkmark.square" : "square"
}
var body: some View {
Button(action: {
self.isChecked.toggle()
}) {
Image(systemName: self.imageName)
}
}
}
enum TangleType: String, Codable, CaseIterable {
static let filterArray: [TangleTypeFilter] = {
var result: [TangleTypeFilter] = []
for tangleType in TangleType.allCases {
result.append(TangleTypeFilter(tangleType: tangleType))
}
return result
}()
case grid
case row
}
class TangleFilter: ObservableObject {
@Published var tangleTypes: [TangleTypeFilter] = TangleType.filterArray
}
class TangleTypeFilter: ObservableObject {
var tangleType: TangleType
@Published var isChecked: Bool
lazy var binding: Binding<Bool> = Binding(get: {
return self.isChecked
}, set: {
self.isChecked = $0
})
init(tangleType: TangleType) {
self.tangleType = tangleType
self.isChecked = false
}
}
extension TangleTypeFilter: Hashable {
static func == (lhs: TangleTypeFilter, rhs: TangleTypeFilter) -> Bool {
return lhs.tangleType == rhs.tangleType
}
func hash(into hasher: inout Hasher) {
hasher.combine(tangleType)
}
}
Pretty sure this is a no-no, but asking just in case there's an easy way to make this work
struct DocumentContentView: View {
private static let logger = Logger(
subsystem: "mySubsystem",
category: String(describing: Self.self)
)
var body: some View {
VStack {
Text("Hello")
logger.trace("hello")
}
}
}
This code generates the following compile error at the logger.trace line
buildExpression is unavailable: this expression does not conform to View
I suspect every line of the body var (or any @ViewBuilder - designated code?) needs to 'return' a View. Is this correct? or more importantly any work arounds other than putting some/all of the view contents in a. func()?
I seem to recall hearing that DateFormatters are (or were) expensive to instantiate.
With this in mind, I tried a small experiment with the following code:
class MyClass {
		static let df = DrawingCellView.dateFormatter
static var dateFormatter: DateFormatter {
let result = DateFormatter()
result.dateFormat = "yyyy-MM-dd"
return result
}
		func dateText() -> String {
				return MyClass.dateFormatter.string(from: Date())
		}
When I put a breakpoint in the dateFormatter code, it fires each time I use it. However if I instead use df, the breakpoint only fires once.
Does this make sense?
If so, is this the recommended way to construct a runOnce static constant declaration/assignment?
thanks!
Mike
See sample code below...
Basically it's a galleryView with a dataSource that can add/remove items dynamically. It works as expected when GalleryView's dataSource variable has a type (that conforms to ObservableObject)
However when I change dataSource's type to be a protocol, I can't seem to get my code to compile.
Any guidance on how to use a protocol in GalleryView, and continue to keep the UI updating when the model object's item list changes?
thanks!
Mike
protocol GalleryDataSource: ObservableObject {
var itemCount: Int { get }
func item(for index: Int) - String
}
class GalleryModel: ObservableObject {
static let test1: GalleryModel = GalleryModel(items: ["A","B","C"])
@Published var items: [String]
init(items: [String]) {
self.items = items
}
}
extension GalleryModel: GalleryDataSource {
var itemCount: Int {
return items.count
}
func item(for index: Int) - String {
return items[index]
}
}
struct ContentView: View {
var model: GalleryModel = GalleryModel.test1
var body: some View {
VStack {
GalleryView(dataSource: model)
Button("Add Item") {
model.items.append("\(model.items.count)")
}
}
}
}
struct GalleryView: View {
@ObservedObject var dataSource: GalleryModel //GalleryDataSource
var body: some View {
ScrollView(.horizontal, content: {
HStack {
ForEach(0..self.dataSource.itemCount, id:\.self) { index in
Text(dataSource.item(for: index))
.padding()
}
}
})
}
}
I'm trying to find a syntactically correct way to put the contents of a Container in a separate variable (or function).
Can anyone steer me in the right direction?
thanks, in advance,
mike
struct ContentView: View {
var body: some View {
VStack(content: containerContent)
.padding()
}
var containerContent: () -> Content {
return {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
}
}
I have a SwiftUI view that works as expected in a full SwiftUI context. But I now need to use it in a UIViewController. It mostly works, but I'm trying to expose an @State var out to the viewController, and it only ever returns the initial value.
Any guidance for how best to pass out this @State var?
I could make it be a binding, but in my pure SwiftUI code, it works fine as @State (ie EditorView's container view does not need to know about sliderVal)
thanks, in advance, for any suggestions
import SwiftUI
import UIKit
class ViewController: UIViewController {
var host: UIHostingController<EditorView>?
override func viewDidLoad() {
super.viewDidLoad()
host = .init(rootView: EditorView())
guard let host = host else { return }
addChild(host)
host.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(host.view)
host.didMove(toParent: self)
}
@IBAction func helloTapped(sender: UIButton) {
guard let sliderValue = host?.rootView.sliderVal else { return }
print("UIKit sliderValue: \(sliderValue)")
}
}
struct EditorView: View {
@State var sliderVal: Double
init(sliderVal: Double? = nil) {
_sliderVal = State(initialValue: sliderVal ?? 7)
}
var body: some View {
VStack {
Slider(value: $sliderVal, in: 1...10)
Text("sliderVal: \(sliderVal)")
}
}
}
(NOTE: in order to see this code snippet in action you will need to create a button in the storyboard and link it to helloTapped)
This first code works fine decoding json.
static let localizationsDictText = """
{ "en" : { "string" : "Cat" },
"fr" : { "string" : "Chat"}
}
"""
struct Localization: Codable, Equatable {
let string: String
}
typealias LocalizationsDict = [String: Localization]
func testExample() throws {
let text = Self.localizationsDictText
let data = text.data(using: .utf8, allowLossyConversion: false)
let localizationsDict = try JSONDecoder().decode(LocalizationsDict.self, from: data!)
XCTAssertEqual(localizationsDict.keys.count, 2)
}
But then I try to create a modified version of the above, only changing the type of the LocalizationsDict key from String to an enum:
enum Language: String, CaseIterable, Codable {
case en = "en"
case fr = "fr"
}
typealias LocalizationsDict2 = [Language: Localization]
func testExample2() throws {
let text = Self.localizationsDictText
let data = text.data(using: .utf8, allowLossyConversion: false)
let localizationsDict = try JSONDecoder().decode(LocalizationsDict2.self, from: data!)
XCTAssertEqual(localizationsDict.keys.count, 2)
}
and the JSONDecoder line throws an exception:
testExample2(): failed: caught error: "typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))"
Any suggestions as to why switching from
[String: Localization] to [Language: Localization] might cause JSONDecode() to treat it like an array?
Thanks in advance for any guidance.
I am using @AppStorage in a model object (see code below that works as expected).
class ModelObject {
static let shared = ModelObject()
@AppStorage("enhanced") var scriptPickers: Bool = true
var defaultDependentValue: String {
scriptPickers ? "Enhanced" : "NOT enhanced"
}
}
struct ContentView: View {
@AppStorage("enhanced") var scriptPickers: Bool = true
var body: some View {
VStack {
Toggle(isOn: $scriptPickers, label: {
Text("userDefault val")
})
Text("value: \(ModelObject.shared.defaultDependentValue)")
}
}
}
Now I want to test my model object in a way that will allow me to use a mock instance of UserDefaults, but am having trouble with the syntax. I tried adding a userDefaults var, and referring to the var in the @AppStorage
class ModelObject {
static let shared = ModelObject()
let userDefaults: UserDefaults
init(userDefaults: UserDefaults = .standard) {
self.userDefaults = userDefaults
}
@AppStorage("enhanced", store: userDefaults) var scriptPickers: Bool = true
var defaultDependentValue: String {
scriptPickers ? "Enhanced" : "NOT enhanced"
}
}
However I can't find a way to avoid the syntax error this generates:
Cannot use instance member 'userDefaults' within property initializer; property initializers run before 'self' is available
Any guidance on how I might be able to:
continue using @AppStorage
be able to test my class in a way that doesn't force me to use UserDefaults.standard
thanks, in advance,
Mike
In V 0.1 of my app, I went with a simple option for a piece of business logic in my app.
I then changed something else that caused my simplified business logic to now crash the app at startup.
Excellent, a chance to use Test. Driven Design to replace my flawed business logic.
So I wrote my first test TDD test, but when I tried to run the test... It doesn't run because running the test target seems to start by actually running my full app (which as I described in chapter 1 is currently crashing)
Have I configured something incorrectly? or is it normal that when I attempt to run a single test, step 1 is running the full app?
(note: it is very easy for me to disable/avoid the business logic causing my crash. This question is more about my lack of understanding of what it means to run a test target.)
thanks in advance for any and all responses.
Mike
I've defined a value stored in UserDefaults.
In a view struct I have code that can successfully update the stored value.
I've also added an @AppStorage var in an instance of a class, that can read this value and run business logic that depends on the current stored value.
But what I really want to do, is have code in my class that gets automatically called when the value stored in UserDefaults gets updated.
Basically I want to do this:
@AppStorage("languageChoice") var languageChoice: LanguageChoice = .all {
didSet {
print("hello")
}
}
Unfortunately didSet closures in @AppStorage vars do not appear to get called :-(
My clumsy attempts to use combine have all ended in tears from the compiler.
Any/all suggestions are greatly appreciated.
thanks,
Mike
From what I've read, @AppStorage vars should be @Published, however the following code generates a syntax error at extended's .sink modifier: Cannot call value of non-function type 'Binding<Subject>'
class LanguageManager: ObservableObject {
@Published var fred = "Fred"
@AppStorage("extended") var extended: Bool = true
private var subscriptions = Set<AnyCancellable>()
init() {
$fred
.sink(receiveValue: {value in
print("value: \(value)")
})
.store(in: &subscriptions)
$extended
.sink(receiveValue: {value in
print("value: \(value)")
})
.store(in: &subscriptions)
}
Does anyone know of a way to listen for (subscribe to) changes in @AppStorage values?
didSet works in for a specific subset of value changes, but this is not sufficient for my intended use.
I thought the following code would allow me to have focus in the TextField when the app loads. Is there something else/different that I need to do?
struct ContentView: View {
enum FocusField {
case password
}
@State var fieldContent: String = ""
@FocusState var focus: FocusField?
var body: some View {
VStack {
TextField("Enter text here", text: $fieldContent)
.focused($focus, equals: .password)
Text("Hello, world!")
}
.padding()
.defaultFocus($focus, .password)
}
}
I have a CoreImage pipeline and one of my steps is to rotate my image about the origin (bottom left corner) and then translate it. I'm not seeing the behaviour I'm expecting, and I think my problem is in how I'm combining these two steps.
As an example, I start with an identity transform
(lldb) po transform333
▿ CGAffineTransform
- a : 1.0
- b : 0.0
- c : 0.0
- d : 1.0
- tx : 0.0
- ty : 0.0
I then rotate 1.57 radians (approx. 90 degrees, CCW)
transform333 = transform333.rotated(by: 1.57)
- a : 0.0007963267107332633
- b : 0.9999996829318346
- c : -0.9999996829318346
- d : 0.0007963267107332633
- tx : 0.0
- ty : 0.0
I understand the current contents of the transform.
But then I translate by 10, 10:
(lldb) po transform333.translatedBy(x: 10, y: 10)
- a : 0.0007963267107332633
- b : 0.9999996829318346
- c : -0.9999996829318346
- d : 0.0007963267107332633
- tx : -9.992033562211013
- ty : 10.007960096425679
I was expecting tx and ty to be 10 and 10.
I have noticed that when I reverse the order of these operations, the transform contents look correct. So I'll most likely just perform the steps in what feels to me like the incorrect order.
Is anyone willing/able to point me to an explanation of why the steps I'm performing are giving me these results?
thanks,
mike