1

I have a framework which is not available in simulator, So not able to run in simulator. Im getting below error.

Could not find module 'Framework' for target 'x86_64-apple-ios-simulator'; found: arm64, armv7-apple-ios, arm64-apple-ios, arm, armv7

How can i create a dummy framework or is there any way to make it run on simulator. Just like simulator is handling camera like functionalities.

Tried below code: But how to define the else condition.

#if (arch(x86_64)) && os(iOS)
  import Framework
#else

#endif
Saranjith
  • 11,242
  • 5
  • 69
  • 122

3 Answers3

2

I work for a team that has developed a framework that does not work in simulator (uses camera) but includes the simulator architecture so a developer can use it regardless the device. We only have two entry points and in each of them we put the following code:

#if TARGET_IPHONE_SIMULATOR
    return nil;
#else
    // code goes here
#endif

I know that this is not ideal and we just return nil (simulator is the only possibility of returning nil), but at least you can call it and if nil do something else instead of crashing or just not compiling at all.

Miguel Isla
  • 1,379
  • 14
  • 25
  • I have no access to the developer who made the framework. I have to handle from appside – Saranjith Oct 28 '19 at 07:18
  • I think that [this](https://stackoverflow.com/questions/38481077/how-to-only-include-a-framework-when-building-for-device-not-ios-simulator) other question may help you. – Miguel Isla Oct 28 '19 at 07:56
1

You might create a second target without the framework. I do not know how many files use this framework?

If there are not many you can create a duplicated file only available to the second target. Of course, you have to remove any code referencing to this framework in the duplicated file.

This approach should work.

Lei Zhang
  • 634
  • 4
  • 6
0

Xcode has different build system for simulator and real devices. So it will generate different app for both. If you select any Simulator target then it will builds app for simulator and if you select Generic iOS Device or any real device target then it will builds different build.

You are using that framework which are builded for simulator target, So follow this steps,

  1. Download that framework's code in your system.
  2. Add project files of framework in your workspace. For that you can refer this and this.

If you don't want to add whole code of framework in your project then you can add particular( for device or simulator ) build of framework in your xcode project. For that follow this steps,

  1. Open your downloaded project of framework.
  2. Select any simulator target and build project.
  3. Get generated .framework file from Products folder.
  4. Add this framework in your project like this.
  5. Now build your project for simulator.
  6. Follow above steps for devices target if you want to build for devices.

I hope this will work for you.

Komal Goyani
  • 779
  • 6
  • 25