ReactiveX / RxSwift

Reactive Programming in Swift
MIT License
24.38k stars 4.17k forks source link

Manual integration of XCFrameworks in Test Target #2292

Closed odanu closed 3 years ago

odanu commented 3 years ago

Short description of the issue:

I am having an issue with integrating manually the XCFrameworks in the Test Target.

Expected outcome:

Be capable to run tests using RxTests and RxBlocking.

What actually happens:

Getting errors:

Showing Recent Messages
Ld: warning: ignoring file Frameworks/RxBlocking.xcframework/ios-arm64_armv7/RxBlocking.framework/RxBlocking, missing required architecture x86_64 in file Frameworks/RxBlocking.xcframework/ios-arm64_armv7/RxBlocking.framework/RxBlocking (2 slices)ignoring file Frameworks/RxTest.xcframework/ios-arm64_armv7/RxTest.framework/RxTest, missing required architecture x86_64 in file Frameworks/RxTest.xcframework/ios-arm64_armv7/RxTest.framework/RxTest (2 slices)

RxSwift/RxCocoa/RxBlocking/RxTest version/commit

6.1.0

Platform/Environment

How easy is to reproduce? (chances of successful reproduce after running the self contained code)

Xcode version:

  12.4

Installation method:

I have multiple versions of Xcode installed: (so we can know if this is a potential cause of your issue)

Level of RxSwift knowledge: (this is so we can understand your level of knowledge and formulate the response in an appropriate manner)

odanu commented 3 years ago

Here are some screenshots from the Main and Test target configuration.

errors warning

Main Target

Screenshot 2021-02-12 at 17 59 01

Test Target

Screenshot 2021-02-12 at 17 59 15
odanu commented 3 years ago

Played with the configurations today and nothing helped. I updated the screenshots with the last state of the dependency integration picture... still having the same issue. Worth to mention that we are using Standard Architecture, no Valid Architecture setting is there Excluded Arcchitecture is also empty. Building Active Architecture Only for the Test target.

odanu commented 3 years ago

Attaching a small reproducible project. Root/Frameworks folder contains placeholders for the frameworks.

rxbug.zip

odanu commented 3 years ago

I managed to find a workaround.

Since xcode tools have difficulties selecting the right architecture slice, I just manually removed the ios-arm64_armv7 slice from XCFrameworks.

I though it is safe to do it, since I only deleted the slices from RxBlocking and RxTest - frameworks which are only used for unit testing in our project and we run the tests only on simulator.

freak4pc commented 3 years ago

That seems like a reasonable solution but I'm confused with why Xcode itself didn't get rid of the slices it didn't need. This is literally what the XCFramework format is meant for 🤔

odanu commented 3 years ago

Obviously, it's either an XCode bug or we are missing something.

freak4pc commented 3 years ago

I built it on an M1 Mac, which I wonder if related. If you're curious and want to try, install this: https://github.com/unsignedapps/swift-create-xcframework

(using mint install unsignedapps/swift-create-xcframework)

And run:

 swift create-framework --output xcframeworks RxTest RxBlocking

I'm wondering if building locally will matter at all.

odanu commented 3 years ago

If you're curious and want to try, install this:

I am curious and would be happy to help, but I don't have mint installed and it looks like it's not a simple step, which I would like to avoid. Installed the tool manually as described in the specific section using make install... but than, I had issues executing the command.

freak4pc commented 3 years ago

It seems it's just:

brew install mint

Unless you don't have Homebrew installed at all :)

odanu commented 3 years ago

Hmm I tried the other one before...

brew tap mint-lang/mint-lang
brew install mint-lang

But it didn’t work. Will try your suggestion tomorrow ;)

freak4pc commented 3 years ago

Yeah I got confused as well, that's a programming language called mint as opposed to the package manager called Mint 🤦

Thanks!

odanu commented 3 years ago

I managed to generate the xcframeworks, but using swift create-xcframework..., I guess it was a typo on your side. But in the end, the result was the same. Same slices were included in the package and XCode couldn't pick the right one.

freak4pc commented 3 years ago

I'm not seeing anything that we can do here since it seems like an issue with the compiler/linker choosing the wrong slices, which isn't something we can affect. My instinct would be to file a bug on https://bugs.swift.org . I'd do so myself but I can't easily reproduce with your sample project (getting plist-related compilation errors).

agruchala commented 3 years ago

You can go back to fat frameworks done by lipo and: You can try to set Validate Workspace on build settings to Yes (NOT Yes(Error)) try again. It will change errors to warnings for multiple archs.

sushant-here commented 3 years ago

I got similar issues that im thinking of filing a separate bug on.

When i build Rx Swift with carthage 0.37 i get xcode 12.4 complaining about missing architectures for simulator (intel). When i use the precompiled framework thats included with rxswift 6.1.0, xcode complains about linker issues even thrugh my search path is setup.

Will link the bug that i am going to create once i well and truly give up.

freak4pc commented 3 years ago

Sorry, but have to close this mainly due to the fact we can't possibly fix Apple's tooling. If there's an advancement in this issue from Apple's side that requires us doing something, I'm happy to reopen.

Thanks!

Svetoslav commented 3 years ago

This indeed seems to be an Apple tooling issue. However, in case someone ends up on this issue report in the search of a workaround: a tad simpler to manage workaround alternative to @odanu's workaround to remove the non -simulator subfolder in the respective .xcframework folders, is to change in the build settings of your test target FRAMEWORK_SEARCH_PATHS, so that you have the full path to the -simulator folder, e.g. $(PROJECT_DIR)/Carthage/Build/RxTest.xcframework/ios-arm64_i386_x86_64-simulator, precede the inherited general project search paths:

It achieve effectively the same result—cluing in Xcode where to find the simulator slices, but without the need for manual changes of the Carthage/Build contents.