opentok / opentok-ios-sdk-samples-swift

Sample applications using the OpenTok iOS SDK in Swift
https://tokbox.com/
MIT License
137 stars 65 forks source link

Does not compile for arm64 simulator if the project also uses Swift Package Manager #195

Closed tikitu closed 1 year ago

tikitu commented 1 year ago

Describe the bug The setting "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; from the OpenTok pod is incompatible with SPM packages: if a project includes both the OpenTok pod and any SPM package at all, it will fail to build for arm64 simulators (including simulators for recent iOS versions on M1 Macs).

To Reproduce Steps to reproduce the behavior:

  1. Add any SPM package whatsoever to the sample.
  2. Import a type from that package
  3. Try to build for a recent iOS simulator, on an M1 Mac.

I made an example at https://github.com/tikitu/opentok-ios-sdk-samples-swift/tree/spm-and-m1 importing the SwiftArgumentParser package, just to show my working.

Expected behavior The project should compile. Instead it fails, with the error message Could not find module 'ArgumentParser' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator.

Device (please compete the following information):

Additional context This is more urgent now that Xcode 14.3 has shipped, as this Xcode version removes support for Rosetta emulation: developers on an M1 Mac must stay with Xcode 14.2 if their project includes both OpenTok and any SPM packages.

There's a related issue asking for SPM support (#130) -- while that would be great, the more significant point for our team is that we cannot use SPM for other packages if we're including the OpenTok pod.

emilyvon commented 1 year ago

I'm facing the same issue with the following setup:

Adding some screenshots for references:

In OpenTok pod setting: EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64 for both debug and release:

235587852-592ea372-4a07-4bb3-8002-4b0eb8143df4

And if I commented that line out in the generated pod setting file, I ran into another issue:

235588361-74bb64e1-cbed-4b83-a869-5439ef37acc0
vona-ben commented 1 year ago

Hello @emilyvon @tikitu , Since 2.24.2 release, we have M1 / arm chipset support. To build on arm chipset based machines, users have to use OTXCFramewok instead of Opentok pod (version >= 2.24.2) Example:

target 'Basic-Video-Chat' do
pod 'OTXCFramework', OpenTokSDKVersion
end

instead off

target 'Basic-Video-Chat' do
pod 'Opentok', OpenTokSDKVersion
end
vona-ben commented 1 year ago

Note: We are currently working on an iOS SDK Swift Package Manager, which will be available soon. I will keep you updated on the progress in this thread

jvalli commented 1 year ago

The issue is because you are trying to use old fat framework on M1 machine(arm64). The old fat framework version cannot have unique build configuration to work on both arm64 & x86_64 simulators, so we were agree that old fat framework version will be distributed with "EXCLUDED_ARCHS[sdk=iphonesimulator*]": "arm64" configuration to be able to use it on Simulator Intel machines(x86_64) by default. If the build configuration is removed it works on Simulator M1 but not on Simulator Intel.

So you can use new XCFramework version available through: