Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

This is step is listed in the instructions for installing Realm. link here: 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.

I also need help with the next step, creating a new run script phase.

xcode ver 6.4

like image 479
osha Avatar asked Aug 08 '15 17:08

osha


People also ask

How do I add a framework to a swift project?

In order to create an iOS Framework you need to click on File -> New -> Project (Shift + Cmd + N) -> Framework (under iOS tab, Framework & Library section). Framework under Framework & Library section.

How do I reference a framework in Xcode?

To include a framework in your Xcode project, choose Project > Add to Project and select the framework directory. Alternatively, you can control-click your project group and choose Add Files > Existing Frameworks from the contextual menu.


1 Answers

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 Paths for the app's primary target. It was set by Xcode automatically when step 2 is done.)

To set the Framework Search Paths for the unit test target, do the following steps:

  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

Please see the below image:

enter image description here

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

  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"

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"

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.

like image 127
kishikawa katsumi Avatar answered Sep 25 '22 00:09

kishikawa katsumi