GenericKeyChain KeychainItemWrapper.m does not compile when copied to another project - keychain

I compile and run Apple's GenericKeyChain sample code. No problems there. Now I want to use both files KeychainItemWrapper.m and KeychainItemWrapper.h in my new project and I get lots of compilation errors. I see that Apple's sample code is using ARC. Other posting here direct people to disable ARC for this file. That did not work. I have link the Security Framework on my new project.
My question is what should I do to get these two files compiled successfully on my new project. Why Apple sample code compiles with no problems.
The compilation errors are mostly ARC Casting Rules and ARC restrictions as well as Semantic Issue of using "release".

try the following 2 methods:
Go to Build Setting -> Swift Compiler -> Objective-C Bridging Header and set the path to /"Your project name"-Bridging-Header.h
ex path: myProject/myProject-Bridging-Header.h
Go to Build Phase -> Compile Source and pick the objective-c file (.m file) and set compiler flag to be "-fno-objc-arc"

Related

Avoid compiling Swift files for a single target

I have a large Xcode project, with a mixed Swift and Objective C codebase. One of my targets is a QuickLook plugin, which does not use any Swift files.
When building the QuickLook target, each Swift file with references to ObjC classes (correctly bridged in the main target) report "Cannot find type in scope" errors — even though none of those Swift classes are included in the given target.
I've tried changing SWIFT_COMPILATION_MODE to singlefile for both release and debug, but it didn't help. To be absolutely sure that no Objective C classes import any Swift files in this target, I've also set up a preprocessor macro to guard the inclusion of Project-Swift.h files. I can't find a flag to completely skip Swift compilation phase when building.
Are Swift they automatically compiled no matter what I do and regardless of their target membership?
For anyone else struggling with this in the future:
When QuickLook extensions are compiled, even for the simulator, it tries to compile any other targets that might include it. I had an old build target, which was no longer maintained. At some point, the bridging header of that target had fallen behind the actual project, and for some reason, Xcode threw an error for every Swift class.
Go through all any targets that include your extension, even tests, and make sure those compile correctly, or remove those altogether.
The errors were not associated with that particular target in the logs or in the UI, which is probably an Xcode bug.

WebRTC in iPhone (gas-preprocessor issues)

I'm trying compile the lastest WebRTC version for iPhone. I not need to compile the entire solution, I only need to compile the VAD module.
To do that, I have created a Xcode project and I have tried to compile the source necessary, but I have a problem with the *.s files and its assembler.
Like in the FFMPEG library, I know that I must "translate" the assembler code to an assembler code that the gcc for iPhone understand, but I don't know how I do this manually.
I have tried to create a configure file and set in it "as=gas-preprocessor.pl" (like in FFMPEG), but does not work.
Any idea? How do I run the gas-preprocessor.pl manually?
Thanks.
I'm just finishing it on iOS and has built standalone static libraries of NS/VAD/AECM and AGC, here's some tips for you, and hope you success:
1. Source File List
for standalone VAD build, you should make sure your project has all of these files(no .s file needed), and I'm not listed the header files here, you will get some header file can not be found errors, just fixing it and things will be done.)
webrtc_vad.c
vad_core.c
vad_filterbank.c
vad_gmm.c
vad_sp.c
real_fft.c
division_operations.c
complex_bit_reverse.c
cross_correlation.c
complex_fft.c
downsample_fast.c
vector_scaling_operations.c
get_scaling_square.c
energy.c
min_max_operations.c
spl_init.c
2. Adding a macro called WEBRTC_MAC
I'm not sure why the Xcode environment does not provide this macro, but it should be defined to ensure that WEBRTC_POSIX is enabled. To define this macro, adding it to a new header file or just define it in the webrtc-header-files.
3. Following these steps to build and setup a static library of WebRTC-VAD module on iOS
notice, do not use LLVM 2.0 to compile the VAD module(use GCC or LLVM GCC). cus' it can throw you lots of errors when compiling some webrtc variable declarations.
4. Using the libwebrtc_vad.a
if you got this far, things are easy to go, just include webrtc_vad.h and using the API provided by this module. and vad is working fine in my case.
hope i helped.
try to check this link https://groups.google.com/forum/?fromgroups=#!topic/discuss-webrtc/VJg-fk2-i_0 i believe you have to set inline assembly correctly. I am also onto this so let me know if you want to switch emails or something.

Library Project Reference in Xcode

