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

Support for mac catalyst with apple silicon. #1948

Closed
kasimok opened this issue May 18, 2023 · 14 comments
Closed

Support for mac catalyst with apple silicon. #1948

kasimok opened this issue May 18, 2023 · 14 comments
Assignees
Labels
accepted Issue moved to product team backlog. Will be closed when addressed. bug Something isn't working

Comments

@kasimok
Copy link

kasimok commented May 18, 2023

Describe the bug
I see catalyst is somehow supported, but not fully supported.
Run the sample on Mac Catalyst on x86 macOS works but on apple silicon it shows error of No such module 'MicrosoftCognitiveServicesSpeech'

To Reproduce
Steps to reproduce the behavior:

  1. Add Mac Catalyst to the supported destinations for the speech-sample project
  2. Runs OK on x86_64 Macs but framework not found on arm Macs.

Expected behavior
fully support Mac Catalyst for both x86_64 and arm mac

Version of the Cognitive Services Speech SDK
1.28

Platform, Operating System, and Programming Language

  • OS: macOS 13.2
  • Hardware - Apple M1 Max
  • Programming language: Swift
  • Browser NA

Additional context
Why don't we support SPM directly?

@jhakulin
Copy link

@kasimok Thanks for the report. https://aka.ms/csspeech/iosbinary xcframework package do contains support for both x86_64 and arm64 (ios-arm64_x86_64-maccatalyst).

Anyways, I will try to reproduce your problem.

@kasimok
Copy link
Author

kasimok commented May 19, 2023

@kasimok Thanks for the report. https://aka.ms/csspeech/iosbinary xcframework package do contains support for both x86_64 and arm64 (ios-arm64_x86_64-maccatalyst).

Anyways, I will try to reproduce your problem.

Yes, I noticed the file's name contains both arm64 and x86_64, but somehow, it won't let me use that framework on arm64 Mac Catalyst.

@jhakulin
Copy link

So far just verified that package contains required bits, not clear why you could not use it, so will be checking a bit more.

To see what is bundled inside the binary you can check:

% file MicrosoftCognitiveServicesSpeech

MicrosoftCognitiveServicesSpeech: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64]

MicrosoftCognitiveServicesSpeech (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64

MicrosoftCognitiveServicesSpeech (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64

@kasimok
Copy link
Author

kasimok commented May 19, 2023

@jhakulin could you please verify with your sample project, try adding catalysts support, can you run the Mac catalyst?

I create this issue as my colleague who have a x86_64 runs OK.

image

@kasimok
Copy link
Author

kasimok commented May 22, 2023

@jhakulin Hi Jarno, did you tried it?

@pankopon pankopon added the in-review In review label May 23, 2023
@jhakulin
Copy link

jhakulin commented May 24, 2023

@kasimok I can repro the issue with the Swift sample you pointed out, thanks for the report. The issue might be related to pod installation. I will investigate that bit further. The reason I suspect something might be wrong with the pod installation is that I checked this sample https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/samples/objective-c/ios/speech-samples, it builds and that works ok for Mac Catalyst target on my Mac M1 (ARM based architecture).

Possible workaround now for Mac Catalyst target is to add xcframework manually to Swift project, instead of using pod install

@kasimok
Copy link
Author

kasimok commented May 24, 2023

@jhakulin I tried xcframework in the first place, the same behaviour. Our team does not use cocoapods, then we repacked it into spm(Swift Package Manager) since you provided the xcframework version. I order to use Azure Speech Service we have to install the cocoapods back to verify if it is a xcframework only issue. So in a word, cocoapods/xcframework/spm, they all behaves the same.

Below is the package file I use in swift package manager

// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

// swiftlint: disable prefixed_toplevel_constant
let package = Package(
  name: "MicrosoftCognitiveServicesSpeech",
  products: [
    // Products define the executables and libraries a package produces, and make them visible to other packages.
    .library(
      name: "MicrosoftCognitiveServicesSpeech",
      targets: ["MicrosoftCognitiveServicesSpeechTarget"])
  ],
  dependencies: [
    // Dependencies declare other packages that this package depends on.
    // .package(url: /* package url */, from: "1.0.0"),
  ],
  targets: [
    // Targets are the basic building blocks of a package. A target can define a module or a test suite.
    // Targets can depend on other targets in this package, and on products in packages this package depends on.
    .target(
      name: "MicrosoftCognitiveServicesSpeechTarget",
      dependencies: [
        .target(name: "MicrosoftCognitiveServicesSpeech")
      ],
      path: "MicrosoftCognitiveServicesSpeechTarget"),
    .binaryTarget(
      name: "MicrosoftCognitiveServicesSpeech",
      url: "https://csspeechstorage.blob.core.windows.net/drop/1.28.0/MicrosoftCognitiveServicesSpeech-XCFramework-1.28.0.zip",
      checksum: "4171300d3c0d198eb022ee95835560e800df47be591f5372c9a6ef0ebe53d2c5")
  ]
)
// swiftlint: enable prefixed_toplevel_constant

@jhakulin
Copy link

@kasimok Yeah, not clear what is the reason yet. Note that Objective-C project works with the Macatalyst and same xcframework. I will investigate why Swift project does not.

@kasimok
Copy link
Author

kasimok commented May 31, 2023

@kasimok Yeah, not clear what is the reason yet. Note that Objective-C project works with the Macatalyst and same xcframework. I will investigate why Swift project does not.

Oh, I just tried to create a bridging header and use it in swift project, now it works. So definitely there is a modulemap related bug here in the xcframework/cocoapods.

@jhakulin
Copy link

jhakulin commented Jun 1, 2023

@kasimok Thank you for sharing the workaround, indeed using bridging header provides alternative way to module import. I will look into module import issue.

Internal workitem ref: 5276384

@pankopon pankopon added bug Something isn't working accepted Issue moved to product team backlog. Will be closed when addressed. and removed in-review In review labels Jun 2, 2023
@jhakulin
Copy link

jhakulin commented Aug 8, 2023

Potentially related issue: leetal/ios-cmake#172

We will continue investigating this, however at the moment there seems to be an external issue between CMAKE and Xcode generation with iOS toolchain to support properly Maccatalyst builds with Xcode. After those are solved, I am hopeful there would be better resolution to Maccatalyst module import issue.

Using bridging header is recommended workaround at the moment.

@kasimok
Copy link
Author

kasimok commented Sep 24, 2023

@jhakulin I knew it now, your "CMAKE and Xcode generation with iOS toolchain" must missed the modulemap file for mac catalyst platform. That's why we cannot use the symbols in swift directly.

I tried, copy the modulemap, and the catalyst platform is OK.

Screenshot 2023-09-24 at 3 51 23 PM

@jhakulin
Copy link

jhakulin commented Oct 2, 2023

@kasimok Thank you for the information, I'll create a fix to next Speech SDK release. Thanks again!

@jhakulin
Copy link

jhakulin commented Oct 3, 2023

The fix will be in the 1.33.0 Speech SDK release, closing the issue.

@jhakulin jhakulin closed this as completed Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Issue moved to product team backlog. Will be closed when addressed. bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants