Adding ZXingObjC framework to a project - xcode

Now that ZXingObjC can be used as a framework I can't figure out for the life of me how to add it to my project. I followed the instructions on the git page https://github.com/TheLevelUp/ZXingObjC, but when I add #import <ZXingObjC/ZXingObjC.h> xcode can't find the file. The example projects that they provide, however, compile fine.

Current answer would be http://cocoapods.org.
Put
pod 'ZXingObjC' into your podfile.

The file below does not exist in library header files.
#import <ZXingObjC/ZXingObjC.h>
Also set library header file path in Search Header Path in Build Settings. and import file as per your requirement.

Related

ModuleMap: How can I set a relative path for the umbrella header?

I am working with the Swift Package Manager. I have a project which I can successfully build via "swift build". I have created an Xcode project via "swift package generate-xcodeproj". When I open the project in Xcode it builds successfully.
The Xcode project includes two modules A and B.
Module A has the following map:
module ModuleA {
umbrella header "/Users/Robert/Temp/MyProject/Sources/ModuleA/include/ModuleA.h"
link "ModuleA"
export *
}
Module B depends upon A and has the following import:
import ModuleA
So far so good; everything builds successfully. Now I want to change the module map so that it uses a relative path, such as:
module ModuleA {
umbrella header "ModuleA.h"
link "ModuleA"
export *
}
However, when I do that I cannot get Module B to build: Error - Umbrella header 'ModuleA.h' not found. I have tried everything that I can think of in Build Settings -> Search Paths -> Header Search Paths and User Header Search Paths. I've found similar issues online, here and elsewhere, and have tried what I read but so far no go.
This has reached the hair pulling stage. Any advice will be much appreciated!
My guess is you're modifying the generated modulemap. Create a modulemap file at /Users/Robert/Temp/MyProject/Sources/ModuleA/include/module.modulemap containing:
module ModuleA {
umbrella header "ModuleA.h"
link "ModuleA"
export *
}
Run $ swift package clean to remove the old generated modulemap in .build directory and $ swift build to confirm that the custom modulemap works.
Then delete the generated Xcode project and re-generate it.

Xcode Archive Build Fails

I have an Xcode 7.2 project that succeeds when building/running against the local device Product|Build. The main project include a reference to InAppSettingsKit project. When I try Product|Archive the build fails. Any help or suggestions will appreciated.
The main project has a bridging header file to InAppSettingsKit project. The problem seems to be that the header file referenced in the bridging header file is not found.
Bridging Header File
#ifndef Screen_Saver_Killer_InAppSettingsKit_Bridging_Header_h
#define Screen_Saver_Killer_InAppSettingsKit_Bridging_Header_h
#endif
#include <UIKit/UIKit.h>
#import "InAppSettingsKit/IASKViewController.h"
#import "InAppSettingsKit/IASKAppSettingsViewController.h"
#import "InAppSettingsKit/IASKSpecifierValuesViewController.h"
#import "InAppSettingsKit/IASKSpecifier.h"
#import "InAppSettingsKit/IASKSettingsReader.h"
#import <iAd/iAd.h>
As requested, here is the search paths of the main project:
(I noticed InAppSettingsKit.xcodeproj is in red; does that mean anything ?)
My problem was with InAppSettingsKit. Their website says: for Archive builds there's a minor annoyance: To make those work, you'll need to add $(OBJROOT)/UninstalledProducts/include to the HEADER_SEARCH_PATHS
This wasn't quite right either.
I think this is a bug in XCode 7.2 + Swift with Obj-C dependencies when archives are built.
I now know way more about xcode than I ever wanted to.
First you need to go through the install logs to find out where things are being built. On my installation $OBJROOT points to:
/Users/jlongo/Library/Developer/Xcode/DerivedData/PROJECTX-bmyyngijghtekdgqqfnabonhpuxo/Build/Intermediates/ArchiveIntermediates/PROJECTX/IntermediateBuildFilesPath
There I found the header files in the path:
.../IntermediateBuildFilesPath/iphoneos/include/InAppSettingsKit/
So my resolution ended up being (non-recursive)
$(OBJROOT)/UninstalledProducts/iphoneos/include
Interestingly, $(OBJROOT) or other recursive paths shorter than this one did not work.
Also I placed this setting in:
Main Project|**Targets**|Build Settings|Header Search Paths
setting it here will not work:
Main Project|**Project**|Build Settings|Header Search Paths

RCT Linking Manager file not found

I want to use react native library RCTLinkingManager which shows up in menu under "Libraries > RCTLinkingManager.xcodeproj".
However when i add it to iOS/AppDelegate.m like so:
#import "RCTLinkingManager.h"
// #implementation ...
Build fails with 'RCTLinkingManager.h' file not found. I tried to clean the product and clean build with no luck.
You have to add $(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS to your "Header Search Paths" in the Build Config of your project. You can find more info on the official React documentation
Kindly make sure that you place the
#import <React/RCTLinkingManager.h>
in the Appdelegate.m file above the
#ifdef FB_SONARKIT_ENABLED
it worked for us.
I had a similar issue only when I've done the archive/release version... that happen because the import was made under the #if DEBUG. So make sure you put the import in the proper place otherwise you can get Use of undeclared identifier 'RCTLinkingManager' error
Anyone who is facing this issue for a react-native archive for ios platform just place
#import <React/RCTLinkingManager.h>"
after the first line
"#import "AppDelegate.h"" in the AppDelegate.m file.
If you are using React Native and the command line, Sébastien's modification proposal is to be made to ios/<yourproject>.xcodeproj/project.pbxproj by adding
"$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS",
to the HEADER_SEARCH_PATHS lists (4 locations)
Oh man. similar to this answer:
Anyone who is facing this issue for a react-native archive for ios
platform just place
#import <React/RCTLinkingManager.h>" after the first line
"#import "AppDelegate.h"" in the AppDelegate.m file.
I had to put it above this line (for react-native#0.70)
#if RCT_NEW_ARCH_ENABLED

How can I include a .pch for a specific pod, in cocoapods?

In my projet MyProject (I'm using cocoapods), I want to use MyPod.
The classes of MyPod are copied to MyProject, but not the .pch. Hence, the project is not compiling.
So, I have two questions :
How can I add the .pch of MyPod to the imported classes of MyPod?
Is there a way to "include" the .pch of MyPod in the .pch of MyProject (or, to "modify" the latter)
I am sure 1. is possible. I am learning cocoapods right now.
EDIT
As said in the documentation of cocoapods, the prefix_header_contents attribute of a .podspec is "not recommended as Pods should not pollute the prefix header of other libraries or of the user project."
So, is there any other way? Are we supposed to develop libraries without anything in the .pch?
You have to use the following property:
s.prefix_header_contents
For instance: s.prefix_header_contents = '#import "SomeClass.h"'.
It will add this line of code to the pch file associated to the Pod.

XCode include paths

I'm having a problem getting XCode to deal with a particular file structure that I am using or that I wish to use.
I have a set of files in the following form...
Library
Headers
Library
Package1
Header1.h
Header2.h
HeaderN.h
Package2
Header1.h
Header2.h
HeaderN.h
PackageN
Header1.h
Header2.h
HeaderN.h
Source
Package1
Source1.m
Source2.m
SourceN.m
Package2
Source1.m
Source2.m
SourceN.m
Package3
Source1.m
Source2.m
SourceN.m
The include model I want for code outside of this library is...
#import "Library/Package/Header.h"
I want to point XCode at Library/Headers but not at the internal folders. When I add this tree to the project XCode seems to make implicit include paths to every node in the tree.
Client code within the project but outside this tree can do this...
#import "Header.h"
instead of...
#import "Library/Package/Header.h"
I can't seem to find a way to dissallow the non-qualified form.
Any help would be appreciated.
Thanks,
-Roman
You're running up against Xcode's behaviour that it builds a flat-headermap. You can disable this by adding the build setting:
HEADERMAP_INCLUDES_FLAT_ENTRIES_FOR_TARGET_BEING_BUILT=NO
to your project settings.
If you include the headers in files in the project then XCode will always find them without path qualification, as you've discovered. The best solution is to remove the headers from the project and specify "Library/Headers" as a header search path in your project settings. The headers won't show in your project, but they also won't be implicitly found by XCode while compiling, either; client code will have to specify the full path off of "Library/Headers" to get to the header file they want.

Resources