mac xcode 常见配置和使用问题汇总
2018-03-03 17:35 加个小鸡腿 阅读(686) 评论(0) 编辑 收藏 举报vbox中安装mac系统:https://www.cnblogs.com/liming2017/p/7566953.html
1.报错:There are no schemes in workspace "。。。"
解决:设置scheme共享
方法:xcode打开后,按照Product->Scheme->Manage Schemes后会出现所有的scheme,需要共享的scheme的勾选右边的shared即可
2.Build 文件夹是中间文件的保存地方,如何设置在工程目录下,不放在默认地方:
3.xcode 报错Failed to load project at xxxx ,incompatible project version
错误原因:
由于工程是低版本的Xcode建立的,在使用高版本的Xcode打开时会出现编译不了工程。
解决方法:
鼠标右击.xcodeproj文件 —》显示包内容 —》打开project.pbxproj文件,比较以前的版本号进行修改(比如:把objecVersion=50修改objecVersion=48即可打开工程)
4.mac上sed -i 执行失败报错
mac上执行就会报错“invalid command code C”,查看mac sed 发现如下:
说白了,就是需要一个中间文件来转换下,比如我们上面的sed命令在mac上可以替换成sed -i n.tmp s/$old_version/$new_version/g version.txt ,其实执行这条的时候会生成一个version.txt_n.tmp文件,这个不需要的文件,执行后删除即可。
我们可以采用uname命令来判断当前系统是不是mac,如果"$(uname)" == "Darwin",就表明是mac/ios系统。
所以完整的同时兼容linux和mac/ios的脚本如下:
if [ "$(uname)" == "Darwin" ];then #ios/mac系统 echo "this is Mac,use diff sed" sed -i n.tmp s/$old_version/$new_verison/g version.txt #如果不备份,可以只给空,即sed -i " " s/$old_version/$new_verison/g version.txt ,但是不能省略 rm *.tmp else sed -i s/$old_version/$new_version/g version.txt #linux系统 fi
sed -i n.tmp .. 会导致新增一个文件version.txtn.tmp 可以把n.tmp换成空,即sed -i " " s/$old_version/$new_verison/g version.txt ,就不会有新增文件
另一种方法是在mac上安装gun-sed:
export xsed=sed
if [ "$(uname)" == "Darwin" ];then #mac系统
echo "alias sed to gsed for Mac, hint: brew install gnu-sed"
export xsed=gsed
fi
#后面使用xsed代替sed执行替换动作,
xsed -i s/$old_version/$new_version/g version.txt
3.mac 如何命令行打开.xcodeproj或者.xcodeworkspace
open $name.xcodeproj
或者 open $name.xcodeworkspace
macdeMacBook-Pro:public mac$ open --help open: unrecognized option `--help' Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-s ][-b ] [-a ] [filenames] [--args arguments] Help: Open opens files from a shell. By default, opens each file using the default application for that file. If the file is in the form of a URL, the file will be opened as a URL. Options: -a Opens with the specified application. -b Opens with the specified application bundle identifier. -e Opens with TextEdit. -t Opens with default text editor. -f Reads input from standard input and opens with TextEdit. -F --fresh Launches the app fresh, that is, without restoring windows. Saved persistent state is lost, excluding Untitled documents. -R, --reveal Selects in the Finder instead of opening. -W, --wait-apps Blocks until the used applications are closed (even if they were already running). --args All remaining arguments are passed in argv to the application's main() function instead of opened. -n, --new Open a new instance of the application even if one is already running. -j, --hide Launches the app hidden. -g, --background Does not bring the application to the foreground. -h, --header Searches header file locations for headers matching the given filenames, and opens them. -s For -h, the SDK to use; if supplied, only SDKs whose names contain the argument value are searched. Otherwise the highest versioned SDK in each platform is used.
4.