Я пришел сюда из Google и был удивлен, увидев рабочий пример.
const reader = new FileReader()
reader.onload = event => console.log(event.target.result) // desired file content
reader.onerror = error => reject(error)
reader.readAsText(file) // you could also read images and other binaries
См. полный рабочий пример ниже.
document.getElementById('input-file')
.addEventListener('change', getFile)
function getFile(event) {
const input = event.target
if ('files' in input && input.files.length > 0) {
placeFileContent(
document.getElementById('content-target'),
input.files[0])
}
}
function placeFileContent(target, file) {
readFileContent(file).then(content => {
target.value = content
}).catch(error => console.log(error))
}
function readFileContent(file) {
const reader = new FileReader()
return new Promise((resolve, reject) => {
reader.onload = event => resolve(event.target.result)
reader.onerror = error => reject(error)
reader.readAsText(file)
})
}
label {
cursor: pointer;
}
textarea {
width: 400px;
height: 150px;
}
(версия комплекта) CFBundleVersion - иначе Marketing version
, который покажут на странице Вашего продукта на Appstore.
CFBundleShortVersionString (Строка версий комплекта, короткая) - связывают число, обычно используемое в качестве вспомогательной версии, которая видна пользователям TestFlight, которые только
Вот то, как может Вы получать их в Swift (4+)
программно:
let buildNumber = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as? String,
let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString")
я нуждался в маркетинговой версии в своем сценарии оболочки однажды и здесь - как я получил его с помощью xcode build tools
:
xcodebuild -showBuildSettings -project ${SDK_PROJECT} | sed '1d;s/^ *//;s/"/\\"/g;s/ = \(.*\)/="\1"/;s/ = /=/;s/UID.*//' > xcodebuild-env.tmp
source xcodebuild-env.tmp
echo "${MARKETING_VERSION}"