How to find out which version of API is available for a certain OSX version? - swift

I want to retrieve some meta data of a photo asset in the Photo library. Basically the name, type and location of it. I want to implement it as a command line utility in Swift.
Here is the code I have come up with
var allPhotos : PHFetchResult<PHAsset>? = nil
let fetchOptions = PHFetchOptions()
allPhotos = PHAsset.fetchAssets(with: .image, options: fetchOptions)
But it fails to compile because of 'fetchAssets(with:options:)' is only available in macOS 10.15 or newer.
My app is targeted to run on 10.14 and my MBP is still running 10.14.
When I check the documentation page (https://developer.apple.com/documentation/photokit/phasset),
I can't find the os version information next to each API on the page.
What is the easiest way to find such information?
Also how can I make the code work for 10.14?

macOS Version Requirements
What is the easiest way to find such information?
It says on the page that 10.15+ is required:
Alternatives
Also how can I make the code work for 10.14?
Use fetchAssets(in:options:) (min 10.13) instead of fetchAssets(with:options:) (min 10.15).

Related

Swift: Is there an OS agnostic way to get the home directory?

See title. I want to create the data files for my CLI application preferably in ~/ or ~/config, but predefined Swift FileManager.default.url() doesn't seem to have it.
.homeDirectoryForCurrentUser seems to be available only for macOS Sierra and later.
Any ideas?

How to check installed app version on Apple Watch?

I know how to check app version on iPhone and tried the same way for an app installed on Apple watch in Watch App General -> Usage however not able to see app version. Can anybody help me find the app version on apple watch?
I needed to check an app's version for the app's tech support, so they told me to open the App Store on the watch, find the app and see if it says "Update" or "Open". The store shows the current version and if the button said "Open", it is up-to-date. I don't know yet how to check another way, but thought this may help you.
There is no way to check the version on Apple Watch as per my investigation. mostly the apple watch version is the same as the iPhone app version.
Swift way of getting the current app's version and build number. šŸ˜
add this extension to your project. either as a separate file or in one of your existing files.
then you can get the version and build number like this:
let version = Bundle.version // e.g: 1.2
let build = Build.build // e.g: 16
let versionAndBuild = Build.versionAndBuild // e.g: v1.2(16)
please be careful to not use Build.version() instead. it'll return "0".
and here is the extension:
import Foundation
import WatchKit
public extension Bundle {
static var version: String? {
return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
}
static var build: String? {
return Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as? String
}
static var versionAndBuild: String? {
guard let version = Bundle.version,
let build = Bundle.build else {
return nil
}
return version == build ? "v\(version)" : "v\(version)(\(build))"
}
}

Xcode FIREBASE crashes

I have recently upgraded to Swift 4.2 and I am not able to run my project anymore since then.
I had hundreds of mistakes which I all fixed, the app starts but crashes as soon as it tries to access data from my database
example code
guard let currentUser = API.User.CURRENT_USER?.uid else {return}
crash: Thread 1: signal SIGABRT
I had my app working for over a year now and thousands of users so the code worked previously quit fine.
I have updated my cocoa pods to the newest point, as my terminal said that firebaseauth requires at least 1.4 cocoa pods.
I have updated and newly installed all pods, I deleted my plist and downloaded it again and put it into the project, all to no avail.
My app is working if you download the old version from the App Store, but I want to update some things and need it to run again
Any advice? I have tried everything I found
For Firebase 4/5 and Swift 4, here's the function call to get the currently authenticated users uid
guard let currentUser = Auth.auth().currentUser?.uid else { return }

Deep link issue on iOS (Universal Link)

I have created several Uber deep links via the Uber deep link generator and the links work fine on my Android device. However, when I access the links on my iOS, the Uber app comes on but the dropoff address doesn't come up. Instead, it shows me an empty search bar and I have to type in the address again. I proceeded to re-arrange my client_id to the front as shown but it still yield the same results.
https://m.uber.com/ul/?client_id=jZywlUAYPjYl3uRcFPquz0e_wJqLSmPZ&dropoff[formatted_address]=No.%2047%2C%20Beian%20Road%2C%20Zhongshan%20District%2C%20Taipei%20City%2C%2010491&action=setPickup&pickup=my_location
Does anyone know what I did wrong or what else should I do for this to work on both Android and iOS?
There are two things that you can check :
A minimum OS level of iOS 9 is required for Universal Links support. So please make sure your iOS version is up to date.
Can you try to add to your Universal Link : &dā€Œropoff[latitude]=xx.xxx&dropoff[longiā€Œtude]=yy.yyy
UPDATE:
I have tested following Universal Link on my iPhone and it is working:
https://m.uber.com/ul/?action=setPickup&client_id=Rd3a2B9JITPWPLPzmvXXXXXXX&pickup[latitude]=25.0791848&pickup[longitude]=121.5265924&dropoff[latitude]=25.0777658&dropoff[longitude]=121.5283466&dropoff[nickname]=No.%2047%2C%20Beian%20Road%2C%20Zhongshan%20District%2C%20Taipei%20City%2C%2010491
Or
https://m.uber.com/ul/?action=setPickup&client_id=Rd3a2B9JITPWPLPzmvXXXXXXX&pickup[latitude]=25.0791848&pickup[longitude]=121.5265924&dropoff[latitude]=25.0777658&dropoff[longitude]=121.5283466&dropoff[formatted_address]=No.%2047%2C%20Beian%20Road%2C%20Zhongshan%20District%2C%20Taipei%20City%2C%2010491
I have added pick up location because my real location is not the location you specified - but pickup=my_locā€Œation is also fine if it is not against Uber terms related to pickup and destination distance. Also instead of "dropoff[formatted_address]" try to use "dropoff[nickname]"

Guard Malloc doesn't work

I'm experimenting with different profiling options that Xcode provides, but when I enabling Guard Malloc option in Diagnostics tab and trying to run, I'm getting this error with immediate crash:
dyld: could not load inserted library: /usr/lib/libgmalloc.dylib
And it is right, /usr/lib/ doesn't contain this library. I've located it in:
Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/lib/
So I've created link, and started Command Line Tool (just to be sure, because it apparently part of MacOS SDK), enabled Guard Malloc again but the problem remains.
I don't quite get where is a problem: does it new Xcode 4.3 inadvertence, problem with my system or planned decision by Apple to replace it with something else (maybe Instruments)?
on device or simulator?
According to http://developer.apple.com/library/ios/#DOCUMENTATION/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html
You can use this option both Mac apps and also for iPhone applications running in the simulator.
Well, I got stuck by this too. From an apple list:
http://prod.lists.apple.com/archives/xcode-users/2012/Feb/msg00197.html
That's a known issue that's being investigated. I think that you may be able to work around it by installing the 10.7.3 combo installer
Which means you need to download the combo installer from: http://support.apple.com/kb/DL1484?
I'm trying it now to make sure it works, but the person on the mailing list said it worked.
Problem came up again recently, combo update didn't helped (libgmalloc.dylib was in place).
New solution was to Repair Disk Permissions in Disk Utility:
It looks like you can't enable Guard Malloc when debugging directly on a device (at least iPad in my case), even when running the latest and greatest versions of everything. Running still works in the simulator though.