如何在 Xcode 4 和 Cordova 中使用符号链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10836460/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:26:56  来源:igfitidea点击:

How do I use symbolic links with Xcode 4 and Cordova

xcodecordova

提问by Hyman

I'm unable to get Xcode to copy over www resources to my PhoneGap based iPhone app. I considered using Git submodules, but since the app has to work on different platforms (iPhone, Android, etc) and has to be branded differently (images, css, and small changes to some files), it does not solve the complete problem.

我无法让 Xcode 将 www 资源复制到我的基于 PhoneGap 的 iPhone 应用程序。我考虑过使用 Git 子模块,但由于应用程序必须在不同的平台(iPhone、Android 等)上运行,并且必须以不同的方式标记(图像、css 和对某些文件的小改动),因此它并不能解决完整的问题。

I ended with a solution where I created an external core www folder and created symlinks for every file from the different projects. If a file needed special attention on a platform or for a branding requirement, then I could simply replace that instance of a symlink with an actual file.

我以一个解决方案结束,我创建了一个外部核心 www 文件夹,并为来自不同项目的每个文件创建了符号链接。如果某个文件在平台上需要特别注意或有品牌要求,那么我可以简单地用实际文件替换该符号链接实例。

This all would work like a charm, but for some reason Xcode for does not copy the symlinked resources over to the phone. Does anyone have any idea how to make this work? Or a solid alternative. Even if this takes me a day to fix.

这一切都会像一个魅力一样工作,但出于某种原因,Xcode for 不会将符号链接的资源复制到手机上。有谁知道如何使这项工作?或者一个可靠的选择。即使这需要我一天才能解决。

Thanks.

谢谢。

回答by Hyman

This solutionworked perfectly to pull in the symlinks on build. Using this method you can build Phonegap solutions for all platforms and have them branded differently with the absolute minimum code duplication.

该解决方案非常适合在构建时引入符号链接。使用这种方法,您可以为所有平台构建 Phonegap 解决方案,并以绝对最少的代码重复对它们进行不同的标记。

In short, create a common directory that contains all your phonegap www contents, and then symlink this from your different projects (platform differences or branding differences). For building on Xcode, add the following to your project's run script:

简而言之,创建一个包含所有 phonegap www 内容的公共目录,然后从您的不同项目(平台差异或品牌差异)中符号链接它。要在 Xcode 上构建,请将以下内容添加到项目的运行脚本中:

rsync -pvtrlL --cvs-exclude \
    $PROJECT_DIR/../Resources* \
    $BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH

Note: You also need to dereference symlinks if you build for BlackBerry.

注意:如果您为 BlackBerry 构建,您还需要取消引用符号链接。

回答by bearfriend

I just want to say that using symbolic links shouldn't be necessary. You can simply drop the folder into xcode, and DO NOT copy the files.

我只想说不需要使用符号链接。您可以简单地将文件夹放入 xcode,并且不要复制文件。

In my case, my shared folder was called "mobile", so I did have to create this run script:

就我而言,我的共享文件夹被称为“移动”,所以我必须创建这个运行脚本:

mv $BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/mobile $BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/www

This simply renames the directory so Cordova can find what it's looking for.

这只是重命名目录,以便 Cordova 可以找到它要查找的内容。