Framework missing from System but not XCode on Mac/iOS - ios

I'm working with a Qt project on a Mac. I have to add a framework
MessagesUI.Framework
to the XCode list of frameworks each and every time that I open the project or try to archive it. Is there a way to keep it as a required default so I won't have to add it every time?
I've tried changing the search path but that doesn't seem to work, and it is included in the project files that its used in, within Qt.
#import <ContactsUI/ContactsUI.h>
#import <MessageUI/MessageUI.h>
I also have it linked directly within the .pro file - another framework is successfully added that way.
INCLUDEPATH += /...File/Path.../System/Library/Frameworks
QMAKE_LFLAGS += - /...File/Path.../System/Library/Frameworks
LIBS += -framework ContactsUI
LIBS += -framework MessageUI
UPDATE: It appears that MessageUI.framework is missing from the System frameworks, but not from the XCode frameworks. ContactsUI.framework works, no issue there. Looks as though XCode won't allow me to add a framework from the XCode files, only from System files. ContactsUI.framework was also causing a problem prior to adding its address to the .pro file, but IS in System frameworks.

Use Cocoapods for adding frameworks in Xcode project. This is mostly used way for developers. Here is the link how to use it. Click Here

Cleared Derived Data and discovered a few small (but major) spelling mistakes.
Cocoapods was not necessary to solve this problem.

Related

iOS Framework headers not found in some files of the framework

I am developing a framework for my obj-c iOS app.
I followed this tutorial: https://www.raywenderlich.com/65964/create-a-framework-for-ios
My framework files builds correctly and I can import it into my sample project and it builds correctly. But my project doesn't perform as expected.
When I did deeper into my framework headers, I find my problem.
Certain header files allow me to CMD-Click on the imports to view the corresponding header files in my project.
So for example:
In TestFile.h, I have: #import <Framework/SomeFile.h>, I can CMD-Click on this grand and I get linked to SomeFile.h
In TestFile2.h, I also have: #import <Framework/SomeFile.h>. When I CMD-Click on this, I get the Question Mark symbol indicating that the file isn't found.
In my Framework Project, I have a directory structure like so:
FrameworkProj.xcodeproj
->FrameworkProj
->FrameworkHeaders.h
->Folder
->some files
->some folders
->Folder
I'm wondering if I haven't set a flag in my Build Settings that doesn't recursively link the files to my compiled framework, but I'm wondering why can I see the files in my headers files if this is the case.
Thanks very much!
May seem stupid but I solved this problem with a single line.
I needed to include -all_load in Target > Build Settings > Other Linker Flags

Modules are disabled - but why?

I'm struggeling with Modules in a project. Where I use #import I get "Use of '#import' when modules are disabled". But why are they disabled?
In my build settings I have "Enable modules (C and Objective-C)" set to Yes for all targets.
Setting "Link Frameworks Automatically" to Yes or No does not impact this (compile-time) error
Although the project used to have Objective-C++ and some C++ code, it doesn't anymore. Are there any project-settings I can have missed that were set because of this?
I have no more .pch files in the project, and the build settings have no mention of them
I use CocoaPods (0.39.0) with "use_frameworks!" and the modules I wish #import are from there. But the same error happens if I replace the '#import ' or '#import ' with '#import Foundation;' and '#import UIKit', so I expect this is not related
The project is from pre-iOS7 so I might have missed a setting that used to be on by default
The project requires iOS 8 and builds against iOS 9.2.
I realize that loading third-party modules will probably slow down the apps loading time. I'm converting to CocoaPods with use_frameworks! so that I can measure by how much. If it's not too bad, I'd like to use as I'm planning to move multiple swift-only parts of the codebase into their own frameworks (as open source coocapods)
I believe that this is not be a duplicate of other questions on SO since I've gone through the ones I found (big thank-you to this one), followed the links, re-watched WWDC'13 session 404, and read the related posts on Apples forums, so I believe I've done my homework. :-)
In my project I have a bridging header to bridge from ObjC to Swift, and there is a generated header file to bridge from Swift to ObjC. It turns out that if the bridging header referenced headers where the implementation file referenced the bridge file from Swift to ObjC, module support is disabled. So be careful about what you put in your bridging file, and be careful about when you import the generated -Swift.h file.
Firstly go to the terminal and type xcode-select -p. It should say, /Applications/Xcode.app/Contents/Developer. If it doesn't, then type, sudo xcode-select -s /Applications/Xcode.app and hit enter and type in your password.
If that doesn't fix it, try deleting your project's derived data directory. Go to the Projects view and delete the derived data for your project. Then clean your build folder (command-shift-K). Run Analyze (command-shift-B) and resolve any issues in blue and yellow.
Now if #import is still not working, create a brand new XCode project. Verify that #import works in it. If it doesn't, then your XCode installation got screwed up probably, or your HDD is dying. Delete XCode and re-download it, see if that works. Restart into the recovery partition and see if you have some disk issues (unlikely, but hey).
If #import works in the new project, try taking all your from your current project and copying them into the new project. Make sure you have the latest version of cocoapods and then freshly install your pods into the new project.
If all of that doesn't fix it, you probably left an #end statement out somewhere or have a missing } ...

