Posts

Post not yet marked as solved
1 Replies
200 Views
I have a multiplatform project in Xcode 13.3.1, but when I try to run a unit by clicking the diamond in the gutter, the linker fails. From the link line in the log, it looks as if it isn't even linking with my app at all. I also noticed that I had to put in my own @testable import NameOfMyApp instead of Xcode generating that line like it does for single-platform projects, so that makes me wonder if this something extra i need to do since this project is multiplatform? Everything compiles fine, but the linker seems to be forgeting to link with my app...
Posted
by remsleep.
Last updated
.
Post marked as solved
2 Replies
2.7k Views
I've upgraded to 10.2 and now when I try to commit, Xcode says "No author information was supplied by the version control system". There is an option to "Fix", which takes me to preferences, where I added my name -- but still no success.How do I get git to work again on 10.2?
Posted
by remsleep.
Last updated
.
Post not yet marked as solved
1 Replies
123 Views
When an Array has an Element type that is an optional, I'd like to count the non-nil elems. Is there a way to do this with just a var? How can I say that Element is an Optional<T>, without introducing T via the generic func? Thanx. extension Array {     func someCount<T>() -> Int where Element == Optional<T> {         self.reduce(0) { count, elem in count + (elem == nil ? 0 : 1)     } }
Posted
by remsleep.
Last updated
.
Post not yet marked as solved
1 Replies
204 Views
My App had no such warnings before updating to 13.3, but now it claims I'm updating from a background thread. A simple print will make these warnings stop, so something is wrong:  @MainActor private func runOnMain(_ action: @escaping () async -> ()) async {         //print("", terminator: "")         await action()     } simply uncommenting that print() makes all the warnings go away, so I think 13.3 has an issue here... Is anyone else seeing this?
Posted
by remsleep.
Last updated
.
Post not yet marked as solved
4 Replies
251 Views
If i have a struct inside a function, swift keeps telling me is doesn't conform to Comparable, even though the same definition is fine outside of a function -- why is this? Foo fails Comparable here: func foo() {             struct Foo : Equatable, Comparable {                 let x: Int                 let y: Int                 static func (lhs: Foo, rhs: Foo) - Bool {                     return lhs.x+lhs.y rhs.x+rhs.y                 }             }         }
Posted
by remsleep.
Last updated
.
Post not yet marked as solved
4 Replies
20k Views
My app is working as expected in the simulator on iOS 12.1, but not on my iOS 11.x device, and it is just a layout issue. I'm not aware of any major changes in layout constraints from 11 to 12, so I'm perplexed... I upgraded an older device from iOS 10 to 12 and my app layout works on it, so it seems something changed between iOS 11 and 12 regarding layout, but I don't know what that is...How can I get a simulator running iOS 11.x to debug? I'll start debugging on my actual 11.x device, but I would also like to know how to get a simulator running older iOS versions? xcodebuild -showsdks says I only have 12.1 iphone/simulator 12.1 -- how do I run 11.x in the simulator, or older iOS versions in general in the simulator?
Posted
by remsleep.
Last updated
.
Post not yet marked as solved
2 Replies
675 Views
In my AppDelegate, I'm picking a seed like this on my physical iPad Pro:func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -&gt; Bool { // Override point for customization after application launch. sysRandom = GKRandomSource.sharedRandom() randDist0 = GKRandomDistribution(randomSource: sysRandom!, lowestValue: 0, highestValue: 0xffffffff) let _ = randDist0!.nextInt() let toss = randDist0!.nextInt() print("App Seed: \(toss)") appSeed0 = tossI keep getting a seed of 0, so I'm clearly not understanding something. The shared random source on my iPad should be giving me a random value, right? I was tossing twice just to be sure... What am I doing wrong here?
Posted
by remsleep.
Last updated
.
Post marked as solved
4 Replies
4.0k Views
I was surprised (Int,Int) isn't Hashable. How do I write the obvious extension to make it so?If I try "extension (Int,Int)" the error is that non-nominal type (Int,Int) can't be extended. The word "nominal" appears nowhere in the Swift iBooks provided by Apple, so I can't be absolutely certain that I even know what Xcode is telling here... Using a typealias gives the same error.How do I extend (Int,Int) to make it Hashable so I can use it for dictionary keys? What is a "non-nominal" type, and where can I find that definition?
Posted
by remsleep.
Last updated
.
Post not yet marked as solved
3 Replies
1k Views
As a lone developer (whose personal iPhone is stil a 6s), I would obviously need to acquire iPhone 7, 8, and X test devices -- how do I do this without disturbing my personal iPhone? Do I need to form a DBA or some other business entity and purchase devices as that entity?As a semi-retired programmer, I'm not familiar with these various legal/business aspects of app development -- any advice appreciated.
Posted
by remsleep.
Last updated
.
Post marked as solved
1 Replies
667 Views
I can't find the iOS equivalent of mach_absolute_time that will give me the current time in microseconds -- is there no such thing?
Posted
by remsleep.
Last updated
.
Post not yet marked as solved
1 Replies
1.3k Views
In the xcode IB is there any way to specify separate constraits depending on the device orientation? Essentially, in portrait I want to use a larger number of stack views (rows) with fewer items each, while in landscape I want a smaller number of stack views (rows) with a larger number of items in each. Is this possible in IB? Do I need to do this programmatically instead?
Posted
by remsleep.
Last updated
.
Post marked as solved
3 Replies
1.6k Views
I'm following the "Intro to App Development with Swift" in iBooks and in one of the tutorials it tells me to drag a new View from the Object Library onto the View Controller in the stroryboard of a single-view App. But, xcode won't accept the drag -- nothing takes effect. How do I drag a view object from the object library onto the view controller of a newly opened single-view app project?
Posted
by remsleep.
Last updated
.
Post not yet marked as solved
0 Replies
226 Views
Are there any frameworks for image recognition? I would like to recognize mahjong tiles from photographs -- can any framworks help me, or do I need to do this from scratch? If I need to do this myself, where should I start?
Posted
by remsleep.
Last updated
.
Post not yet marked as solved
0 Replies
2k Views
This code is from the latest Swift book, and makes it seem as if I can use files in much the same way that I would in Python (for example). But, I can't find any open() call in the standard library that will take a String as shown here.How can I do simple file I/O in a playground?“func processFile(filename: String) throws { if exists(filename) { let file = open(filename) defer { close(file) } while let line = try file.readline() { // Work with the file. } // close(file) is called here, at the end of the scope. }}”Excerpt From: Apple Inc. “The Swift Programming Language (Swift 4.2 beta).” iBooks. https://itunes.apple.com/us/book/the-swift-programming-language-swift-4-2-beta/id1002622538?mt=11
Posted
by remsleep.
Last updated
.