Carthage icon indicating copy to clipboard operation
Carthage copied to clipboard

Integrating an XCFramework into a test target does not work as described

Open TheDom opened this issue 5 years ago • 5 comments

  • carthage install method: [ ] .pkg, [ ] homebrew, [X] source (via Mint)
  • which carthage: /usr/local/bin/carthage
  • carthage version: 0.37.0
  • xcodebuild -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:

  1. Create a new iOS project with “Include Tests” checked
  2. Add Cartfile.private with github "Quick/Nimble" == 9.0.0
  3. Run carthage bootstrap --platform iOS --use-xcframeworks --use-ssh --no-use-binaries --cache-builds
  4. Follow the Carthage docs (migration guide / main section) to integrate it:
    • Drag and drop Nimble.xcframework into 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)
  5. Add import Nimble to the unit test file
  6. Run unit test
  7. ❌ 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.xcframework contains ios-arm64_armv7 and ios-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 avatar Mar 31 '21 18:03 TheDom

@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.

ericklborges avatar Apr 19 '21 17:04 ericklborges

@TheDom did you find some workaround for this in the meantime? @ericklborges it doesn't work on 13.7 for me.

vburojevic avatar Apr 21 '21 19:04 vburojevic

@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.

TheDom avatar Apr 21 '21 20:04 TheDom

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

yurapriv avatar Apr 29 '21 15:04 yurapriv

Closing, I can't repro this with Xcode 12.5.1 (and Carthage 0.38.0 and Nimble 9.2.0) anymore. 🎉

TheDom avatar Jul 31 '21 00:07 TheDom