1. 程式人生 > >swift 讀取info.plist檔案中的資訊

swift 讀取info.plist檔案中的資訊

//在頂部狀態列顯示風火輪(iPhonex之後沒有好像)

        UIApplication.shared.isNetworkActivityIndicatorVisible = true

//  讀取info.plist中的資訊

        let mainBundle = Bundle.main

        let identifer = mainBundle.bundleIdentifier

        let info = mainBundle.infoDictionary

        let bundleId = mainBundle.object(forInfoDictionaryKey: "CFBundleName")

        let version = mainBundle.object(forInfoDictionaryKey: "CFBundleShortVersionString")

        print("[identifer]:\(identifer!)")

        print("[info]:\(info!)")

        print("[bundleId]:\(bundleId!)")

        print("[version]:\(version!)")