opencv2/opencv.hpp file not found in Xcode

I have built openCV to get opencv2.framework. I added this to my xcode iOS project by going to "build phases->Link Binary With Libraries", then tried to include "opencv2/opencv.hpp" in my project.
I get the error "opencv2/opencv.hpp" not found. But the file exists in the framework. I have tried to find a solution online but nothing has worked for me.
The file I'm trying to include it in is a .mm file. I have made "compile sources as" objective-c++. Any help would be great.
What worked for me was very simple:
*NOTE THE DIFFERENCE FOR IOS vs. OS X PROJECTS
FOR IOS:
Put the opencv download (for 3.0.0 it is just a drag and drop kind of thing) into the project specific Xcode folder. Then set the Frame Search Paths to $(PROJECT_DIR). The Frame Search Path is located under the Build Settings. No other paths need to be set.
Lastly, right click in the navigator pane and click "Add Files to..." in order to add in the opencv library from the project folder.
FOR OSX:
check out Tim's tutorial: https://www.youtube.com/watch?v=OVSPfUmNyOw
I solve the problem by adding to the FRAMEWORK_SEARCH_PATHS the absolute path were I had the framework I needed to use:
You should use your own path obviously. ;-)
Took me 4 hours to figure this out. This is how I got this to work :
Along with the opencv framework add the following frameworks in the build phases:
Accelerate, AssetsLibrary, AVFoundation
, CoreGraphics
, CoreImage
, CoreMedia
, CoreVideo
, QuartzCore
, UIKit
, Foundation.
Then, in the .pch file add these lines before UIKit and Foundation imports :
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif
In my case the symbolic links to the header files were broken. This was caused by cloning the following great example project:
https://github.com/BloodAxe/OpenCV-Tutorial
In the cloned project, the header files were not reachable anymore. After reimporting the opencv2.framework from the official opencv ios download site (OpenCV for iOS), the headers were available again. XCode should look as follows:
The following is a screenshot of a Xcode project with broken headers.
With broken header files, the xcode project looks as follows:
Make sure in Build Settings for the Target, you have the Framework Search Path in the Search Paths section set to the correct path to where your framework is located in your directory. You can do this by clicking to the right of Framework Search Path in the white space, click the + sign and add $(PROJECT_DIR) then click + again and add $(inherited). Make sure the framework is located in your main directory for your project at hand. This worked for me, as I encountered the same problem.
Hope this helps!
I used openCV in my project and implementing it with cocoapods was impossible because version of library was too old, so i decided to implement it as static library. create folder in your project and add library there, in build settings find library and framework search path and add link to your openCV folder. It will work without any error. Also you should add openCV header file in prefixPatch.
More Detail Instruction 100% Works:
1) Download framework from official website: OpenCV
2) In Project Directory create folder named: External_SDK
3) Put Opencv framework inside this folder and drag&drop it in Xcode Project (Folder) with Target Membership of your App (Not App_test).
4) In Xcode Project search for yourPrefixHeaderFileName.pch and in the top of the file add this lines:
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif
5) after that you should import or include it in .h file, why include? because it's CPP library. If you want to access library with import keywoard than you should do like this: #import <EXAMPLE>
6) In build settings search for library and framework search path and add link to your EXTERNAL_SDK folder. To read framework directly from your folder. Find and change ALWAYS_SEARCH_USER_PATHS = YES
and in HEADER_SEARCH_PATHS add $(inherited) and /usr/include/FRAMEWORK_PATH
Hope this answer will help someone.
And the best practice is to call
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
Only header files.
From my experience, it is not necessary to add so many other frameworks. Instead, only need opencv2 and add "#import " in prefixheader.pch
The thing is that MUST set correct Framework Search Paths as mentioned above unless opencv2 framework folder is in your project directory.
Notice: don't set wrong location in Framework Search Paths as there are two "YourProjectName". Set the 1st one (belongs to TARGETS), not the 2nd one(belongs to PROJECT). I made the mistake.
Here is my answer for this.
Environment: XCode 8.1
Download page: http://opencv.org/downloads.html. Choose any link for iOS.
Important step: while downloading opencv2.framework, you must use ".zip" format, not ".framework" format, afterwards, unzip it to opencv2.framework. It is weird, but it should work. Meanwhile, you have to rename it to opencv2.framework if the unzipped one is not.
just drag and drop the framework to your iOS project. No any settings are required. You could refer to this for testing : www.youtube.com/watch?v=ywUBHqxwM5Q.
I ran into some issues when I went to Target-->Build Phases-->Link Binary With Libraries. When I added opencv2.framework from there, my app would not launch.
Instead, I just dragged and dropped the framework under the directory "Frameworks" in XCode and that worked. I didn't change anything else.

Trouble with an .h import

As a beginner in ObjectiveC I need some help.
I'm working on a phonegap plugin for IOS (so, written with objective C). I use some open source code but I got an error with an .h import.
My architecture look like:
myFmk.framework/
myFmk.framework/ABCDE/myFmk.h <== in a sub folder
myFmk.framework/myFmk <=== this is a file
myPlugin.h
myPlugin.m
In myPlugin.h I have #import and in "myFmk.framework/myFmk" file I have only one line "ABCDE/".
I thought that this file do a redirection of the absolute import (with brackets) but my complier told me that "myFmk/myFmk.h" is not found.
I tried to find some documentation about this feature but I wasn't able to find its name... do you have this documentation or the feature name?
Thks.
Is the framework added using a cocoapod? If not, did you follow the instructions properly for adding it to your project? It would probably help if you posted the framework you are experiencing problems with.
If this is a framework that is added to your project properly and you are unable to import there are a few things you should check. First, go to your project settings (click on the project at the very top of your file tree in the left column) and then look for "linked libraries". See if the library is listed there. If not click the + and try to add it.
If this framework was added via cocoapods another thing to check is search your file structure for libPods.a. If it is red, I find sometimes it is helpful to delete it, close the project and run pod install again.
Also if you installed the project via cocoapods remember to open the workspace and not the old xcode project file.
I have also experienced this problem when my header search paths and other linker flag paths were wrong. Linker Flags should be $inherited if this is a cocoapod. In my projects most Header search paths are $inherited too.
If none of this is helpful please provide more information such as how this framework was added to your project and what the framework is. Also let us know if you get any error messages.

XCode - Adding a external static library in Cocoapods project

I am experimenting with the Cocoapods to understand what settings/configurations it does so everything works so smoothly. While doing that one specific case troubling me.
Basically there is a different behaviour between non cocoapods projects that uses external libs and cocoapods projects that uses external libs.
Both projects and external library can be found on GitHub.
1) External library libImageFilters.a uses CoreMotion framework. So finally when this library will be included in any app, that app will either include CoreMotion framework or use clang modules so that just by doing #import CoreMotion; framework is added. I prefer the second approach and for this in the header file (ImageFilters.h) added below lines
#if __has_feature(modules)
#import CoreMotion;
#endif
2) AppWithoutPods application just add this external lib and header file. Do the below settings
Enable Modules = YES
Link Frameworks Automatically = YES
Build the application and everything build fine as CoreMotion Framework is included through header file.
3) AppWithPods application uses AFNetworking as a pod. So install the pods and open workspace. When built with above clang module settings,everything builds fine. Now if I add external lib and header file. Build fails with linker error saying CMMotionManager is referenced from libImageFilters. When CoreMotion is explicitly included it builds fine.
This is where the confusion is. Modules are enabled and frameworks are linked automatically. Basically there is nothing different in both apps except cocoapods.
I checked all the settings for both projects, nothing is different then why build fails? Can someone help me understand this?

Resources