How to get iOS APP archive date using Swift [duplicate] - ios

This question already has answers here:
Get build date and time in Swift
(6 answers)
Closed 5 years ago.
I have a requirement in my application that, i need to show .ipa file creation date using swift.
Can anybody tell me how to do that.
Thanks in advance.

You can get the url of your app using Bundle property executableURL and use url method resourceValues to get the bundle creation date:
if let executableURL = Bundle.main.executableURL,
let creation = (try? executableURL.resourceValues(forKeys: [.creationDateKey]))?.creationDate {
print(creation)
}

Related

How to configure and use a bundle in Xcode for iPhone apps? [duplicate]

This question already has answers here:
How do I add an MP3 to my iOS/Xcode project?
(1 answer)
How to add sound files to your bundle in Xcode?
(4 answers)
Closed 10 months ago.
I need to use some audio content in the app I'm coding in Swift with Xcode. That's the first time I try to use a bundle with Xcode.
First I created a local folder on my Mac called "mybundle.bundle" containing my file "mysound.mp3"
I dragged and dropped it in Xcode, the bundle goes to the assets correctly.
But then things get tough. I tried different syntaxes of code to access my file in the bundle.
guard let path = Bundle.main.resourcePath!+"/bundle mybundle.bundle/mysound.mp3" else {
return print("Error")
}
That code always goes to print "Error".
Also tried this :
guard let url = Bundle.main.url(forResource: "mysound", withExtension: "mp3") else {
print("Error")
return
}
Same thing.
Is there any additional setup to do before that main bundle is available for access ?
Thanks a lot !

Localization.strings: The data couldn’t be read because it isn’t in the correct format [duplicate]

This question already has answers here:
Localization in Swift 2
(3 answers)
Closed 5 years ago.
The data couldn’t be read because it isn’t in the correct format. The text in .string file. Please help me for it
abc = "abc"
xyz = "xyz"
You have to set a semicolon after each row, that´s why you´re getting that error:
Like this:
abc = "abc";
xyz = "xyz";

Swift Share CoreData between App and Today Extension [duplicate]

This question already has an answer here:
How to access CoreData model in today extension (iOS)
(1 answer)
Closed 6 years ago.
I want to access my CoreData from my Today Extension Widget to display some data. I already read that I have to create an app group and add this one to my App and my Widget. I already have done this, but now I'm not sure what to do next. I found an old tutorial but the methods used there aren't available or I'm not able to find them in AppDelegate. Can anybody help me please?
You need to get the URL of the group container with containerURL(forSecurityApplicationGroupIdentifier: of FileManager passing the container identifier in both targets:
lazy var secureAppGroupPersistentStoreURL : URL = {
let fileManager = FileManager.default
let groupDirectory = fileManager.containerURL(forSecurityApplicationGroupIdentifier: "group.com.mydomain.myapp")!
return groupDirectory.appendingPathComponent("databaseName.sqlite")
}()

iOS get Last mobile shutdown time [duplicate]

This question already has answers here:
Getting iOS system uptime, that doesn't pause when asleep
(6 answers)
Closed 6 years ago.
Is this possible to get Last shutdown or reboot time using objective c or Swift.
I tried many websites and forums. i can't find solution for this problem.
Check out NSProcessInfo there is a property called systemUptime of type NSTimeInterval
NSProcessInfo.processInfo().systemUptime
[[NSProcessInfo processInfo] systemUptime]
I gave you your answer in both objective-c and swift since you tagged them both.
You cannot detect the last shutdown time. But you can detect the last reboot time as:
let systemUptime = NSProcessInfo.processInfo().systemUptime;
And to detect the time, since last reboot is:
let systemUptime = NSProcessInfo.processInfo().systemUptime;
let timeNow = NSDate().timeIntervalSince1970
let dateOfLastReboot = NSDate(timeIntervalSince1970: timeNow-systemUptime)

How to get String from a NSTaggedPointerString? [duplicate]

This question already has answers here:
convert NSTaggedPointerString to NSString
(5 answers)
Closed 6 years ago.
It's about a Get network request, for more information please see this pic.
I want to get the argument "pilotCode", but its value is "0xa00006e....", I want to get its real value which is "admin", please tell me what should I do?
Thank you very much.
I solved this problem just now.
just add this code:
"NSString *realStr = [NSString stringWithString:pilotCode];"

Resources