前端analysis | What,Why,Who,When,Where,How

《NativeScript》- nativescript入门

2020-12-25

快速入门Hello-world

本文基于mac系统,采用HomeBrew安装

node 安装

nativescript 安装

1
npm i -g nativescript  

校验版本安装(Telerik NativeScript)

1
> tns

安装 NativeScript Playground 到手机

app-store or google play下载即可

项目创建

1
> tns create HelloWorld --template tns-template-blank-ng

项目预览

1
2
> cd HelloWorld
> tns preview

本地开发build

For iOS development

1
2
3
4
5
6
Latest Xcode
Command-line tools for Xcode
xcodeproj ruby gem
CocoaPods
The six python package

For Android development

1
2
3
4
5
JDK 8 or later
Latest official release of Android SDK
Android Support Repository
(Optional) Google Repository
Android SDK Build-tools 28.0.3 or later

安装Xcode

APP-Store中可下载

1
xcodebuild -version

mac系统一键安装依赖

1
ruby -e "$(curl -fsSL https://www.nativescript.org/setup/mac)"

检测依赖是否安装完毕, No issues were detected 表示已安装完毕,关键在于前几步骤

1
> tns doctor

Java

1
2
3
4
5
6
7
8
9
10
brew tap homebrew/cask-versions
brew update
brew tap homebrew/cask

#更新库
brew tap AdoptOpenJDK/openjdk
#下载最新的
brew install --cask adoptopenjdk
brew install --cask adoptopenjdk8
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

SDK配置

1
2
3
4
5
6
#安装sdk
brew tap caskroom/cask
brew reinstall android-sdk
brew install --cask android-sdk
export ANDROID_HOME=/usr/local/share/android-sdk
brew install --cask android-platform-tools

sdk 安装成功后,路径

多库问题

Cask adoptopenjdk8 exists in multiple taps:
homebrew/cask-versions/adoptopenjdk8
adoptopenjdk/openjdk/adoptopenjdk8

1
rm /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-versions/Casks/adoptopenjdk8.rb

Java 版本切换配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Add the below function in your ~/.bashrc or ~/.zshrc
jdk() {
version=$1
export JAVA_HOME=$(/usr/libexec/java_home -v"$version");
java -version
}
For Fish shell user, add the below function in your ~/.config/fish/functions

function jdk
set java_version $argv
set -Ux JAVA_HOME (/usr/libexec/java_home -v $java_version)
java -version
end

iOS 8 Drop at Xcode 12

iOS Simulator deployment target ‘IPHONEOS_DEPLOYMENT_TARGET’ is set to 8.0

1
2
3
4
5
6
7
8
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end

Python版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
brew install pyenv

pyenv install 3.7.3

pyenv global 3.7.3

echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"

echo "alias python=/usr/local/bin/python3.7" >> ~/.bashrc
brew list | grep python
brew info python

If you need to have python@3.8 first in your PATH run:
echo 'export PATH="/usr/local/opt/python@3.8/bin:$PATH"' >> ~/.zshrc

For compilers to find python@3.8 you may need to set:
export LDFLAGS="-L/usr/local/opt/python@3.8/lib"

For pkg-config to find python@3.8 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/python@3.8/lib/pkgconfig"

使用支付宝打赏
使用微信打赏

若你觉得我的文章对你有帮助,欢迎点击上方按钮对我打赏