Using iOS 7 SDK with llvm-gcc-4.2 - ios

I've installed xcode 5 and noticed that gcc compiler is deprecated. Assuming that I don't want to switch to Apple LLVM 5.0, here come my questions:
Is it possible to use iOS7 SDK and still compile in llvm-gcc-4.2?
If yes, how to do this?
If you don't know if that's possible, please don't post answers like "use clang, man", because they are not actually answering the questions I've posted.

Apple has removed the support for llvm-gcc-4.2 in XCode 5. Even if you install and change your base sdk to 6.1 sdk, you won't be able to build using llvm-gcc-4.2. So your only option is to continue using XCode 4.x if you want to use llvm-gcc-4.2.

LLVM-GCC is not included in Xcode 5.
I got above line from
https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_5_0.html
So the question is what to use instead of llvm-gcc ?

Is it possible to use iOS7 SDK and still compile in llvm-gcc-4.2?
If you want to compile your whole app using llvm-gcc-4.2: Probably not. I haven't checked this myself, but the iOS 7 headers would only need to add a single dependency on a clang feature missing in llvm-gcc-4.2 and you're swimming in compile errors. You may be able to hack your way through them, but it would likely be easier (not to mention more future-proof) to suck it up and upgrade to clang.
If you only need to compile some of your app using llvm-gcc-4.2: Sure, as long as you don't need to import any iOS 7 headers in the parts that you build with llvm-gcc-4.2.
You could try moving the problematic bits off to a static library, compiling that with gcc, then linking in to the final app, built with clang. You won't be able to target 64-bit, as llvm-gcc-4.2 doesn't can't generate armv8 code, but it should work otherwise.
One caveat: If your static lib uses C++, there may be some problems due to ABI and std library differences. But those are solvable problems, at least.

You could use homebrew to install the gcc version you need. Most probably all your Makefiles will need to be corrected (sigh)
I did:
brew search gcc
And the results:
homebrew/versions/gcc43
homebrew/versions/gcc45
homebrew/versions/gcc47
homebrew/versions/gcc49
homebrew/versions/gcc44
homebrew/versions/gcc45
homebrew/versions/gcc48
homebrew/versions/llvm-gcc28
homebrew/dupes/apple-gcc42

Related

Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.3 compiler

Check several publications with the same compilation error, and it really seems annoying that some libraries do not have support for current versions, well Apple also updates the Xcode many times along with the Swift version. Then after reviewing many publications and research, I discovered this post where they indicate:
Swift 5 provides binary compatibility for applications: a guarantee
that, in the future, an application created with one version of the
Swift compiler will be able to communicate with a library built with
another version. This applies even when using the version
compatibility mode from previous languages ​​(-swift-version 4.2).
In other cases, they indicate using carthage update --platform iOS --no-use-binaries but I am using cocoapod so I cannot use that solution and finally indicate enabling Build Libraries For Distribution, but nothing really worked for me until now and I can't help thinking that maybe tomorrow they will launch swift 5.1.4 and the support they make for swift 5.1.3 is unusable.
I really hope you can help me with the solution to the problem I present with the compilation error and if anyone knows about the post ABI STABILITY

Can I use old frameworks when migrating to Swift 3?

I'm currently migrating my project to Swift3 as I know that there is one bug I have under iOS 10 that needs to be fixed.
So I installed iOS 10 on one of my devices.
Now I can't run my app on the device, getting the 'Could not find developer disk image' error.
So I downloaded the latest Xcode8-beta.
Now my code can't be compiled - I first have to convert it to the newest syntax.
So while fixing all the non auto-converted syntax issues, I'm getting errors for frameworks I'm importing, too:
"Module file was created by an older version of the compiler"
Which - to my understanding - means that this framework needs to be recompiled with the current version of XCode.
This would mean that I would have to cross my fingers that all the frameworks I use are up-to-date, or otherwise, fix those, too?
Is it not possible at all to use 'deprecated' frameworks?
Is this Apple being super strict to get rid of any Swift1/2 code as possible?
This would mean that I would have to cross my fingers that all the frameworks I use are up-to-date, or otherwise, fix those, too?
Is it not possible at all to use 'deprecated' frameworks?
Is this Apple being super strict to get rid of any Swift1/2 code as possible?
Yup. Swift 3 is it.
I feel bad for those that had to convert their C code to swift 2, and now swift 3 is coming xD
Hopefully they will make the transition easier with the final release version, and that shortly after that all of the major frameworks will have been updated (for you to recompile).
You need to recompile the frameworks. Even frameworks managed with dependency managers like Carthage (which recompile on each update command) are still having problems with XCode 8 Betas / Swift 3: https://github.com/Carthage/Carthage/issues/1440

make Xcode build fail or at least warning if I use methods from "future" SDK version, relative to Target SDK version [duplicate]

Is there a way to have Xcode tell me when I'm calling a method that isn't available in the SDK of the minimum supported target?
For example, the method [NSURLConnection sendAsynchronousRequest:queue:completionHandler:]. This method is available on iOS5 and up. But my application's minimum target is iOS4.
If I use that method (sendAsync), I'd like Xcode to tell me that that method isn't available for the minimum target I'm trying to support.
I've tried putting __IPHONE_OS_VERSION_MAX_ALLOWED=40000 in the preprocessor settings, but that just triggers a bunch of Apple SDK errors that aren't helpful. (Probably because my active SDK is iOS5.1)
Is the only solution to get ahold of old SDKs and install them in Xcode?
Are there any easier solutions?
There is unfortunately no standard way of doing this. By setting the target OS to a lower number than the base SDK, Xcode will weakly link the libraries and frameworks. When doing that Xcode will not warn you for using methods that may not be available on the target OS.
You could temporarily set the base SDK lower, but that might not always work. Since you want to ignore most of the errors and warnings produced (because they are only called conditionally in your code path), and many warnings and errors are dependant on other error that you may need to resolve before the compiler will give any meaningful output.
I do not think there exist any static analysis tools for this, neither from Apple nor third party.
After doing some research, reading the Apple Doc about it, and trying a number of things. The solution is downloading an old Xcode DMG from Apple, grab the .pkg file for the same SDK as your deployment target and install it in your version of Xcode. Here's how:
Download older Xcode.dmg from Apple
Open the DMG
In Terminal, go into packages: "cd /Volumes/[DMG]/Packages; open ."
Find the SDK you want, something like iPhoneSDK_4.0.pkg
Install that package, but change the install directory to /Applications/Xcode/Contents/Developer
Restart Xcode if it was open.
Now that you have the same SDK as your deployment target, set your BaseSDK to the same. When you build you'll get warnings about missing methods. Your project may or may not successfully build with an older BaseSDK in a new version of Xcode, but that doesn't matter - you've just found the method calls you need to wrap in a feature check with respondsToSelector:.
As of Xcode 7.3, the compiler can now generate these warnings for you. All you need to do is set the -Wpartial-availability warning flag in the Build Settings, as described in this answer.

What is difference between libxml2.dylib and libxml2.2.dylib in iOS

Currently I am using libxml2.dylib to parse XML now I want to shift to libxml2.2.dylib. Then, what kind of changes I would do in configuration and coding?
Xcode 4.5 (and the iOS6 SDK for that matters, because the libraries available are dependent of the SDK, not the Xcode version) still has libxml2.2.dylib.
You should generally not link your application with a specific version of libraries like that, but better with a generic version like libxml2.dylib or libxml2.2.dylib.
but for the better result in ios6 libxml2.2.dylib. is used.Sometimes you will get linking errors or some unusual errors with lower version
If you want to know the difference
then follow this link-
iOS6 does not have libxml2.2.7.3.dylib.are there any substitutes?
if you are getting linking errors then you should add /usr/include/libxml2 is in your Header Search Paths in your Debug/Release configuration

how to collect code coverage on physical iPhone with Apple LLVM Compiler 3.0?

Does latest XCode's Apple LLVM compiler 3.0 support collecting code coverage data from physical iPhone machine? If yes, how to set it up?
Below gives a solution for gcc compiler. But I want to know whether this is a workable way for LLVM compiler 3.0. Because for our project, when switching from llvm compiler to LLVM gcc, we got some compiling errors, so we'd like to stick to apple's llvm compiler.
https://stackoverflow.com/questions/5101014/code-coverage-not-showing-results-using-xcode-
gcov/5140459#5140459
I found a solution for this.
http://www.gerardcondon.com/blog/2012/02/21/code-coverage-updates-for-xcode-4-dot-3/
And I can get the coverage data from device now. But met another issue when parsing the gcdata. The gcdata collected is marked as 4.2 version, while the gcno files generated by Apple Compiler 3.0 is 4.4. When using lcov which calls gcov(by default 4.2.1) to generate cov info file, it failed to parse the gcdata. I have tried to install a new version of gcov(gcc4.4.7), but still failed. I am still doing some investigation on this. Hope I don't need to write my own lcov. :-)
Thanks.

Resources