Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

ios - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...