Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find module 'Resolver' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator #136

Closed
brentjensen opened this issue Nov 4, 2021 · 7 comments

Comments

@brentjensen
Copy link

When you try to build for x86_64 simulator, Resolver can't be found, because it does not appear to be built for this architecture. Is there a way to add this to the supported architectures?

To reproduce:

  1. Add Resolver swift package to your project and import it into a file.
  2. Add "arm64" in the "Excluded Architectures" build setting for your project. (this is needed when 3rd party libraries have not yet been built for Apple Silicon)
  3. Attempt to build your application.
@brentjensen
Copy link
Author

Forgot to mention. I'm configured to use Resolver 1.4.1 in Swift Package Manager.

@hmlongco
Copy link
Owner

Looking into this as just got an M1 machine.

@eungkyu
Copy link

eungkyu commented Dec 19, 2021

I also experienced this issue on M1 mac, it turned out that Resolver is not the cause of the problem after all. I had one binary-only pod which is not compatible with arm64 simulator, and it was the problem. Excluding this pod solved the problem. In the end, I added build configuration only for simulator without that binary-only pod.

@horovodovodo4ka
Copy link

same here but via cocoapods

@brentjensen
Copy link
Author

brentjensen commented Jan 4, 2022

I managed to create a universal xcframework to fix this. The steps will hopefully help you resolve it in a way that doesn't force so many compromises, or others having this issue can follow these steps for a temporary workaround. Most of these steps were required because of the restrictions of XCFramework, so if you can, it would be much better to figure out how to get lipo to combine two arm64 frameworks (Apple Silicon Simulator and iOS builds will both contain this architecture).

There are a lot of steps here, but they should take only about 10 mins or less to complete.

  1. Download the code base on master branch (commit bd565aa)
  2. On the "Resolver" target, update the build setting BUILD_LIBRARY_FOR_DISTRIBUTION = YES (this generates to swift interface files required for xcframework)
  3. Update the Target name, and the build setting TARGET_NAME to Resolve (instead of "Resolver"). The definition of an xcframework confuses the compiler when a class is named the same thing as its module. The product module name is configured to rely on this user defined build setting TARGET_NAME.
  4. I updated the Product Bundle Identifier to "Resolve" as well, just for parity (probably no real reason to do this).
  5. In Resolver.swift, import Combine right above the definition for the struct InjectedObject, but inside the #if directive. (Otherwise, the xcframework swift definition file gets really confused about using Combine.ObservableObject because it chooses to fully qualify this symbol, instead of using the alias found in Foundation)
  6. Switch the "Run" "Build Configuration" to "Release" in the scheme editor (cmd-shift-comma).
  7. Build the product for both a simulator and for "Any iOS Device".
  8. In the Project Navigator, open the Products folder, right-click on the Resolve framework, and select Show in Finder. This will allow you to copy the two Resolve.framework folder paths for the next step.
  9. Run this command in the Terminal (after you replace the 3 locations with your own applicable values):
    xcodebuild -create-xcframework \ -framework "<YOUR_BUILD_PATH>/Release-iphonesimulator/Resolve.framework" \ -framework "<YOUR_BUILD_PATH>/Release-iphoneos/Resolve.framework" \ -output "<YOUR_BUILD_PATH>/Universal/Resolve.xcframework"
  10. Copy this Resolve.xcframework to the location where you'll want it for your project, remove your existing Resolver, and then drag this xcframework into your Project Navigator (you don't need Copy items, but make sure each target you want to use Resolver in is checked in the modal dialog that appears).
  11. FINALLY, in each Target you added Resolver to, go to the "General" tab, scroll down to "Frameworks, Libraries, and Embedded Content" and choose "Embed & Sign" for the "Resolve.xcframework".

@brentjensen
Copy link
Author

Oh, and of course this module name change means you'll need to import Resolve everywhere you had import Resolver

@hugovanderlei
Copy link

Any news about this issue?

@hmlongco hmlongco closed this as completed Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants