Framework Not supported in Simulator - Make Dummy Framework - ios

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

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.

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.

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,
Download that framework's code in your system.
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,
Open your downloaded project of framework.
Select any simulator target and build project.
Get generated .framework file from Products folder.
Add this framework in your project like this.
Now build your project for simulator.
Follow above steps for devices target if you want to build for devices.
I hope this will work for you.

Related

(Class) is unavailable: cannot find swift declaration for this class ONLY for iPhone <= 5 simulator, Generic iOS Device and Release Build

I understand that many similiar questions have been asked in the past - however, none of them exactly applies to my situation.
I am using the AudioKit framework in my app. I added the framework by copying the framework into the app directory and adding it to embedded binaries. It runs perfectly on the iOS simulators after the iPhone 5 simulator (i.e. 5S plus). However, when building for: earlier simulators; Generic iOS Device; and my device (which is an iPhone SE) I get the error (Class) is unavailable: cannot find swift declaration for this class where (Class) is every single AudioKit class in my code.
As per this answer I've checked the framework's Modules folder and the only files there are x86_64.swiftdoc and x86_64.swiftmodule. As I understand, to build for a real iOS device I need an arm64.swiftmodule. However, I cannot figure out how to create this file/where to find it.
The linked question would suggest that I need to change the framework's deployment target, but I can't figure out how to change it (or even where the framework's deployment target is stated).
I have tried creating a new xCode project, building it from the start for Generic iOS device, then adding the AudioKit framework - but I still get the same errors.
Finally decided to give up trying to make it work. Used Carthage instead - works perfectly. If anyone else has this issue - just use Carthage.

iOS or macOS project: duplicate interface definition for ViewController

I am trying to build a common Xcode project for macOS and iOS. My project directory structure is
MyApp
Common
AAPLAppDelegate.h
AAPLAppDelegate.mm
AAPLRenderer.h
AAPLRenderer.mm
MyApp_iOS
AAPLViewController.h
AAPLViewController.mm
main.m
MyApp_macOS
AAPLViewController.h
AAPLViewController.mm
main.m
build gives Duplicate interface definition for class 'AAPLViewController'.
I have added AAPLViewController.h in Build Phases -> Headers of corresponding macOS and iOS schemes.
I have also assigned corresponding macOS and iOS target membership to all files in MyApp_iOS and MyApp_macOS folders.
I tried comparing my project to an working macOS and iOS project but couldn't find a clue to avoid the error.
here is the git repo of it; macOS code isn't complete yet but iOS target should be built without above error.
You need to correctly setup your headers search paths. First, set ALWAYS_SEARCH_USER_PATHS to YES. If that will not work - add only needed headers to USER_HEADER_SEARCH_PATHS setting.

Error - "Class is unavailable : Cannot find Swift declaration for this class", while building app on iPhone 4s (iOS 9.3)

My App has been created under iOS 10.2, and when I'm trying to create a build of the app to run on iPhone 4s (iOS 9.3).
I'm using two frameworks :-
ViewModelExtensions.framework (github.com/jozsef-vesza/ExpandingTableView/tree/master/ExpandingTest/Carthage/Checkouts/ViewModelExtensions/ViewModelExtensions)
ExpandingTableView.framework (github.com/jozsef-vesza/ExpandingTableView) in my project.
I'm not able to create a built for my project. Its giving me 3 main errors as follows :-
ExpandingTableViewController is unavailable: cannot find Swift declaration for this class
ExpandingTableViewCell is unavailable: an not find Swift declaration for this class
Use of undeclared type ViewModelType
The thing is its perfectly running on all simulators supporting iOS 10.2. What shall I do ?
Here is the screenshot.Screenshot
My Code - Project
Reason your code not running is because one of the framework you have added Expandable tableView has minimum target requirement specified as 10.2 :) So you can not run it on anything less than iOS 10.2 :)
Now you can't change the frameworks minimum target, so change your projects development target :)
Solutions :
Change Development target to 10.2 in your project
Or get rid of the framework and find something that has minimum target as iOS 9 :)
We'll need more detail (code, did you use pods, etc.)
However, this looks like a problem with the referenced frameworks (I assume you've imported UIKit at least). I suspect (without seeing your code) that you're getting errors next to the frameworks above at build time. If so, there are a few things to check:
Make sure if you used cocoapods, you are using the 'workspace' and not the 'project' file.
Check and see if your "target membership" (you can see this in the inspector to the right of your class code) is set to the proper targets (i.e. your app - and probably nothing else at this point)?
If these checks fail, try re-installing the frameworks (again, depends if you used cocoapods or embedded them via Xcode (point 1 above)).

Cocoa Touch framework shared between iOS and tvOS

I'm working on an app that can have some shared code that I want to encapsulate in a framework. I created iOS Putter app target, then a framework PutterKit that I link from the app. This works fine.
Then I create a tvOS app target PutterTV and duplicate the PutterKit to PutterKit (TV) and set its sdk to tvOS
When I import PutterKit in the tvOS app and compile it, I get the error
No such module 'PutterKit'
Here is a sample project
https://dl.dropboxusercontent.com/u/1326174/Putter.zip
What is the correct way to setup such a framework?
Looking at your project, you need to:
import PutterTVKit
If you look at your PutterKit(TV) target build settings, you will notice that the ProductName and ProductModuleName are PutterTVKit.
Also make sure that in the Linked Frameworks and Libraries section in PutterTV app target, you link in PutterTVKit.framework (not PutterKit.framework).
With these changes, it appears to compile fine.

Adding Framework and App Extension targets to IOS App project, am I doing it correctly?

I'm studying IOS/Swift development and I'd like to build an IOS app that in the future will have its own Today Extension. I've read that it is better to put the common logic (for example the logic that accesses Internet resources, performs some job on the result etc) between the App and its extension into a Custom Framework.. Since I think I'll need to change both Framework and App code during the development of the App, I'd like to avoid building the framework in a separate project, than use Show In Finder function to locate the framework bundle and then drag-and-dropping it within the App project.. So I'd like to know if this is the correct way to set up a Workspace with an App, the framework it uses and the Today Extension of the App:
Create a new Project with an IOS App target
Select the project in the Project Navigator and then Editor->Add Target... and specify a Cocoa Touch Framework
Editor->Add Target... and specify Today Extension
Add the framework in Linked Frameworks and Libraries
In this way I've seen that changes to the Framework sources do not need a Framework target recompilation, maybe because the project knows about the need to recompile framework sources even if I only build & run the IOS App target that uses that framework? Am I doing it right? I've seen that the Today Extension created in such way does not lists the framework in the Build Phases -> Target Dependencies while the IOS App does, but both of them correctly use the updated code of the Framework when I update it.
Then, I've noticed the following warning when I compile the project, but I don't know if it is related to the way I've setup the project:
ld: warning: linking against dylib not safe for use in application extensions: /Users/gianni/Library/Developer/Xcode/DerivedData/TestFrameworkApp-dshihhfiuepeqzddbnpgnfwilhem/Build/Products/Debug-iphonesimulator/TestFramework.framework/TestFramework
BTW is it normal that the entries within the Products folder are always red? Is it due to the fact that I build only for IOS Simulator since I don't have a Paid developer account that allows me to build for an IOS Device? Does this prevent me to build a framework that can be exported for some other Project since I can't find the Framework bundle with a right clicking on the framework product and selecting Show In Finder (and so I can't drag-and-drop it to another project)?
I hope I've been clear enough and that you'll point me in the right direction to understand what is the suggested way of starting my new project :)
It sounds to me like you're headed down the exact path I would take.
Regarding the warning you're seeing... I believe that checking the "Allow app extension API only" for your shared framework will supress that and cause build failures when you attempt to use a API that is not allowed in extensions.

Resources