0

In my iOS app I need to find the Date when app was compiled and show it.

Is there a way to figure it out without setting the date manually?

AlexanderZ
  • 2,128
  • 3
  • 20
  • 24
  • You can set build number as date with build script and read it from `Budle`. – Ryan Dec 14 '16 at 16:47
  • There should be the way to get the date without setting it each time you compile the app. – AlexanderZ Dec 14 '16 at 16:50
  • Which do you want, Objective-C or Swift? This is trivial with Objective-C. I don't know if it can be done in Swift. – rmaddy Dec 14 '16 at 16:55
  • Like @Ryan said, you can probably get it from the app bundle. Call up the .app file and retrieve the date. I'm not sure you need to do anything with the build number, just get the .app file. –  Dec 14 '16 at 16:57

1 Answers1

0

In my iOS app I need to find the Date when app was compiled and show it.

You can use a shell script to write the date into a file that's included in the app's assets. Run the script as an early step in the build process using a "Run Script" build phase in your target's Build Phases. Then add code to your app that finds the file and reads the date. I'd recommend using either property list or JSON file formats here to make reading the date easy. If you go with a property list, there's a command line tool called PlistBuddy that'll make it easy to write your shell script.

Caleb
  • 124,013
  • 19
  • 183
  • 272