iOS project compilation - ios

I am working on a project accessing web service. I found a project
http://d1xzuxjlafny7l.cloudfront.net/downloads/PromoTest.zip
The above code include JSON library [project setting compiler = LLVM 4.2]
And I tried to use partial code of that project in my project.
So I copied the JSON library into my project [my project uses Apple LLVM 3.1]
and then some error show up
eg.
SBJsonStreamWriterState **states;
//error:Pointer to non-const type "SBJsonStreamWriterState *" with no explicit ownership
I have tried using compiler flags -fno-objc-arc, no good.
I wonder if its a ARC problem? if it is, then why above compiler flag wont work.

Try disabling ARC at the target level like shown in the attached picture:

So, I solved it by deleting SBJson Library. I found Apple already written a json library.

Related

How to fix Application Loader Error: Invalid Bundle. The bundle ... contains disallowed file 'Frameworks'

I have a Swift project with three Swift custom frameworks. The App builds and runs successfully but when I try to upload to iTunes Connect using Application Loader I get the following error for all three frameworks:
ERROR ITMS-90206: "Invalid Bundle. The bundle at 'XXX.app/Frameworks/YYY.framework' contains disallowed file 'Frameworks'."
As discussed in this SO answer I have set the 'Embedded Content Contains Swift Code' to NO in the frameworks and YES in the App, but this error persists.
The three Frameworks are all my own (I am seriously considering reworking the project to avoid Frameworks altogether but that is a chore I would like to avoid right now).
I am not using cocoapods.
Any ideas on how to resolve this error?
The key to solving this for me was, in addition to ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO, also setting EMBEDDED_CONTENT_CONTAINS_SWIFT=NO in build settings for all targets except the main app target. Had to clear out derived data, but after that all was well.
In (SE-0133) of the Xcode 8.3 Release note, there's a description about EMBEDDED_CONTENT_CONTAINS_SWIFT setting:
The new build setting ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES replaces the EMBEDDED_CONTENT_CONTAINS_SWIFT setting, which has been deprecated. This new setting indicates that Xcode should always embed Swift standard libraries in a target for which it has been set, whether or not the target contains Swift code. A typical scenario for using this setting is when a target directly uses or embeds another product that contains Swift code. (26158130)
which means ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES has replaced EMBEDDED_CONTENT_CONTAINS_SWIFT, thus you need to change the former one(ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES) to NO in the extension target.
So this is not a good answer, but it is what I did to resolve it:
I created a new project and copied in all my files - in a flat structure without Frameworks, editing just to remove the relevant import statements. It now uploads fine. So it is the Framework structure that is the root of the problem. Not sure if the idea of Swift embedded custom libraries is just broken or I was doing something wrong so still looking for better answers...

Building Cocoa touch framework with c++11 code

I am trying to make an iOS framework. My code includes c++11 features.
When I build the framework target I get errors such as:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ctime:56:9: No member named 'clock_t' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ctime:58:9: No member named 'time_t' in the global namespace; did you mean 'size_t'?
How can I resolve this? Thanks.
UPDATE:
Here is my Apple LLVM 6.0 - Language-c++ settings:
Regular iOS project with that c++11 code compiles without errors.
you need to explicitly add libc++ as a linked library under general tab.
I don't know how far it will work fine in your scenario. I got similar kind of error when I tried to compile and build so. I will share what I did :
1.Goto your project Build Settings.
2.Click Build Settings.
3.Search for Apple LLVM 6.0 - Language-c++ .
4.set c++ standard library as libstdc++ .
Then try compile the project.
This might not the exact solution.
I just shared what worked for me when I am facing the similar kind of errors as yours.
Thank you!
Have you tried setting the C++ Language Dialect to C++11? It's in the same place as the C++ standard library setting:
Go to Build Settings
Select your Target, and click Build Settings.
Search for Apple LLVM 6.0 - Language-C++
Set C++ Language Dialect to C++11.
You might also have to set the C++ Standard Library to libc++.
Xcode adds all headers to the "Headers" build phase by default. So, I solved my issue by removing all unnecessary C++ headers from the build phase.

iOS: Unknown type name 'namespace' with Qualcomm's Vuforia Augmented reality source

