{"id":17690223,"url":"https://github.com/onmyway133/testtarget","last_synced_at":"2025-05-07T02:43:31.947Z","repository":{"id":7893057,"uuid":"55266732","full_name":"onmyway133/TestTarget","owner":"onmyway133","description":":whale: Notes on configuring test targets","archived":false,"fork":false,"pushed_at":"2023-03-16T19:57:11.000Z","size":1068,"stargazers_count":44,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T05:32:55.019Z","etag":null,"topics":["framework","runpath","searchpath","swift","target","test","xcode"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onmyway133.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-01T22:48:22.000Z","updated_at":"2022-04-20T15:43:22.000Z","dependencies_parsed_at":"2024-10-24T17:16:58.716Z","dependency_job_id":null,"html_url":"https://github.com/onmyway133/TestTarget","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmyway133%2FTestTarget","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmyway133%2FTestTarget/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmyway133%2FTestTarget/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onmyway133%2FTestTarget/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onmyway133","download_url":"https://codeload.github.com/onmyway133/TestTarget/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252802608,"owners_count":21806537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["framework","runpath","searchpath","swift","target","test","xcode"],"created_at":"2024-10-24T11:50:14.241Z","updated_at":"2025-05-07T02:43:31.918Z","avatar_url":"https://github.com/onmyway133.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TestTarget\n\n❤️ Support my app ❤️ \n\n- [Push Hero - pure Swift native macOS application to test push notifications](https://www.producthunt.com/posts/push-hero-2)\n- [PastePal - Pasteboard, note and shortcut manager](https://www.producthunt.com/posts/pastepal)\n- [Frame recorder - Recorder gif and video with frame](https://www.producthunt.com/posts/frame-recorder)\n- [Other apps](https://onmyway133.github.io/projects/)\n\n❤️❤️😇😍🤘❤️❤️\n\nNotes on configuring test targets\n\n#### This applies to\n\n- Main targets\n  - App\n  - Framework\n- Test targets\n  - Unit tests\n  - UI tests\n\n#### Examples\n\nDependencies used\n\n- Main target: [Sugar](http://github.com/hyperoslo/Sugar)\n- Test target: [Nimble](https://github.com/Quick/Nimble), [Quick](https://github.com/Quick/Quick)\n\nExamples\n\n- Cocoapods\n- Carthage\n\n#### Notes\n\n- 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 !\n- Remember to \"Clean Build Folder\" and \"Clear Derived Data\" so that you're sure it works. Sometimes Xcode caches.\n\n### Errors\n\nErrors occur mostly due to linker error\n\n- Test target X encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted\n- Framework not found\n\n## Cocoapods\n\n#### 1. Pod\n\nTest targets need to include pods that Main target uses !\n\nor we'll get \"Framework not found\"\n\n```ruby\ndef app_pods\n\tpod 'Sugar', '~\u003e 1.0'\nend\n\ndef test_pods\n\tpod 'Nimble', '~\u003e 3.2'\n\tpod 'Quick', '~\u003e 0.9'\nend\n\ntarget 'TeaApp' do\n\tapp_pods\nend\n\ntarget 'TeaAppTests' do\n\tapp_pods\n\ttest_pods\nend\n\ntarget 'TeaAppUITests' do\n\tapp_pods\n\ttest_pods\nend\n\n```\n\n#### 2. Link Binaries with Library\n\nCocoapods builds a framework that contains all the frameworks the Test targets need, and configure it for us\n\n![](Screenshots/cocoapods_link_binaries.png)\n\n#### 3. Runpath Search Paths\n\n- Go to Test target Build Settings\n- Add `$(FRAMEWORK_SEARCH_PATHS)`\n\n![](Screenshots/cocoapods_runpath_search_paths.png)\n\n## Carthage\n\n#### 1. Cartfile\n\nWe usually have\n\n- Cartfile for Main target\n\n```swift\ngithub \"hyperoslo/Sugar\" ~\u003e 1.0\n```\n\n- Cartfile.private for Test target\n\n```swift\ngithub \"Quick/Nimble\"\ngithub \"Quick/Quick\"\n```\n\n#### 2. Link Binaries with Libraries\n\n- Go to Test target build phase\n- Drag built frameworks from `Carthage/Build`\n- In rare case, we need to drag frameworks that the Main target uses\n- In rare case, we need to drag the Main target framework\n\n![](Screenshots/carthage_link_binaries.png)\n\n#### 3. Framework Search Paths\n\nConfigure correct path\n\n- Go to Test target Built Settings\n- Configure Framework Search Paths\n\n![](Screenshots/carthage_framework_search_paths.png)\n\n#### 4. Runpath Search Paths\n\n- Go to Test target Build Settings\n- Add `$(FRAMEWORK_SEARCH_PATHS)`\n\n![](Screenshots/cocoapods_runpath_search_paths.png)\n\n#### 5. Copy Files (maybe)\n\nFrom [Adding frameworks to unit tests or a framework](https://github.com/Carthage/Carthage/blob/0.11/README.md#adding-frameworks-to-unit-tests-or-a-framework)\n\n\u003e 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.\n\n![](Screenshots/carthage_copy_files.png)\n\n## Runpath Search Paths and Install name\n\nQuestion\n\n- Why preconfigured run path \"@executable_path/Frameworks\" and \"@loader_path/Frameworks\" not work?\n- Why configuring runpath to \"$(FRAMEWORK_SEARCH_PATHS)\" works ?\n- Why framework has install name \"@rpath/Sugar.framework/Sugar\" ?\n\nReference\n\n- [Run-Path Dependent Libraries](https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html)\n- [Linking and Install Names](https://www.mikeash.com/pyblog/friday-qa-2009-11-06-linking-and-install-names.html)\n\n## Author\n\nKhoa Pham, onmyway133@gmail.com\n\n## License\n\n**TestTarget** is available under the MIT license. See the [LICENSE](https://github.com/onmyway133/TestTarget/blob/master/LICENSE.md) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonmyway133%2Ftesttarget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonmyway133%2Ftesttarget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonmyway133%2Ftesttarget/lists"}