Which compiler settings are changed when I change target device? - ios

I have an iOS project that builds fine for simulators, but which has compiler errors when built for a Generic Device or when I try to run on a real device through Xcode. NOTE: actual compiler errors, not linker or deployment errors. The errors are to do with mismatched types in typedefs - as if it's including headers from a different SDK, or has different preprocessor defines.
My question is - what compiler settings are changed when I change target device in the Xcode UI and where can I view the differences? I cannot see any differences when I look at the project settings and change the target device - specifically the deployment target version and SDK version appear unchanged.
The project used to build fine with any of these target devices under Xcode 7, but does not under Xcode 8. I suspect this is down to the version of the SDK that comes with Xcode. But for it to work with some target devices and not others it has to be changing compiler settings. This should be really simple to fix, if only I could see what changes it's making!
Here's the line (in my code) which fails to compile:
typedef void* IOSurfaceRef;
And here's the error message:
error: typedef redefinition with different types ('void *' vs 'struct __IOSurface *')
Please note I don't want help fixing the error or advice on what it's trying to do - I know it's not good. I'd just like to know which compiler settings are changed by switching target device.

It fails because CGBase.h contains this code:
#if !TARGET_IPHONE_SIMULATOR
typedef struct CF_BRIDGED_TYPE(id) __IOSurface *IOSurfaceRef __attribute__((swift_name("IOSurfaceRef")));
#endif
When you are building for a device the #if !TARGET_IPHONE_SIMULATOR preprocessor directive is true, so your code has two typedefs for IOSurfaceRef with conflicting types.

Related

Error - "Class is unavailable : Cannot find Swift declaration for this class", while building app on iPhone 4s (iOS 9.3)

