Xcode "Missing Submodule" warning - ios

I'm using Xcode6 GM to create a Coacoa Touch Framework (a new function in Xcode6), then this framework is included into my app.
Everything is fine (works fine), except that I get warnings in "#import". What is the root cause?

I ran into the same problem and eventually fixed it by adding my project headers into the umbrella header. When you create a new framework it should start with a single .h file titled by the project (in your case DirectProximityFramework.h).
Inside this file is a comment:
In this header, you should import all the public headers of your
framework using statements like #import <DirectProximityFramework/PublicHeader.h>
So just add your GeofencingHelper.h file in this file:
#import <DirectProximityFramework/GeofencingHelper.h>
This should remove all of your warnings!

Maybe, you can stop this warning by adding following line to "DirectProximityFramework.h"
#import <DirectProximityFramework/GeofencingHelper.h>
...etc
I suggest to check
[Target your framework] -> Build Phases -> Headers -> Public

In case if it is not your framework and there is nothing to do you can disable warning in such way
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincomplete-umbrella"
#import <DirectProximityFramework/GeofencingHelper.h>
#pragma clang diagnostic pop
Note - it is not a fix, it just hide the problem.

I ran into this issue and all the solutions above didn't fit me, since the file wasn't supposed to be in the umbrella header.
So if this is your own framework and that particular file shouldn't be in the umbrella header, make sure it isn't marked public in the target membership section.
That fixed it for me.

I had same issue and my solution was..
When you create the framework project.Your project automatically "yourProjectName.h" file gets created, In this header file import class class.
In my case I am getting missing submodule 'MSFramework.MSLocationManager' [-Wincomplete-umbrella]this warning.
resolved by Just importing
#import <UIKit/UIKit.h>
# import "MSLocationManager.h"
//! Project version number for MSFramework.
FOUNDATION_EXPORT double MSFrameworkVersionNumber;
//! Project version string for MSFramework.
FOUNDATION_EXPORT const unsigned char MSFrameworkVersionString[];
here I just add the # import "MSLocationManager.h"in header file.

// In this header, you should import all the public headers of your framework using statements like
#import <GameworkSDK/GWObject.h>
like this:
#import <UIKit/UIKit.h>
#import <GameworkSDK/GWObject.h>
//! Project version number for GameworkSDK.
FOUNDATION_EXPORT double GameworkSDKVersionNumber;
//! Project version string for GameworkSDK.
FOUNDATION_EXPORT const unsigned char GameworkSDKVersionString[];

i had this problem cocoa pods
my solution was real simple but took forever for me to figure out.
when i ran $ pod install it generated a workspace for me in the same dir as my .xcodeproj file.
however i had already created a workspace to use as its parent directory.
so then i simply deleted my old workspace and went with the one that pods created
glhf!

Set header search path in your project setting:
TARGETS / Build Settings / Header Search Paths
"$PODS_CONFIGURATION_BUILD_DIR/[YOUR PROJ NAME]/[YOUR PROJ NAME].framework/Headers"
Now import the header file.
#import <DirectProximityFramework.h>

Related

Could not build Objective-C module 'mupdfdk'

I'm trying to add mupdf framework to a swift project. I created a new project and copied the mupdfdk.framework to my project and referenced it in the frameworks section. Following is a screenshot of the documentation.
Now my project looks like this.
Then when I try to import it in viewcontroller, I get Could not build Objective-C module 'mupdfdk' error. Are there any other steps I'm missing? Please help.
You need to add this bridging header:
MuPDF-Bridging-Header.h
#ifndef MuPDF_Bridging_Header_h
#define MuPDF_Bridging_Header_h
#import "mupdfdk.framework/Headers/mupdfdk.h"
#endif /* MuPDF_Bridging_Header_h */
and declare it within the Swift Compiler section of the Build Settings:

'FMDB.h' file not found

have been trying to import a header file for database.
I'm getting two errors.
'FMDB.h' file not found
and
ailed to emit precompiled header '/Users/myname/Library/Developer/Xcode/DerivedData/zzzzzz- for bridging header '/Users/myname/Library/Autosave Information/zzzzzz/header.h'
The full path of FMDB.h is the below
/Users/myname/Library/Autosave Information/zzzzzz/fmdb/FMDB.h
In Objective-C Bridging Header : header.h
in the header file, the codes are :
#ifndef Header_h
#define Header_h
#import "FMDB.h"
#endif /* Header_h */
I set Allow Non-modular Includes in Framework Modules as Yes.
It didn't work out for me tho.
Follow a few steps:
Rename your header to --> YourProjectName-Bridging-Header.h
Check/Add Path of this header in your Build Setting --> Under Objective-CBridging Header (You may drag the file path)
Framework Modules as No
Then build, it should work. thanks!
I recently moved to new Mac book with Apple M1 Max chip and got the same error. I resolved it by removing arm64 from EXCLUDED_ARCHS in Build Settings.

