Saranjith
Saranjith

Reputation: 11587

Framework Not supported in Simulator - Make Dummy Framework

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

Upvotes: 1

Views: 1147

Answers (3)

Komal Goyani
Komal Goyani

Reputation: 847

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.

Upvotes: 0

Lei Zhang
Lei Zhang

Reputation: 634

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.

Upvotes: 1

Miguel Isla
Miguel Isla

Reputation: 1460

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.

Upvotes: 2

Related Questions