Integrating an XCFramework into a test target does not work as described
- carthage install method: [ ] .pkg, [ ] homebrew, [X] source (via Mint)
which carthage:/usr/local/bin/carthagecarthage version: 0.37.0xcodebuild -version: Xcode 12.4, Build version 12D4e- Are you using
--no-build? No - Are you using
--no-use-binaries? Yes - Are you using
--use-submodules? No - Are you using
--cache-builds? Yes - Are you using
--new-resolver? No
Cartfile Empty
Cartfile.private
github "Quick/Nimble" == 9.0.0
Carthage Output
*** Checking out Nimble at "v9.0.0"
*** No cache found for Nimble, building with all downstream dependencies
*** xcodebuild output can be found in /var/folders/_h/h5z8gsz12pb00k6w4h57s34h0000gp/T/carthage-xcodebuild.GO566x.log
*** Building scheme "Nimble-iOS" in Nimble.xcodeproj
Issue
I want to integrate an XCFramework only into a test target- i.e., it should not be bundled with the main app to ensure that it does not ship to the App Store. This is possible with regular .frameworks but I am not able to achieve this with .xcframeworks by following the Carthage docs.
Repro with clean project:
- Create a new iOS project with “Include Tests” checked
- Add
Cartfile.privatewithgithub "Quick/Nimble" == 9.0.0 - Run
carthage bootstrap --platform iOS --use-xcframeworks --use-ssh --no-use-binaries --cache-builds - Follow the Carthage docs (migration guide / main section) to integrate it:
- Drag and drop
Nimble.xcframeworkinto the unit test target’s “Link Binary with Libraries” build phase - Verify “Runpath Search Paths” of the test target contains
@loader_path/Frameworks(it should by default)
- Drag and drop
- Add
import Nimbleto the unit test file - Run unit test
- ❌ Xcode shows
No such module 'Nimble'error on the line with the `import Nimble statement
I tried many things but could not get this to work.
- The most promising was setting
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Carthage/Build/**";. then I’ll get the following error:Could not find module 'Nimble' for target 'x86_64-apple-ios-simulator'; found: arm64, armv7-apple-ios, arm64-apple-ios, arm, armv7.Nimble.xcframeworkcontainsios-arm64_armv7andios-arm64_i386_x86_64-simulator- FWIW, if I integrate an XCFramework with the same slices in the main app target, then everything works fine.
- Copying the frameworks through a build phase did not change anything
While this might be an XCFramework and not a Carthage issue, it seems to me like the Carthage docs are not addressing this use case sufficiently.
Expected outcome Carthage should build and run the tests
@TheDom I am experiencing the same issue, also with Nimble. I found out that if you run your tests target under this setup on a iOS 13.7 simulator, it just works.
It is not ideal, but it can be a good lead to the maintainers, and also save you some struggle while people try to figure it out.
@TheDom did you find some workaround for this in the meantime? @ericklborges it doesn't work on 13.7 for me.
@vburojevic No, we stuck with regular .frameworks for now. If there is no proper solution, then I have the following workaround in mind: Add the XCFrameworks to the main target for development but remove them through a script (e.g. with fastlane) before the App Store submission build.
I have the same problem as described here! Workaround for similar issue described here https://github.com/ReactiveX/RxSwift/issues/2292#issuecomment-804045119 worked for me
Closing, I can't repro this with Xcode 12.5.1 (and Carthage 0.38.0 and Nimble 9.2.0) anymore. 🎉