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.)
To set the Framework Search Paths
for the unit test target, do the following steps:
- 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
Please see the below image:
Now, you have done to the step 3. Step 4 is following:
- 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"
The step 4 is not required for development, but it needs to work around an App Store submission bug when you submit the app.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…