Switch开发环境搭建

13 3月

如果由于各种原因需要在Switch上做开发,那么第一个需要的就是环境配置。目前主要需要的是devkitA64和libnx。

devKitA64是在devkitPro下的,另外还有ARM、3ds等,如果只是Switch开发安装A64即可。这里注意下devkitPro没有版本号管理一说。

Mac

我这里以mac为例,首先下载devkitPro_pacman,按照说明安装。然后确认下xcode情况

xcode-select --install

修改环境配置为

export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
export PATH=${DEVKITPRO}/tools/bin:$PATH

libnx在上面安装完成后会自带,不需要额外处理。

Ubuntu

如果是ubuntu系统,安装步骤基本一致,首先确保依赖

apt-get git wget install libxml2 libstdc++6 gpg xz-utils make -y

安装pacman并设置环境变量

wget https://github.com/devkitPro/pacman/releases/download/devkitpro-pacman-1.0.1/devkitpro-pacman.deb
RUN dpkg -i devkitpro-pacman.deb && dkp-pacman -S switch-dev --noconfirm
RUN source /etc/profile.d/devkit-env.sh

Docker

如果用vs code并启用了remote development,可以用我打好的预设镜像

docker pull registry.cn-shanghai.aliyuncs.com/htynkn/switch-devenv

或者使用官方的镜像

docker pull devkitpro/devkita64

vs code配置如下

{
	"name": "devkita64",
	"dockerFile": "Dockerfile",
	
	// Set *default* container specific settings.json values on container create. 
	"settings": {
		"terminal.integrated.shell.linux": "/bin/sh"
	},

	// Add the IDs of extensions you want installed when the container is created.
	// Note that some extensions may not work in Alpine Linux. See https://aka.ms/vscode-remote/linux.
	"extensions": []

	// Use 'forwardPorts' to make a list of ports inside the container available locally.
	// "forwardPorts": [],

	// Use 'postCreateCommand' to run commands after the container is created.
	// "postCreateCommand": "uname -a",

	// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
	// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

	// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
	// "remoteUser": "vscode"
}

运行效果如下:

开发语言需要掌握ASM/C/C++,示例项目可以参考:https://github.com/switchbrew/switch-examples

另外还有几个比较典型的可以参考:

UI库:

https://github.com/rock88/libnx-SDL2

https://github.com/XorTroll/Plutonium

参考项目:

https://github.com/AtlasNX/Swurl/tree/master

https://github.com/AtlasNX/Kosmos-Updater

发表评论

电子邮件地址不会被公开。