Build information in iOS Application (date/time app was built)

前端 未结 2 1200
小蘑菇
小蘑菇 2020-12-10 05:55

I\'m looking for a way to dynamically add in information about the application during the build process of an iOS application.

During testing, it would be great to k

2条回答
  •  独厮守ぢ
    2020-12-10 06:29

    You can write a shell script build phase in Xcode that runs at the end of your build process. In this phase you can use the defaults command to write data to an arbitrary file. I've used this technique to write to the Info.plist file, but you can write to any file you want[1].

    Here's a sample script to write the current git version to Info.plist:

    infoplist="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
    gitversion="$(cd "$SRCROOT" && git describe --always --dirty 2>/dev/null)"
    if [[ -n "$gitversion" ]]; then
        defaults write "${infoplist%.plist}" GitVersion "$gitversion"
    fi
    

    You should be able to adapt this to point to the file you want (e.g. your Settings bundle) and write the info you want.

    [1] Be careful if you write to Info.plist, Xcode has bugs that can prevent it from realizing Info.plist changed during the build, which can break the provisioning when doing a device build.

提交回复
热议问题