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

三、拓展阅读

相关推荐
SZ1701102313 小时前
介质访问控制(MAC)
网络·macos
鸿蒙布道师4 小时前
鸿蒙NEXT开发动画案例3
android·ios·华为·harmonyos·鸿蒙系统·arkui·huawei
鸿蒙布道师4 小时前
AI原生手机:三大技术阵营的终极对决与未来展望
android·人工智能·ios·华为·智能手机·ai-native·hauwei
蓉妹妹5 小时前
Mac电脑,idea突然文件都展示成了文本格式,导致ts,tsx文件都不能正常加载或提示异常,解决方案详细说明如下
macos·intellij-idea
Echo-潔6 小时前
iOS创建Certificate证书、制作p12证书流程
ios·ios 生成app打包证书
Tassel_YUE7 小时前
VMware Fusion安装win11 arm;使用Mac远程连接到Win
arm开发·macos
@PHARAOH21 小时前
HOW - 在 Mac 上的 Chrome 浏览器中调试 Windows 场景下的前端页面
前端·chrome·macos
yangpipi-1 天前
10.王道_HTTP
网络协议·http·ios
鸿蒙布道师1 天前
鸿蒙NEXT开发动画案例2
android·ios·华为·harmonyos·鸿蒙系统·arkui·huawei
海尔辛1 天前
学习黑客 MAC 地址深入了解
学习·macos·php