I've tried a number of ways to import the 3rd party library 'ZXing' into my iOS app, but all have been painful or have simply not worked. If anyone could suggest either what I'm doing wrong, or a better way to import a library such as ZXing, I'd be very grateful.
It must be easier than this!!!
This is what I've done, with results :
Directory structure of MyGreatApp (at time of writing)
/MyGreatApp/MyGreatApp.xcworkspace (main workspace that compiles the
application)
/MyGreatApp/Projects/MyGreatApp/MyGreatApp.xcodeproj
/MyGreatApp/Projects/MyGreatApp/(All source code for MyGreatApp)
/MyGreatApp/Projects/other-inhouse-project/other-inhouse-project/other-inhouse-project.xcodeproj
/MyGreatApp/Projects/other-inhouse-project/other-inhouse-project/(Source
code for other-inhouse-project)
/MyGreatApp/Projects/other-inhouse-project/RestKit/RestKit.xcodeproj
/MyGreatApp/Projects/other-inhouse-project/RestKit/(source code for
restKit)
Adding the ZXing project to the workspace:
Download project from git hub : https://github.com/TheLevelUp/ZXingObjC (latest release)
Copy project to /Projects (in svn repo).
Open MyGreatApp workspace, 'add Files' -> select 'ZXingObjC.xcodeproj'.
Add the compiled library (libZXingObjC-iOS.a) to the MyGreatApp build phases drag and drop from ZXing products. Add the frameworks required by ZXing.
Add Path to ZXing in header search paths and library search paths. "$(PROJECT_DIR)/../../Projects/ZXingObjC-2.2.6/ZXingObjC" . Use $(PROJECT_DIR) so the path is relative and works on all build machines.
Changed ZXing build settings to NOT use arm64 architecture, as we currently don't support it due to the old restKit library.
In order for other configurations to build, the only solution I've found is to add a configuration to the ZXing project with exactly the same name, i.e. adding QA (PAT12), QA (PAT14) etc etc. (this is not ideal)
Result :
Project compiles and works fine, the above steps were quite time consuming however.
Compiling ZXing produces no error warnings.
Can use
Adding the ZXing files to the MyGreatApp project (files compiled with project):
Download project from git hub : https://github.com/TheLevelUp/ZXingObjC (latest release)
Drag the ZXingObjC folder onto Xcode. Make sure "Copy items" is checked before clicking "Add".
Add the frameworks required by ZXing.
Had to alter line of ZXing source code to allow it to compile (not sure what the result of this might be, some info here : https://github.com/TheLevelUp/ZXingObjC/issues/118)
@property (nonatomic, strong) /*__attribute__((NSObject))*/ dispatch_queue_t captureQueue;
Result:
Project compiles and 'seems' to run fine (nervous about hacking the ZXing source code however)
Compiling produces about 180 error warnings.
Cant use
Adding the ZXing project using CocoaPods:
Followed instructions on CocoaPods website for installation.
Tried creating Podfile in the same Directory as MyGreatApp.xcproject, but this resulted in compiler errors, and the 'pod install' command created a new xcworkspace file in the same folder as my project (we already have one somewhere else)
Tried creating a Podfile in the same directory as MyGreatApp.xcworkspace, but this resulted in the pod install command not working
Result:
Cannot install using CocoaPods.
Cant use
Any help or suggestions as to how a good way might be to add ZXing to my project would be very helpful.
If you want to add third party API to your project then simply follow these steps:
+ symbol.This is the best approach to add any third party API to a project.
Hope this will help everyone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With