What is Foobar-umbrella.h for? - ios

Assuming I got a Framework called Foobar. When I try compiling my iOS project I get the compiler warning:
Umbrella header for module 'Foobar' does not include header
'Foobar-umbrella.h'
I don't get what this 'Foobar-umbrella.h' is and why it isn't included. Some details about my project:
An iOS 8 App project mostly written in Swift. A little bit Objective-C
The 'Foobar' framework is a separate project mostly written in Swift which I have included as a subproject to my main project.
It has been included by embedding it in build phases and depending on it. But I am not explicitly linking against it.
I use Cocoapods, but 'Foobar' is not included as a pod.

The umbrella header is the 'master' header file for a framework. Its use is that you can write
#import <UIKit/UIKit.h>
instead of
#import <UIKit/UIViewController.h>
#import <UIKit/UILabel.h>
#import <UIKit/UIButton.h>
#import <UIKit/UIDatePicker.h>
and so on.
For me, <XCTest/XCTestCase+AsynchronousTesting.h> is included in <XCTest/XCTest.h>. Maybe it is not for you? In that case, add the
#import <XCTest/XCTestCase+AsynchronousTesting.h>
manually.

Related

How to import framework into XCode project?

I get No such module 'BRLMPrinterKit' error.
I take a reference from official document https://support.brother.com/g/s/es/htmldoc/mobilesdk/guide/getting-started/getting-started-ios.html to import framework.
Here is my step:
drag BRLMPrinterKit.framework and BRLMPrinterKitW.framework into my framework folder
Check they are in Link Binary With Libraries (remove and drag again)
Check Framework Search Paths (I'm not sure it correct or not)
Check Header Search Paths (I'm not sure it correct or not)
Finally I clean and build get No such module 'BRLMPrinterKit' error.
I have no idea how to fix my import problem, any help would be appreciated. Thanks.
That's not a Swift module, so first, you need to create a bridging header, in which you import <BRLMPrinterKit/BRLMPrinterKit.h>, then you can use the BRLM classes in your Swift files.
Try using CocoaPods to install the framework, it's more convenient and faster.
Your framework supports installation using cocoapods
https://cocoapods.org/
https://github.com/jonathantribouharet/BRLMPrinterKit
using CocoaPods to install the 'BRLMPrinterKit' framework.
add the bridge file.(Targets > Build Settings > Swift Compiler - General > Objective-C Bridgeing Header)
the bridge file.h
#ifndef PtouchPrinterKit_Bridging_Header_h
#define PtouchPrinterKit_Bridging_Header_h
#import <BRLMPrinterKit/BRPtouchBluetoothManager.h>
#import <BRLMPrinterKit/BRPtouchDeviceInfo.h>
#import <BRLMPrinterKit/BRPtouchNetworkManager.h>
#import <BRLMPrinterKit/BRPtouchPrinter.h>
#import <BRLMPrinterKit/BRPtouchPrinterData.h>
#import <BRLMPrinterKit/BRPtouchPrinterKit.h>
#import <BRLMPrinterKit/BRPtouchPrintInfo.h>
#endif
then you can use the framework

Xcode generated umbrella header for framework does not import Foundation when #objc inference is turned off

I have a framework written entirely in Swift, and it's included in an app that uses a mix of Objective-C and Swift, i.e.
#import "MyFramework-Swift.h"
If Swift 3 #objc inference is turned ON for the framework target then everything compiles and runs fine. If Swift 3 #objc inference is turned OFF then the framework itself will compile, but the file that it's included in does not and spits out a bunch of errors like:
Unknown type name 'NSArray' or Unknown type name 'NSError'
The imports in the Objective-C file where I'm trying to use this framework essentially look like this (i.e. Foundation is being imported before trying to import the swift framework):
#import Foundation;
#import <OtherNonSystemHeaders.h>
#import "ThisFilesHeader.h"
#import "MyFramework-Swift.h"
If I open up the header file that Xcode generates there's a section about 150 lines down that looks like this:
#if __has_feature(modules)
#import ObjectiveC;
#endif
And if I manually change it to this it will compile and run.
#if __has_feature(modules)
#import ObjectiveC;
#import Foundation;
#endif
Obviously that's not a real solution since it gets overwritten any time Xcode regenerates that header, but I can't understand why turning off #objc inference is causing that import to disappear. I have manually marked certain methods as #objc, all the classes in the framework subclass NSObject, and each file imports Foundation.
I thought this might be a bug, but this happens both with Xcode 9.2 and 9.3, and clearly people are able to turn off #objc inference since it's now a recommended setting. But I am truly at a loss.
This sounds like you're missing #import Foundation; in your ObjC prior to:
#import "MyFramework-Swift.h"
ObjC files should #import Foundation; themselves. This is often also placed in the precompiled header (.pch) for performance reasons, but each .m should still import everything it needs, including Foundation.
Typically I recommend the following layout for .m files:
#import ...System Headers...
#import "Non-system framework headers"
#import "Local headers"
#import "Project-Swift.h"
We recently had to workaround what sounds like the same problem, although for us #objc inference didn't make a difference. Here is what we did:
In the MyFramework project, add a top-level header file MyFramework.h with just this one-liner:
#import Foundation;
Make sure that this file is added to each of the targets in your framework project as a Public header (not Private or Project... this part is important).
Rebuild the framework. The generated MyFramework-Swift.h still won't #import Foundation but you will see the new MyFramework.h file right beside it in the built framework's Headers folder.
Import your framework into your app's Objective-C files using the same #import <MyFramework/MyFramework-Swift.h> syntax you're probably already using. You should no longer receive the Unknown type name errors.

iOS - "'Foundation/Foundation.h' file not found" Error Inside Custom Framework Inside Swift Project

I have compiled a custom Objective-C Framework which I will be referring to as Custom.framework. I'm having an issue with the files inside the framework when I try to build the project the framework is linked in.
Inside Custom.framework I have my main Header file called Custom.h and the following code is where the problem arises:
#import <Foundation/Foundation.h> // 'Foundation/Foundation.h' file not found
I have a recursive framework and library path set up to where my .framework file is located: /Users/macbook/Library/Developer/Xcode/**
My project and framework files are in /Users/macbook/Sites/
Also my framework appears in red text, but is recognized when I import it if that helps.
As Glenn Howes states in a comment under the question, I needed to change the import to #import Foundation instead of using #import and turn on Enable Modules (C and Objective-C) in my build properties (which I already had).
Have you added Foundation.framework in Scheme --> Build Phases --> Link Binary With Libraries?

xcode cannot compile NSString

xcode will not compile a FRESH project with only libxml2 and its requirements installed. it returns this error every time.
http://puu.sh/bYc7D/b37d7c6e99.png
I do not know how to resolve this, has anyone had this before?
Most of the standard project templates include a prefix header called project_name-Prefix.pch (and a reference to it in build settings, search for 'prefix').
Since most classes use the Foundation library, including Foundation.h in that header is a good idea. Also make sure that Foundation.framework is included under "Build Phases" -> "Link Binary With Libraries".
If your project isn't setup that way, it might be useful to create a new project using the most basic template (like Single View), observe how its setup and do the same things to your project.
Looks like Foundation isn't imported. Do you have anything in your prefix header file?
Regardless, try importing it into your header:
#import <Foundation/Foundation.h>
Or alternatively if you use modules:
#import Foundation;
Import Fondation? I don't see it at the top of the file.

Importing Core Data to existing project fails

I have a workspace and I'm trying to add Core Data to it. I went to the project I want to add Core Data to, selected the Target, hit the + sign under Link Wit Binary Files and added the Core Data framework. That part works fine. I can build and run. When I try the next and using this line:
#import <CoreData/CoreData.h>
I get build errors. These build errors look like:
"ARC Semantic Issue"
Pointer to non-const type 'id' with no explicit ownership
These errors are present in
NSEntityDescription.h
NSManagedObjectModel.h
NSMnagedObject.h
NSManagedObjectContext.h
NSPersistentStore.h
Does anyone know why I'm not able to import Core Data to an existing iOS project? Thanks in advance!
In my framework search paths, I had an erroneous path that correctly built once I removed it:
$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
It should be as simple as adding CoreData.framework to your target:
Click the plus button (+) under Linked Frameworks and Libraries
Then in your Prefix file (Tabs-Prefix.pch in this case) in the #ifdef __OBJC__ declaration:
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#impport <CoreData/CoreData.h> //Added core data here
#endif
If this does not work, perhaps you have an older version of Xcode installed and the paths are messed up. It could be trying to import an older framework.
I think this could be related to your entity definitions. Is it possible that you have declared entities that use the attribute name id? That would typically be a NSNumber type in the model subclasses, i.e. *id.
It seems that in this case, the compiler instead of complaining about the *id in the class files, it indicates the id in the header files, which is confusing.
--> Try changing your attribute names.
I had the same problem. It was solved by the following steps:
Remove Reference to CoreData.framework from Frameworks group in Xcode.
Remove CoreData.framework from 'Link Binary with Libraries' in target settings.
Quit Xcode (Cmd + Q).
Open your project folder in Finder and delete CoreData.framework file.
Start Xcode, open your project. Now you may to add the CoreData.framework in 'Link Binary with Libraries'.
Don't forget to add #import <CoreData/CoreData.h> into <projectName>-Prefix.pch located at Supported Files. My prefix header seems like this:
`
#import <Availability.h>
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#endif
`
I don't know how existance of any file in project directory can affect to compile errors, but it works for me.
Hope this helps for anyone who reads it.

Resources