I've looked through a number posts and cannot find a solution to this problem.
I installed the MMLanScan Objective C library into in my pod file successfully.
Then I created a bridging header file in my project directory
#ifndef BridingHeader_h
#define BridingHeader_h
#import "MMLANScanner.h"
#import "LANProperties.h"
#import "PingOperation.h"
#import "MMLANScanner.h"
#import "MACOperation.h"
#import "MacFinder.h"
#import "MMDevice.h"
#endif
I also set the header file path in my project's compiler settings
But when I build my app, I get two compile time errors
error 1:
MMLANScanner.h file not found
error 2:
Failed to emit precompiled header `/Users/my user name/Library/Developer/Xcode/Derived Data/My Project Name...
Both these errors disappear when I delete my imports from the bridging header file.
Any clues how to compile this library would be appreciated.
edit
So the required .h files appear to be in my pod directory, so not sure why I get these errors
So the solution was as simple as adding the relative folder path to the header file imports
#ifndef BridingHeader_h
#define BridingHeader_h
#import "MMLanScan/MMLANScanner.h"
#import "MMLanScan/LANProperties.h"
#import "MMLanScan/PingOperation.h"
#import "MMLanScan/MMLANScanner.h"
#import "MMLanScan/MACOperation.h"
#import "MMLanScan/MacFinder.h"
#import "MMLanScan/MMDevice.h"
#endif
not
#ifndef BridingHeader_h
#define BridingHeader_h
#import "MMLANScanner.h"
#import "LANProperties.h"
#import "PingOperation.h"
#import "MMLANScanner.h"
#import "MACOperation.h"
#import "MacFinder.h"
#import "MMDevice.h"
#endif
Related
I successfully installed this Objective C library MMLanScan, successfully created a bridging header file, and successfully built my project without compile time errors.
But now when I extend from MMLANScannerDelegate I get a compile-time error, for example compiling this
class MyViewController: UIViewController, MMLANScannerDelegate {
// ...
}
results in this error
Use of undeclared type 'MMLANScannerDelegate'
Here is my bridging header file which I successfully compiled, so I'm not sure what the problem is
#ifndef BridingHeader_h
#define BridingHeader_h
#import "MMLanScan/MMLANScanner.h"
#import "MMLanScan/LANProperties.h"
#import "MMLanScan/PingOperation.h"
#import "MMLanScan/MMLANScanner.h"
#import "MMLanScan/MACOperation.h"
#import "MMLanScan/MacFinder.h"
#import "MMLanScan/MMDevice.h"
#endif
When reproducing step by step this this original example of RCTMapboxGL (5.1.0) I run into an error with the linker. This happens to me every time I try to use RCTMapboxGL.
I tried both the:
Manual installation process for iOS
Xcode console:
Installation process with CocoaPods
Xcode console:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_RCTMapboxAnnotation", referenced from:
objc-class-ref in libRCTMapboxGL.a(RCTMapboxGL.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The missing symbol RCTMapboxAnnotation is in ../node_modules/react-native-mapbox-gl/ios/RCTMapboxGL.xcodeproj, which is already added to my project as a reference.
Other Linker Flags in Xcode Build Settings
My solution was fixing all React import statements across the MapboxGL library.
Turning them into global imports in the form #import <React/MissingClass.h> solved the problem:
e.g. #import RCTView.h to #import <React/RCTView.h>
(9 files in total):
RCTMapboxAnnotation.m:
#import "RCTMapboxAnnotation.h"
#import <React/RCTEventDispatcher.h>
#import <React/UIView+React.h>
#import <React/RCTBridge.h>
#import <React/RCTUtils.h>
RCTMapboxAnnotation.h:
#import "RCTMapboxAnnotation.h"
#import <MapBox/MapBox.h>
#import <UIKit/UIKit.h>
#import <React/RCTConvert+MapKit.h>
#import <React/RCTComponent.h>
#import "RCTMapboxGL.h"
RCTMapboxAnnotationManager.m:
#import "RCTMapboxAnnotationManager.h"
#import <React/RCTUIManager.h>
#import <React/RCTConvert+CoreLocation.h>
#import <React/UIView+React.h>
#import "RCTMapboxAnnotation.h"
RCTMapboxAnnotationManager.h:
#import <React/RCTViewManager.h>
RCTMapboxGL.h:
#import <Mapbox/Mapbox.h>
#import <React/RCTView.h>
#import <React/RCTEventDispatcher.h>
#import <React/RCTBridgeModule.h>
RCTMapboxGL.m:
#import "RCTMapboxGL.h"
#import <React/RCTBridgeModule.h>
#import <React/RCTEventDispatcher.h>
#import <React/UIView+React.h>
#import <React/RCTLog.h>
#import "RCTMapboxGLConversions.h"
#import "RCTMapboxAnnotation.h"
RCTMapboxGLManager.h:
#import <React/RCTViewManager.h>
RCTMapboxGLManager.m:
#import "RCTMapboxGLManager.h"
#import "RCTMapboxGL.h"
#import <Mapbox/Mapbox.h>
#import <React/RCTConvert+CoreLocation.h>
#import <React/RCTConvert+MapKit.h>
#import <React/RCTBridge.h>
#import <React/RCTEventDispatcher.h>
#import <React/UIView+React.h>
#import <React/RCTUIManager.h>
#import "RCTMapboxGLConversions.h"
#import "MGLPolygon+RCTAdditions.h"
#import "MGLPolyline+RCTAdditions.h"
RCTMapboxGLConversions.m:
#import <Foundation/Foundation.h>
#import <React/RCTConvert+CoreLocation.h>
#import <React/RCTConvert+MapKit.h>
#import "RCTMapboxGL.h"
I have a project that is written in Objective-C and I am trying to add Swift to it. I have read several places that I can import my Project-Swift.h header in my Project-Prefix.pch. This works but I get a bunch of no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed warnings.
Am I doing something wrong or is it not possible to import the Project-Swift.h header in Project-Prefix.pch?
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "Project-Swift.h"
#endif
(a) The 4th parameter in the UIApplicationMain() method is the method:
NSStringFromClass()
(b) NSStringFromClass() is found in Foundation.h
(c) The only import into main.m is UIKit.h.
(d) As best I can tell, UIKit.h does not extend the Foundation.h
So, why am I not getting an error when I compile main.m? NSStringFromClass() should be an unrecognized method?
Have a look at the macro in the *prefix.pch file in your project supporting files ;-)
Foundation is imported in the precompiled header that comes standard with every Xcode project:
//
// Prefix header for all source files of the <x> target in the <x> project
//
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
My *-Prefix.pch file looks like the following
//
// Prefix header for all source files of the 'stuff' target in the 'stuff' project
//
#import <Availability.h>
#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
So why is it then when I remove #import from a file in Xcode 4.6.2 all the syntax highlighting turns off for all Foundation Framework objects? The code still compiles and run correctly.