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

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

How to add the parent path to RealmSwift.framework in the “Framework Search Paths” section?

iosxcodeswiftrealm

提问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:

如果您正确执行第二步,项目目录将如下所示:

enter image description here

在此处输入图片说明

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 Pathsfor 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 Pathsfor the unit test target, do the following steps:

要设置Framework Search Paths单元测试目标,请执行以下步骤:

  1. Click the project in the "Project Navigator" of Xcode
  2. Click the unit test target in the "TARGETS" section
  3. Click the "Build Settings" tab
  4. Scroll down and find the "Search Paths" section
  5. Double click the value of "Framework Search Paths"
  6. Click "+" button in the bottom-left of popover
  7. 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).)
  8. Press "enter" key to accept the text
  1. 在Xcode的“项目导航器”中点击项目
  2. 单击“目标”部分中的单元测试目标
  3. 单击“构建设置”选项卡
  4. 向下滚动并找到“搜索路径”部分
  5. 双击“框架搜索路径”的值
  6. 点击弹出框左下角的“+”按钮
  7. 添加$(PROJECT_DIR)到文本字段(“父路径”是框架中的位置。所代表的项目根目录中的框架$(PROJECT_DIR)。)
  8. 按“输入”键接受文本

Please see the below image:

请看下图:

enter image description here

在此处输入图片说明

Now, you have done to the step 3. Step 4 is following:

现在,您已完成第 3 步。第 4 步如下:

  1. Click the main app's target in the "TARGETS" section
  2. Click "Build Phases" tab
  3. Click the "+" button in the top-left corner
  4. Select the "New Run Script Phase"
  1. 在“目标”部分单击主应用程序的目标
  2. 单击“构建阶段”选项卡
  3. 点击左上角的“+”按钮
  4. 选择“新建运行脚本阶段”

enter image description here

在此处输入图片说明

  1. Open "Run Script" section that added
  2. Paste the following snippet to the text field bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework/strip-frameworks.sh"
  1. 打开添加的“运行脚本”部分
  2. 将以下代码段粘贴到文本字段 bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework/strip-frameworks.sh"

enter image description here

在此处输入图片说明

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 提交错误。