我试图在构建前操作中从Xcode运行python脚本:
#! /usr/bin/env python
import shutil
import os
app_name = 'name'
def skinfunction(root_src_dir, root_dst_dir):
for src_dir, dirs, files in os.walk(root_src_dir):
print(str(files))
dst_dir = src_dir.replace(root_src_dir, root_dst_dir)
if not os.path.exists(dst_dir):
os.mkdir(dst_dir)
for file_ in files:
src_file = os.path.join(src_dir, file_)
dst_file = os.path.join(dst_dir, file_)
if os.path.exists(dst_file):
os.remove(dst_file)
shutil.copy(src_file, dst_dir)
root_src_dir = '${PROJECT_DIR}/skins/'+str(app_name)+'/authorize_bg.imageset'
root_dst_dir = '${PROJECT_DIR}/iDetail/Images.xcassets/authorize_bg.imageset'
skinfunction(root_src_dir,root_dst_dir);
在脚本接近尾声时,我试图获取PROJECT-DIR-Xcode环境变量,但它无法正常工作。或者值的格式无效。在
如果我硬编码PROJECT_DIR值(项目所在位置的完整url)并且脚本成功运行。在
我是不是在尝试获取环境变量时遗漏了什么。在
好的,我想好了,而不是通过使用需要调用的${PROJECT_DIR}直接获取环境变量操作系统.getenv()功能。我可以通过调用以下命令获取环境变量:
相关问题 更多 >
编程相关推荐