xcode 如何在“框架搜索路径”部分添加 RealmSwift.framework 的父路径?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31896667/
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
How to add the parent path to RealmSwift.framework in the “Framework Search Paths” section?
提问by osha
This is step is listed in the instructions for installing Realm. link here: https://realm.io/docs/swift/latest/
这是安装 Realm 的说明中列出的步骤。链接在这里:https: //realm.io/docs/swift/latest/
I am new to xcode and I don't understand how to complete this step. Can someone give me detailed instructions? I found the Framework Search Paths section in the build settings, but I don't even know what it means to add a parent path.
我是 xcode 的新手,我不明白如何完成这一步。有人可以给我详细的说明吗?我在构建设置中找到了框架搜索路径部分,但我什至不知道添加父路径意味着什么。
I also need help with the next step, creating a new run script phase.
我还需要下一步的帮助,创建一个新的运行脚本阶段。
xcode ver 6.4
xcode 6.4 版
回答by kishikawa katsumi
If you follow to 2nd step correctly, the project directory will be like following:
如果您正确执行第二步,项目目录将如下所示:
Now, you can build main app's target fine. However, if you execute the unit test with Realm, it will be failed to build due to it cannot find the framework. So you should tell where in the framework is. (More precisely, you should also set the Framework Search Paths
for the app's primary target. It was set by Xcode automatically when step 2 is done.)
现在,您可以很好地构建主应用程序的目标。但是,如果您使用 Realm 执行单元测试,则会由于找不到框架而导致构建失败。所以你应该告诉框架中的位置。(更准确地说,您还应该Framework Search Paths
为应用程序的主要目标设置 。它是在第 2 步完成后由 Xcode 自动设置的。)
To set the Framework Search Paths
for the unit test target, do the following steps:
要设置Framework Search Paths
单元测试目标,请执行以下步骤:
- Click the project in the "Project Navigator" of Xcode
- Click the unit test target in the "TARGETS" section
- Click the "Build Settings" tab
- Scroll down and find the "Search Paths" section
- Double click the value of "Framework Search Paths"
- Click "+" button in the bottom-left of popover
- Add
$(PROJECT_DIR)
to text field ("Parent path" is the place where is in the framework. The framework in the project root directory that is represented$(PROJECT_DIR)
.) - Press "enter" key to accept the text
- 在Xcode的“项目导航器”中点击项目
- 单击“目标”部分中的单元测试目标
- 单击“构建设置”选项卡
- 向下滚动并找到“搜索路径”部分
- 双击“框架搜索路径”的值
- 点击弹出框左下角的“+”按钮
- 添加
$(PROJECT_DIR)
到文本字段(“父路径”是框架中的位置。所代表的项目根目录中的框架$(PROJECT_DIR)
。) - 按“输入”键接受文本
Please see the below image:
请看下图:
Now, you have done to the step 3. Step 4 is following:
现在,您已完成第 3 步。第 4 步如下:
- Click the main app's target in the "TARGETS" section
- Click "Build Phases" tab
- Click the "+" button in the top-left corner
- Select the "New Run Script Phase"
- 在“目标”部分单击主应用程序的目标
- 单击“构建阶段”选项卡
- 点击左上角的“+”按钮
- 选择“新建运行脚本阶段”
- Open "Run Script" section that added
- Paste the following snippet to the text field
bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework/strip-frameworks.sh"
- 打开添加的“运行脚本”部分
- 将以下代码段粘贴到文本字段
bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework/strip-frameworks.sh"
The step 4 is not required for development, but it needs to work around an App Store submission bug when you submit the app.
第 4 步不是开发所必需的,但需要在您提交应用程序时解决 App Store 提交错误。