DHlibxls icon indicating copy to clipboard operation
DHlibxls copied to clipboard

Guide to make it work with Swift

Open ricardo85x opened this issue 9 years ago • 6 comments

I would like to use the DHlibxls, but I have some problem on how to include it in my project.

On README I found this:

Usage: include the enclosed project in your primary Xcode project. Ensure that there is a dependency on it in an Target that uses it. [It does not use categories so no need for "-forceload".]

What you mean with encloused project? Do you mean only the DHxlsReaderIOS.xcodeproj? or the TestDHlibxls.xcodeproj? What about the others files and folders?

Thanks

ricardo85x avatar Nov 18 '15 20:11 ricardo85x

DHxlsReaderIOS - the other project shows a sample use of this project.

dhoerl avatar Nov 18 '15 22:11 dhoerl

Ok I did follow this guide:

http://stackoverflow.com/questions/9370518/xcode-4-2-how-include-one-project-into-another-one

But I still get this message:

screen shot 2015-11-19 at 10 36 09 am screen shot 2015-11-19 at 10 35 40 am

Do you know what it could be?

ricardo85x avatar Nov 19 '15 12:11 ricardo85x

Ok I did it: I have to add #import <Foundation/Foundation.h> on my bridge header

But

When I try to build I got this:

ld: warning: ignoring file /Users/ricardo/Library/Developer/Xcode/DerivedData/ExcelFinal-btnecoozlgukhpdhbhkymccgggac/Build/Products/Debug-iphoneos/libDHxlsReaderIOS.a, file was built for archive which is not the architecture being linked (arm64): /Users/ricardo/Library/Developer/Xcode/DerivedData/ExcelFinal-btnecoozlgukhpdhbhkymccgggac/Build/Products/Debug-iphoneos/libDHxlsReaderIOS.a Undefined symbols for architecture arm64: "OBJC_CLASS$_DHxlsReader", referenced from: type metadata accessor for __ObjC.DHxlsReader in ViewController.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am stuck again...

ricardo85x avatar Nov 19 '15 12:11 ricardo85x

Ok I did it: Follow the steps:

1 - Drag the DHxlsReaderIOS.xcodeproj inside you main project 2 - In you Project/Targets go on Targets and add DHxlsReaderIOS as Target Dependencies 3 - In you Project/Targets go on Build Phases and add libDHxlsReaderIOS.a as "Link Binary With Libraries" 4 - In your Project/Targets go on Build Settings and change the "User Header Search Paths" to "/full/path/of/the/DHlibxls/**" 5 - On DHxlsReaderIOS project on Build Phases, remove the libiconv.dylib 6 - On your project/Targets on Build Settings change the "Architectures" to "$(ARCHS_STANDARD_32_BIT)" 7 - On your project/Targets on Build Settings change the "Build Active Architecture Only" to "NO" 8 - On your project/Targets on Build Settings -> Other Linker Flags add: -libiconv and -ObjC 9 - On DHxlsReaderIOS projectc do the same as item 8 10 - Add a bridge header to you project with: "<Foundation/Foundation.h>" and "DHxlsReader.h"

sample swift code:

[code] let file : String = NSBundle.mainBundle().pathForResource("test", ofType: "xls")! let reader = DHxlsReader.xlsReaderWithPath(file) print(reader.appName()) [/code]

Sorry for my english.

ricardo85x avatar Nov 20 '15 14:11 ricardo85x

Great! So you added the above comment to show that you got it to work?

I just updated the project to support 64 bit and had to deal with issues relating libiconv - see https://forums.developer.apple.com/thread/4572.

So the project is updated to latest Xcode 7.1, and the Test App also works and runs on a 64 bit device in the simulator.

dhoerl avatar Nov 20 '15 15:11 dhoerl

yes now it is working fine : )

ricardo85x avatar Nov 20 '15 15:11 ricardo85x