iOS开发进阶(十三):脚手架创建iOS项目

文章目录

一、前言

项目初期,需要搭建项目基本框架,为此离不开辅助工具,即脚手架。当然,IDE也可以实现新建空白项目,但是其新建后的项目结构可能不符合预期设计,故需要通过脚手架创建项目方式统一项目开发规范,对于开发管理至关重要。

脚手架shell文本命令(createiOS.sh)如下:

powershell 复制代码
git clone http://88.66.99.83/BPPlatform/vast_app_template.git
cd vast_app_template
/usr/local/cocoapods/bundle/bin/bundle-env ruby create_xcode_project.rb ../ TestSC com.boc.test
open ../

其中,create_xcode_project.rb文件内容如下:

javascript 复制代码
require File.expand_path('../proj_creator', __FILE__)
require File.expand_path('../file_migration', __FILE__)
require File.expand_path('../conf_substitution', __FILE__)
require File.expand_path('../create_main_workspace', __FILE__)

# # create program
# puts "\033[32m'=============START============='\033[0m\n"
# creator = ProCreator.new
# creator.start
#
# # migrate files
# puts "\033[32m'files setting...'\033[0m\n"
# mig = FileMigration.new
# mig.migration
#
# # replace key words
# puts "\033[32m'content setting...'\033[0m\n"
# subOp = ConfSubsitution.new
# subOp.start
#
# puts "\033[32m'pod install...'\033[0m\n"
# puts "\033[32m#{`pod install`}\033[0m\n"
#
#

rootpath = ARGV.shift

projName = ARGV[0]

bundleid = ARGV[1]

widgets = ARGV[2]

generator = WorkspaceGenerator.new(rootpath, projName, bundleid, widgets)

generator.create

执行shell脚本:

powershell 复制代码
./createiOS.sh

生成后的项目结构如下图所示:

由项目结构可知,脚手架中对项目做了很好的分层处理,便于项目解耦。

二、xcode-select 命令

Print or change the path to the active developer directory. This directory controls which tools are used for the Xcode command line tools (for example, xcodebuild) as well as the BSD development commands (such as cc and make).

-help可查看xcode-select存在哪些命令:

当安装多个xcode的版本,使用该工具使用指定的版本。

  • -p 或者 --print-path 查看当前开发者目录,也即是xcode的版本目录。
  • -s <path>--switch <path> 选择xcode版本。
  • --install 安装;
  • --version 查看版本;
  • --reset 恢复默认;
  • sudo rm -rf /Library/Developer/CommandLineTools 强制删除安装目录下的文件;
powershell 复制代码
sudo xcode-select --switch Xcode.app

三、拓展阅读

相关推荐
北京自在科技1 小时前
苹果折叠屏iPhone突破折痕难题 或将在2026年发布
ios·iphone·findmy·折叠屏·库克
一粒沙-1 小时前
iOS 将GIF图分享至微信
前端·ios
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
吃汤圆的抹香鲸2 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
Mamong11 小时前
Metal 学习笔记三:渲染管线
ios·swift·metal
甜于酸13 小时前
MuMu模拟器Pro for Mac 安卓手机平板模拟器
android·macos·智能手机
渔夫阿布13 小时前
在MAC上面通过HomeBrew安装node和npm@指定版本
前端·macos·npm
waicsdn_haha14 小时前
TeX Live 2025 最新版安装与中文环境配置全教程(Windows/Mac/Linux)
linux·windows·macos·论文笔记·sublime text·mdk·嵌入式开发工具
yidahis15 小时前
用DeepSeek学源码-SDImageCodersManager 中的工厂模式解析
ios·源码
xinyu39118 小时前
iOS Framework代码中加载图片资源
macos·ios·cocoa