I know something like this is already asked many times on SO, but I've tried everything (been at this for three hours now) and I still didn't find a solution. I'm quite new to xCode and I'm starting to work on a project that was originally created by somebody else.
So, I have a library project in my xcode (XS2Library) and now I would like to reference to that library in my other project (WaarBenJij). Building the Library succeeds and I reference to it by adding the LibXS2Library.a to the Project target's "Link Binary With Libraries".
Xcode doesn't give me any errors, so it looks like the library project is referenced appropriately. However, when I try to build my project I get the error that a class that resides in my library project cannot be found ("'XS2URLLoader.h' file not found").
Can anybody steer me in the right direction, maybe?
There's a sensible difference between the .a file, which is needed for linkage and contains the library source, and the .h file, which is needed to compile (and preprocess) and which contains the functions and classes declarations.
Here you included the .a file, which is required for a later step, but to use the library you also need to import the required .h files into your project.
The easier way is to simply put them in your project.
Or you can add the whole library as a subproject and as a dependency.

ios iPhone / iPad - Project with GData static library libGDataTouchStaticLib.a fails on build (duplicate symbol)

I am trying to build an App using the GData static library libGDataTouchStaticLib.a
I have made all the appropriate linkings in my project settings and have copied GDataXMLNode.h and GDataXMLNode.m to my project.
I am receiving the error below. Can someone help me understand what this is?
ld: duplicate symbol _kGDataXMLXPathDefaultNamespacePrefix in
/Users/myUser/Library/Developer/Xcode/DerivedData/GData-edmqtrniowvhfjgfgngtlfxttvri/Build/Products/Debug-iphoneos/libGDataTouchStaticLib.a(GDataXMLNode.o) and
/Users/myUser/Library/Developer/Xcode/DerivedData/MyApp-grzimbvctfmwhmdluxbuxmskcvzy/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/GDataXMLNode.o for architecture armv7
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang failed with exit code 1
You shouldn't have to copy in GDataXMLNode.h and GDataXMLNode.m to your project. I believe the reason you are getting the duplicate symbol error is because the libGDataTouchStaticLib.a library already contains the compiled GDataXMLNode.m class.
I am currently using the GData library in a project I am working on, and got it set up by using these instructions: http://hoishing.wordpress.com/2011/08/23/gdata-objective-c-client-setup-in-xcode-4/, so this answer assumes that you have the same setup. However I have used a slightly different way of importing the headers that was suggested by one of the comments on the above blog.
In your Xcode project remove the GDataXMLNode.h and GDataXMLNode.m files, and make sure that the GData.xcodeproj project is linked into your project the same way as in the above blog, but do not drag the headers directory to your source tree. Add these arguments to the Debug and Release Header Search Paths of your current target instead:
/usr/include/libxml2
${BUILT_PRODUCTS_DIR}/Headers
You can find this under the Build Settings tab of your target. The second argument will import all the GData headers into your project if you have set up the GData.xcodeproj file correctly. Once you have done this you should be able to import the various GData classes including GDataXMLNode.h class wherever you need it by typing this at the top of the appropriate class:
#import "GDataXMLNode.h"
Much credit goes to Kelvin's blog for his great tutorial. Hope that helps!

why do I get this error building a static library for my iPhone project using XCode 4?

I have an existing iPhone application, and I just wanted to make a static library out of the code, so that I can use it by a separate test application (within the workspace). The application compiles fine, but when I try to compile the library version (which has the same code files) I get the following error:
Lexical or Preprocessor Issue - "MyClass.h" file not found
However, the application still runs, even through there is this error. In fact when I compile the application (which uses the static library) it initially says no errors, and then after a second or two the above mention error then appears.
I'm basically doing:
Create a new target in the project using the Coco Touch Static Library
Add the .m files in the targets "Compile Sources"
Adding the .h files in the targets "Copy Headers"
Adding the same set of libraries in the "Link binaries with libraries"
Go into the Profile and modified the Target to be RELEASE
Any suggestions? Am I missing a step here?
I'll have a stab at this :-) I think it might be that MyClass.h has been set to private. Thus it is not added to header directory when you create the static library. You should check to see if this is so by checking the output header directory. If the header file is missing, then it's pretty sure thats whats going on.
Secondly, why use a seperate app for testing and therefore require building a static library at all? I have several static libraries and apps which I unit test with GHUnit. I do it by simply adding a new app target and configuring it to run the GHUnit iOS app. I can then add the classes I want to test and any testing frameworks such as OCMock without having to create separate projects. Basically it sounds like your testing methodolody is perhaps more complex than necessary. :-)
So, the issue turned out to be I had "-ObjC" set in the "Other Link Flags" option, which I'd put there as at one stage trying to get things working I read this was required - Dereks advice to review the compilation log worked well here