Swift framework - Use Swift class reference in Objective-C class

I am creating Swift framework in which I have to use Objective-C class. So I went through this link. This is the public header of my framework :
#import <UIKit/UIKit.h>
//! Project version number for Test.
FOUNDATION_EXPORT double TestVersionNumber;
//! Project version string for Test.
FOUNDATION_EXPORT const unsigned char TestVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Test/PublicHeader.h>
#import <arpa/inet.h>
#import <ifaddrs.h>
#import <netdb.h>
#import <sys/socket.h>
#import <MyTest/MPAppDelegateProxy.h>
Now in class MPAppDelegateProxy, I have to use a Swift class which I have created. This is :
#import "MPAppDelegateProxy.h"
#import "MyTest.h"
#implementation MPAppDelegateProxy
+ (void)proxyAppDelegate {
[MPGlobal MPLog:#"App delegate not set, unable to perform automatic setup." file:#"MPAppDelegateProxy.m" function:#"proxyAppDelegate" line:32];
// rest of code
}
MPGlobal is one of my Swift class. But I am getting :
Use of undeclared identifier 'MPGlobal'
Note : I have added #objC before MPGlobal.
You need to import <Target>-Swift.h file.
This is known as Objective-C Generated Interface Header Name.
You can find it in your Target's build settings.
This file is auto generated by compiler and it needs to be imported in Objective-C files.
change the SWIFT_OBJC_INTERFACE_HEADER_NAME build setting and making it the same across different targets. To do so change the instruction that generates this property from $(SWIFT_MODULE_NAME)-Swift.h to $(PROJECT_NAME)-Swift.h as explained here
After doing this Clean Build Folder by pressing Alt and going into Product menu. Since name of header is shared among targets now it can be imported once in the .m ObjectiveC file and all targets can benefit from Swift classes.
If after building it still shows the error, ensure that the header can be reached from XCode by Cmd clicking on its name. It should open a file that contains code similar to this:
SWIFT_CLASS("_TtC27ProjectName_Summary11MyClass")
#interface MyClass : NSObject
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
#end
If need to ensure that those headers are being generated open a terminal and use this command
find ~/Library/Developer/Xcode/DerivedData -name "*Swift.h"
You should see one header for each target
Another issue that happened to me after those changes is that it started giving errors on ObjectiveC code that I didn't touch. The problem was due to the position of the import, as reported here:
Exactly where at the top of a .m file you #import the hidden bridging
header can make a difference. The usual sign of trouble is that you
get an “Unknown type name” compile error, where the unknown type is a
class declared in Objective-C. The solution is to #import the .h file
containing the declaration for the unknown type in your Objective-C
files as well, before you #import the hidden bridging header. Having
to do this can be an annoyance, especially if the Objective-C file in
question has no need to know about this class, but it resolves the
issue and allows compilation to proceed.
At the very end the code compiles and runs on device and simulator!
Original answer
Also you can try this,
You needed to import the -Swift.h for for both the framework and the app target
For Example :
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <Foundation/Foundation.h>
#import "XLPagerTabStrip-Swift.h"
#import "RealmSwift-Swift.h"
...... // Add all frameworks, subclasses, and dependance ios frameworks
#import "MyProject-Swift.h"
You can read this article How to import file header and check paths

How to fix the Xcode path error

In the AFNetworking's sample code, I use several folders to classify the source codes.
And the Xcode reports:
/Users/.../Framework/AFNetworking.h:19:9: 'AFNetworking/AFURLRequestSerialization.h' file not found
/Users/.../AFNetworking-master/Example/Classes/Networking Extensions/AFAppDotNetAPIClient.h:4:9: While building module 'AFNetworking' imported from /Users/dengjiangzhou/Documents/源码/2_AFNetworking/AFNetworking-master/Example/Classes/Networking Extensions/AFAppDotNetAPIClient.h:4:
/Users/.../AFNetworking-master/Example/:1:9: In file included from :1:
And
Here is the code:
In the AFNetworking.h file
#import <Foundation/Foundation.h>
//! Project version number for AFNetworking.
FOUNDATION_EXPORT double AFNetworkingVersionNumber;
//! Project version string for AFNetworking.
FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <AFNetworking/PublicHeader.h>
#import <Availability.h>
#import <TargetConditionals.h>
#ifndef _AFNETWORKING_
#define _AFNETWORKING_
#import <AFNetworking/AFURLRequestSerialization.h>
#import <AFNetworking/AFURLResponseSerialization.h>
#import <AFNetworking/AFSecurityPolicy.h>
#if !TARGET_OS_WATCH
#import <AFNetworking/AFNetworkReachabilityManager.h>
#endif
#import <AFNetworking/AFURLSessionManager.h>
#import <AFNetworking/AFHTTPSessionManager.h>
Error occurs in the last line.
And I didn't change any code. I just organized the files to check the functions of each module easily.
Maybe insert a file name in the search path of Xcode build settings, is quite OK.
I have not figured it out.
Many Thanks in advance.
You should remove AFNetworking/ from import line and use
#import ""
instead of
#import <>
Go to Build Phases -> Open Headers section -> Move files from Project to Public.
Try this:
Select AFURLRequestSerialization.m
Go to the right tab in the Xcode. Find Target Membership. Uncheck and check again all the boxes.
Product > Clean
Hold Alt and perform: Product > Clean Build Folder...
Build again.

Project-Swift.h file not found

I have a new Swift project with a few files, I've needed to add some Objc code.
In Build Settings, my Objective-C Generated Interface Header Name is MyProject-Swift.h
Product Module Name and Product Name are both MyProject.
My Objective-C Bridging Header is MyProject/MyProject-Bridging-Header.h
The contents of my Bridging Header are:
#ifndef MyProject_Bridging_Header_h
#define MyProject_Bridging_Header_h
#import "Blakey.h"
#endif
Blakey.h is pretty simple:
#import Foundation;
#import "MyProject-Swift.h"
#class KeyPair;
#interface Blakey: NSObject
- (void)createKeyPairForSeed:(NSString *)seed;
#end
And Blakey.m
#import <Foundation/Foundation.h>
#import "Blakey.h"
#implementation Blakey
- (void)createKeyPairForSeed:(NSString *)seed;
{
}
#end
(side note: I'm aware my function returns a void, that will be changed later once this issue is fixed so it returns an actual value)
Why is Xcode throwing an error at the #import "MyProject-Swift.h" in Blakey.h?
Project-Swift.h is a file auto generated by Xcode on successful compilation of the project. Catch here is the word successful compilation If your project has any compilation error Project-Swift.h file will not be generated. So in a way it becomes a deadlock. Bestway comment out all the lines that have compilation error and then manage to get it compile without any errors. Only after that Project-Swift.h will be generated.
Additional information, Once the Project-Swift.h file is generated if you open it and if you happened to see that your swift class is not imported there thats because Project-Swift.h imports only the classes that extends from NSObject So plain Swift classes will not be imported.
ISSUE:
You need to import Project-Swift.h in .m file and not .h file. So modify your Blakey as
#import <Foundation/Foundation.h>
#import "Blakey.h"
#import "MyProject-Swift.h"
#implementation Blakey
- (void)createKeyPairForSeed:(NSString *)seed;
{
}
Finally remove #import "MyProject-Swift.h" from Blakey.h
#import Foundation;
#class KeyPair;
#interface Blakey: NSObject
- (void)createKeyPairForSeed:(NSString *)seed;
#end
I had similar issue and almost ended up spending a whole day trying to figure out what wrong with my app.
So following the solution that's helped me :
Clear derived data
Create a class in swift with prefix of #objc for example #objc class mySwiftClass{...}
Build the project again
Et voila.. Should work now.
Why to add #objc?
this #objc prefix, tells the compiler to generate to your swift class a header file. it will add it to the "MyModule-Swift.h" file
I realize this is an old thread, but I had similar issues after adding a new target to a project. I solved it by adding a preprocessor macro (Build Settings -> Apple Clang - Preprocessing) only in said target and then importing the Swift.h file conditionally, like this:
#if DEV_VERSION
#import "Project_DEV-Swift.h"
#else
#import "Project-Swift.h"
#endif
My main target is called Project and the new target is Project DEV (the space is replaced with an underscore in the import), and the preprocessor macro is called DEV_VERSION.
After doing this, both targets build just fine.
<product_name>-Swift.h file not found
It is a kind of bridge(adapter) between Swift and Objective-C. This file contains Swift's API for Objective-C which was marked [#objc and #objcMembers].
You can work with types declared in Swift from within the Objective-C code in your project by importing an Xcode-generated header file.
The header's name is generated from a <product_name>-Swift.h
[Mixing Objective-C and Swift ]
I had a similar issue whereby it would have this issue for anything other than live.
I resolved the issue by hardcoding "Product module name" & "Product name" to my project name. This avoids the need to have preprocessor logic in every file that includes swift code as demonstrated in Pauli Kettunen's solution.

Resources