❤️ Support my app ❤️
- Push Hero - pure Swift native macOS application to test push notifications
- PastePal - Pasteboard, note and shortcut manager
- Frame recorder - Recorder gif and video with frame
- Other apps
❤️❤️😇😍🤘❤️❤️
Notes on configuring test targets
- Main targets
- App
- Framework
- Test targets
- Unit tests
- UI tests
Dependencies used
Examples
- Cocoapods
- Carthage
- Make sure test target can link to all the frameworks it needs. This includes frameworks that Test targets use, and possibly frameworks that Main target uses !
- Remember to "Clean Build Folder" and "Clear Derived Data" so that you're sure it works. Sometimes Xcode caches.
Errors occur mostly due to linker error
- Test target X encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted
- Framework not found
Test targets need to include pods that Main target uses !
or we'll get "Framework not found"
def app_pods
pod 'Sugar', '~> 1.0'
end
def test_pods
pod 'Nimble', '~> 3.2'
pod 'Quick', '~> 0.9'
end
target 'TeaApp' do
app_pods
end
target 'TeaAppTests' do
app_pods
test_pods
end
target 'TeaAppUITests' do
app_pods
test_pods
end
Cocoapods builds a framework that contains all the frameworks the Test targets need, and configure it for us
- Go to Test target Build Settings
- Add
$(FRAMEWORK_SEARCH_PATHS)
We usually have
- Cartfile for Main target
github "hyperoslo/Sugar" ~> 1.0
- Cartfile.private for Test target
github "Quick/Nimble"
github "Quick/Quick"
- Go to Test target build phase
- Drag built frameworks from
Carthage/Build
- In rare case, we need to drag frameworks that the Main target uses
- In rare case, we need to drag the Main target framework
Configure correct path
- Go to Test target Built Settings
- Configure Framework Search Paths
- Go to Test target Build Settings
- Add
$(FRAMEWORK_SEARCH_PATHS)
From Adding frameworks to unit tests or a framework
In rare cases, you may want to also copy each dependency into the build product (e.g., to embed dependencies within the outer framework, or make sure dependencies are present in a test bundle). To do this, create a new “Copy Files” build phase with the “Frameworks” destination, then add the framework reference there as well.
Question
- Why preconfigured run path "@executable_path/Frameworks" and "@loader_path/Frameworks" not work?
- Why configuring runpath to "$(FRAMEWORK_SEARCH_PATHS)" works ?
- Why framework has install name "@rpath/Sugar.framework/Sugar" ?
Reference
Khoa Pham, [email protected]
TestTarget is available under the MIT license. See the LICENSE file for more info.