My App has been created under iOS 10.2, and when I'm trying to create a build of the app to run on iPhone 4s (iOS 9.3).
I'm using two frameworks :-
ViewModelExtensions.framework (github.com/jozsef-vesza/ExpandingTableView/tree/master/ExpandingTest/Carthage/Checkouts/ViewModelExtensions/ViewModelExtensions)
ExpandingTableView.framework (github.com/jozsef-vesza/ExpandingTableView) in my project.
I'm not able to create a built for my project. Its giving me 3 main errors as follows :-
ExpandingTableViewController is unavailable: cannot find Swift declaration for this class
ExpandingTableViewCell is unavailable: an not find Swift declaration for this class
Use of undeclared type ViewModelType
The thing is its perfectly running on all simulators supporting iOS 10.2. What shall I do ?
Here is the screenshot.Screenshot
My Code - Project
Reason your code not running is because one of the framework you have added Expandable tableView has minimum target requirement specified as 10.2 :) So you can not run it on anything less than iOS 10.2 :)
Now you can't change the frameworks minimum target, so change your projects development target :)
Solutions :
Change Development target to 10.2 in your project
Or get rid of the framework and find something that has minimum target as iOS 9 :)
We'll need more detail (code, did you use pods, etc.)
However, this looks like a problem with the referenced frameworks (I assume you've imported UIKit at least). I suspect (without seeing your code) that you're getting errors next to the frameworks above at build time. If so, there are a few things to check:
Make sure if you used cocoapods, you are using the 'workspace' and not the 'project' file.
Check and see if your "target membership" (you can see this in the inspector to the right of your class code) is set to the proper targets (i.e. your app - and probably nothing else at this point)?
If these checks fail, try re-installing the frameworks (again, depends if you used cocoapods or embedded them via Xcode (point 1 above)).

Cordova 3.4, Xcode 5.1 and iOS 7.1

I was building my project perfectly but after updating iOS to 7.1, I was then forced to update Xcode 5.1 and now I'm getting error and warning messages:
4S 7.04 – builds – no error or warning messages
5S 7.1 – doesn’t build – mixture of error and warning messages:
26 x Value conversion issue
Implicit conversion loses integer precision:
12 x Linker build errors
Then I do the steps outlined in this blog post to remove linker errors – delete all conditional architecture and make sure arm64 is in the all the projects and targets: http://shazronatadobe.wordpress.com/2014/03/12/xcode-5-1-and-cordova-ios/
4S 7.04 – builds – warning messages:
12 x Format String Issue
Values of type ‘NSInteger’ should not be used as format arguments; add an explicit cast to ‘long’ instead
5S 7.1 – doesn’t build – warning messages:
26 x Value conversion issue
Implicit conversion loses integer precision:
12 x Format String Issue
Values of type ‘NSInteger’ should not be used as format arguments; add an explicit cast to ‘long’ instead
I think the warning messages are now affecting the badges as they are not reseting correctly
Are the warning messages relevant? And would they likely be affecting resetting the badges?
Okay, so I have gone back and forth with this for a while and I've got a few possible solutions for you.
Make sure in Xcode you are selecting both your project and the target within that project also and make sure your settings are setup like the forum post you mentioned.
Make sure you also change the settings on the CordovaLib project as well. Both the project and the target need to be changed, but it's slightly different. you also need to add i386 as a supported platform in the cordova project, but is not needed in yours.
Other things to check are.... Make sure you are using the right kind of provisioning profile... ie. Distribution for production phone builds and Development for team builds and testing on your device.
Check and make sure you are not missing a library you needed to import. You can usually tell if you are missing a library by the mach-o linker errors though.
Example: I removed a plugin from my phonegap project via command line. Well then I added it back and my project would not build using the 'phonegap build ios' command. I had to open the XCode version of my project within xcode then re-import the AudioToolbox library under the Linked files and then I was able to build again via command line.
Good luck, comment here if you need more help.
Please check my attached images might be it will helpful for you.

build error on iOS 7.1 - Zxing

Updated to XCODE 5.1/IOS 7.1 and tried to build my project which included Zxing library.
Getting the following error:
/Zxing/cpp/core/src/zxing/ChecksumException.h:3:9: '__CHECKSUM_EXCEPTION_H__' is used as a header guard here, followed by #define of a different macro
Error is occurring for the following code,
#ifndef __CHECKSUM_EXCEPTION_H__ //this line causes the error.
#define __NOT_FOUND_EXCEPTION_H__
.....
.....
#endif // __CHECKSUM_EXCEPTION_H__
Everything was perfect before the xcode 5.1 update.
I suspect recent migration of IOS 7.1 to support 64-bit architecture causes this error but i'm not sure.
I tried to remove 64-bit support from the Zxing library using this link but still it's not working.
Any help or suggestion would be greatly appreciated.
Looks like there are some underground compiler settings changes in XCode 5.1.
So to fix this issue you need add -w flag to ZXingWidget Other Warning Flags.
This flag completely disable all compiler warnings.
Select ZXingWidget framework.
Select ZXingWidget target in ZXingWidget framework.
Press Build setting tab and type "other wa" in search.
Add -w parameter flag to Other Warning Flags.
Here is a screen with steps how to add this flag:

Facebook SDK giving unused variable compile errors in Xcode 5.1

I'm getting a lot of unused variable errors after updating to the new version of and Xcode 5.1.
Compiler is saying unused variables are errors, and checked the compiler settings that i didn't modify treating warning as errors.
This only happened after I updated to Xcode 5.1
There seems to be indeed an issue with Facebook iOS SDK and compiling on Xcode 5.1 even if compiling it by itself.
I opened a bug in the Facebook support system:
https://developers.facebook.com/x/bugs/1449419898627543/
As a temporary workaround - you can fix it by turning off treating warnings as errors ( a very good practice by itself btw I use for our SDK) by:
1. Open the Facebook proj file (or the project inside an existing project
2. Go to build settings of the entire project
3. Change the "Treat Warnings as Errors" field from YES to NO.
This will let you compile it even with these warnings - but do be alert for an updated sdk in the coming days.
The problem was that we were unintentionally compiling for 64bit in the internal compiler settings somewhere inside our scripts. Please be aware.

Adding ShareKit to existing iPad app gives strange syntax errors

I am trying to add ShareKit support to an existing iPad App. I got ShareKit code from http://getsharekit.com/. I added the ShareKit folder to the App per instructions and compiled it. Now I get syntax errors on previously working statements such as:
Statement in Constants.h file:
extern NSString * const kSupportURL;
Error:
Unknown type name 'NSString'
If I remove the ShareKit files it compiles and runs without any errors.
The project is being compiled under Xcode 4.2. Base SDK is "Latest iOS (iOS 5.0)". Target iOS Deployment target is "iOS 3.2". C Language Dialect is "C99 [-std=C99]"
Don't know how you linked your frameworks, but that particular message would appear if you weren't linked to Foundation.framework or if you forgot to #import foundation

Resources