I am using Qualcomm's Vuforia Augmented Reality solution in my iOS project. I integrated their library and files into my application. But, I'm struggled with the build error for long time, couldn't be able to fix it. Please refer the attached image. The actual error is Unknown type name 'namespace' in their Matrices.h file.
I know this error comes because of C++ access, so we need to rename the extention to .mm file which are trying to access c++ functions. I actually changed the files into .mm including this SampleApplicationSession.mm. But, still I'm getting the namespace error. Could someone please guide me how to fix this?
You can rename your file with .mm or you can select your .m file and change the "File Type" to "Objective-C++ Source".
Its works.
In general if you try to compile Objective c++ source, you can get this error.In Xcode ,selecting the TARGET and then going to Build setting->Apple LLVM 6.0-Language->Compile source As,then changing the option From "According to File type" to Objective-C++ ,worked for me.Hope it will work.

Stripe API gives 'SenTestingKit/SenTestingKit.h' file not found

I've read through the article referring to this in xcode 4.5, but it didn't help me in xcode 5.0.2.
I have a project that compiles successfully. If I add the Stripe framework to my project then it immediately fails to compile and gives me this file not found error for an #import made in this header file:
Stripe/Vendor/PaymentKit/PaymentKit Example/PaymentKit Test/PKCardNumberTest.h:9:9: 'SenTestingKit/SenTestingKit.h' file not found
I do not have the SenTesting framework in my link libraries. If I add it I get an error about it being an OSX library and not an ios. None of the Stripe documentation gives any indication that you need to add this library. I sent their support an email and they told me they don't have any information.
Anyone out there have any suggestions? Again, as soon as I add the framework to my project (and I am making sure it copies the files to my project) it fails to compile.
I tried adding quotes around my framework search paths, but it just changed the error so now Parse/Parse.h was no longer found.
The two framework search paths I have are: $(inherited) and /Users/ctam/Documents/development/Chw
See the Xcode 5.0 Release Notes:
Unit Testing
The CPlusTest unit testing framework has been removed
from Xcode 5. To write unit tests for C++ code, use the new XCTest
framework and create Objective-C++ (.mm) test case subclasses. 8273037
SenTestingKit and OCUnit are deprecated. Use the migrator to move to
XCTest. 14857574
When you download the Stripe library via the link in their documentation there are a bunch of subfolders for a test project they don't tell you about. I looked through and removed the test application files and everything works fine now. Curious that their explicit directions lead to this problem.

How to link a Cocoa Touch Static Library to a MonoTouch project?

I have created a Cocoa Touch Static Library using Xcode 4 and I want to use it in a MonoTouch project. How do I proceed?
Here is the content of my Static Library :
MyClass.h
MyClass.m
I built using "Build For Archiving" after following THIS BLOG POST and I took the libMyLib.a it generated and added it to a new MonoTouch Binding Project.
Then I replaced the content of libMyLib.linkwith.cs, because THIS BLOG POST said so.
[assembly: LinkWith ("libMyLib.a", LinkTarget.ArmV6 | LinkTarget.ArmV7 | LinkTarget.Simulator, ForceLoad = true, Frameworks="CoreGraphics QuartzCore UIKit")]
Then I added this to ApiDefinition.cs
I left StructsAndEnums.cs empty.
Then I built with Release and took the dll from the bin folder and added it to the root of a MonoTouch iPad project, and added it to the references.
Then, after following the instructions in THIS ARTICLE, I set the mtouch arguments to this
-gcc_flags "-L${ProjectDir} -lMyLib -force_load -ObjC"
Then I tried to run the project and I got this error in the Build Output
error MT5201: Native linking failed. Please review user flags provided to gcc: "-L/Users/herpderp/Projects/TestProject/TestProject" "-lMyLib" -force_load "/Users/herpderp/Projects/TestProject/TestProject/libMyLib.a" "-L/Users/herpderp/Projects/TestProject/TestProject" "-lMyLib" "-force_load" "-ObjC"
This directory contains a full sample showing various ways of integrating Objective-C libraries with MonoTouch:
https://github.com/xamarin/monotouch-samples/tree/master/BindingSample
The error message for MT5201 tells you there was an error while doing the native link step. That's 100% sure. The second part ask to to review your gcc_flags, which is the most common reason, for the failure. However it's not 100% sure this is the issue. When you seek help you should always paste the lines above any error (as they might be useful).
The error is likely about the duplication of the options given to the native linker. This occurs because you did supplied them twice (i.e. in your binding project and in your main project).
From the Binding Objective-C Types article you linked:
Or you can take advantage of the assembly-level LinkWithAttribute, that you can embed in your contract files...
It means the additional mtouch arguments are not needed with you use LinkWith attribute. Since you're using this way (the best one :-) to bind your static library you can skip this step (from your main project).
By doing so you do yourself (and anyone using your library) a favor since they are less risky to get out-of-sync (e.g. library update or different build configuration).

Resources