I'm trying to import/use this project in my Swift application, but the compiler throws tons of error with following message:
No known class method for selector 'indexPathForRow:inSection:'
Following is the typical code which generates the above error:
if ([self tileForIndexPath:[NSIndexPath indexPathForRow:row inSection:i]].empty) {
...
}
I can able to run the downloaded project as an standalone application without having any problem, though.
I've also added all the frameworks to my main application - those were used and installed to the said project, but that didn't help. My main project's deployment target is 10.0.
indexPathForRow:inSection: is a static constructor method that creates NSIndexPath instances. It is defined in UIKit:
https://developer.apple.com/documentation/foundation/nsindexpath/1614934-indexpathforrow?language=objc
In this project the author imports UIKit in the pch file:
https://github.com/austinzheng/iOS-2048/blob/7c0840a0f7bd77b01d6a36778a253f8f4b2e6529/NumberTileGame/NumberTileGame/NumberTileGame-Prefix.pch#L14
So you have 2 options: either setup a pch file for Objective-C code in your project (create the file and add to Xcode project build settings), or in each source file where you get this error add #import <UIKit/UIKit.h>.
Im pretty new to Xcode/Swift and want to install a third party library(SharkORM).
I drag'n'dropped the folder "SharkORM" into XCode and selected "Create groups". Then i created a file "Swift-Bridging-Header.h" and typed in #include “SharkORM.h” as described in the documentation. When i hold CMD and click on it it leads me to the interface declaration(good!?). Now when i try to use it: class MyClass: SRKObject { ... } i get an error: "Use of undeclared type 'SRKObject'". But i can CMD+click on it which leads me to the interface declaration again.
I tried to install with Cocoapod, too, with no success.
As posted on GitHub, it sounds like the header file you created has not been added to the build settings as the chosen bridging header.
That is the most likely scenario leading to the object not being defined in your swift code.
Check, if SharkORM.h contains SRKObject declaration. If not, find header file with it and place it to bridging header too
I'm trying to Archive my project but I can't because this error:
/Users/username/Developer/clickbalance/cb-ventas/CB Ventas/CB Ventas/Header.h:12:9: error: 'StarIO_Extension/StarIoExt.h' file not found
#import <StarIO_Extension/StarIoExt.h>
^
<unknown>:0: error: failed to import bridging header '/Users/username/Developer/clickbalance/cb-ventas/CB Ventas/CB Ventas/Header.h'
** ARCHIVE FAILED **
I tried everything like the other questions says about a similiar error like this question: Getting "file not found" in Bridging Header when importing Objective-C frameworks into Swift project
But nothing work.
Here is the location of the framework and the header file:
I linked the .frameworks files in the Link Binary With Libraries too.
This is my header file:
#import <Foundation/Foundation.h>
#ifndef StarIO_Extension_Bridging_Header_h
#define StarIO_Extension_Bridging_Header_h
#import <StarIO_Extension/StarIoExt.h>
#import <StarIO_Extension/StarIoExtManager.h>
#endif /* StarIO_Extension_Bridging_Header_h */
The Objective-C Bridging Header I set to ${PROJECT_DIR}/CB Ventas/Header.h and is set at the Target level, and NOT the Project level
I'm using Cocoapods too.
How can I solve that problem to archive the project?
Make sure you have the framework checkbox checked for the target you are trying to archive in the Utilities pane -> Target Membership:
Im working on an iOS project, which shows the customer number in a barcode. I had installed the framework ZXingObjC with CocoaPods, described in GitHub.
I can compile my Project without errors. I can also use the classes of ZXingObjC in my Objective-C classes, without errors. After than, I have added the import Command #import <ZXingObjC/ZXingObjC.h> to my bridging header file, like my other custom objective-c classes, without compile errors. (I had testet the header file by destroying some import statements and got the expected file not found exception.)
But now, I can't use any class of ZXingObjC in my swift classes. I only got the following compile error: Use of undeclared type '...'. The Xcode autocomplete is not working, too.
e.g.
var test : ZXMultiFormatWriter?
>> Use of undeclared type 'ZXMultiFormatWriter'
I tried:
setup new project, same issue
checked header search path: $(SRCROOT)/Pods/Headers/Public/Adjust
reinstalled the ZXingObjC framework
checked build settings: Enable Modules: YES
checked build settings: Other Linker Flags: $(inherited) -ObjC
-framework "ZXingObjC"
checked linked binaries in the build phases: framework is added
checked import statement in the bridging header file (#import
<ZXingObjC/ZXingObjC.h> and #import "ZXingObjC/ZXingObjC.h" -- no
difference)
Windows style: restarting Xcode and Mac ;-)
I'm using:
Xcode: 6.3.2
CocoaPods: 0.37.2
Project Deployment target: iOS 8.0
SDK: 8.3
Does anyone know the problem? Can anyone help?
How can I make the ZXingObjC framework available in swift?
Actually it is an easy issue:
Podfile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'ZXingObjC', '~> 3.1'
So, on terminal:
cd workspace
pod install
Then, once opened project on Xcode, you have to edit bridging-header adding ZXingObj:
#import <ZXingObjC/ZXingObjC.h>
Finally, in your swift classes that uses ZXingObjC, you have to import ZXingObjC.
import ZXingObjC
class ZXingObjCWrapper {
func encode() {
let writer = ZXMultiFormatWriter.writer()
....
}
}
The rest of the code for when you need to set an UIImage with this bar code:
func generateDataMatrixQRCode(from string: String) -> UIImage? {
do {
let writer = ZXMultiFormatWriter()
let hints = ZXEncodeHints() as ZXEncodeHints
let result = try writer.encode(string, format: kBarcodeFormatDataMatrix, width: 1000, height: 1000, hints: hints)
if let imageRef = ZXImage.init(matrix: result) {
if let image = imageRef.cgimage {
return UIImage.init(cgImage: image)
}
}
}
catch {
print(error)
}
return nil
}
The header search path was not correct in my project. The right values are:
$(inherited)
"${PODS_ROOT}/Headers/Public"
"${PODS_ROOT}/Headers/Public/ZXingObjC"
The second and third lines were not added by installation with CocoaPods.
EDIT: The installed framework have to be added to "Embedded Binaries" in General tab of the project.
I tried everything on this page to add ZXingObjC as a Pod. My goal was to generate an Aztec barcode.
I checked my Header Search Path. As Reddas said, I had to manually add "${PODS_ROOT}/Headers/Public/ZXingObjC". I also added ZXingObjC as an Embedded Binary (in the General Tab).
I checked my bridging file & all was good. I checked my view controllers where I wanted to generate the barcode. The import ZXingObjC was there.
No compile errors. But I can't declare a variable of ZXingObjC.
No luck. Any more suggestions?
EDIT - I went into the Targets, Build Settings and searched for Header Search Paths. I added in BOTH "${PODS_ROOT}/Headers/Public/ZXingObjC" and "${PODS_ROOT}/Headers/Private/ZXingObjC"
This seemed to unclog whatever broke. It works now. Strangely, I can now even delete those entries and it works.
I accidentally deleted my library search path and framework search path from my xCode project. Now my bridging header file is not able to import chart boost header files and xCode is giving me swift compiler error while trying to build the app.
I tried to add absolute path of the framework in framework search path in build settings but nothing changed.
Can someone guide me through it?
These are are the kind of errors I am getting
MY_PROJECT/Bridging-Header.h:21:9: note: in file included from /MY_PROJECT/Bridging-Header.h:21:
import <Chartboost/Chartboost.h>
^
/MY_PROJECT/Chartboost.framework/Headers/Chartboost.h:16:42: error: function definition is not allowed here
typedef NS_ENUM(NSUInteger, CBFramework) {
^
/Users/MY_PROJECT/Bridging-Header.h:21:9: note: in file included from /Users/MY_PROJECT/Bridging-Header.h:21:
import <Chartboost/Chartboost.h>
unknown>0: error: failed to import bridging header '/Users/bewakoofmac/Desktop/Jumpy Tiles/jumpytiles/jumpytiles/Bridging-Header.h'