Xcode not compiling with the correct ios SDK version - ios

I have a local pod which mocks a bluetooth device. In it there is this line...
CBATTRequest *request = [CBATTRequest new];
Since upgrading xcode, the build errors out saying 'new' is unavailable. Clicking through confirms that in the ios 14.5 SDK, this method (init actually) is indeed marked "unavailable"
/*!
* #class CBATTRequest
*
* #discussion Represents a read or write request from a central.
*
*/
NS_CLASS_AVAILABLE(10_9, 6_0)
CB_EXTERN_CLASS #interface CBATTRequest : NSObject
- (instancetype)init NS_UNAVAILABLE;
...the thing is though, my simulator is set to ios 12.4 and the pods deployment target is set to 12.0.
As stated, this was compiling before I upgraded xcode. The pod dev subteam says it works on ios <= 12.4.
So why is it now compiling against 14.5 rather than 12.x? How do I get it to compile against 12.x?

In Xcode 12.5 init NS_UNAVAILABLE makes automatically unavailable new.
I don't know how it was working correctly with actually unavailable initializer, but now you had to find correct way of retrieving reference to valid CBATTRequest object

Related

Xcode 10.2 Use of undeclared identifier error when accessing FrameworkSDK

I have just upgraded from MacOS Sierra to Mojave and from Xcode 10.1 to 10.2
Exactly same app (given in a zip) builds on a MacOS Mohave machine in Xcode 10.2 but it doesn't build on mine machine.
I tried restart, removing derived data etc:
#import "ViewController.h"
#import "MyFrameworkSDK/MyFrameworkSDK-Swift.h"
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSString *applicationId = [[NSString alloc] init];
applicationId = [MyFrameworkSDK exposedMethod]; // here the error is triggered: Use of undeclared identifier 'MyFrameworkSDK'
printf("%s", applicationId);
// Do any additional setup after loading the view.
}
#end
Framework has been imported correctly, included in Linked frameworks and libraries, Bitcode is set to No, Frameworks path set etc, I repeat: it's exactly same project that on another machine works.
I tried even a re-install of Xcode. It didn't work.
Question:
What can be the cause of this? Other local cache, Xcode issues, any privacy set for framework not to be public?
I lost about 1 day with this issue.
Any help would be greatly appreciated.
Update:
It seems there might be some privacy limitations set for framework, the person that is able to access it is in the development team of the framework. If he changes Xcode team to none or another team same error shows up on that machine too.

Switching to Xcode 10 causes `UserNotifications.framekwor dyld: Library not loaded crash` for iOS9

We have an app that is working properly with the UserNotification.framework being linked as required framework in Xcode 9. Everything works smooth here.
Now we are switching to Xcode 10. But there linking this framework as required leads to
dyld: Library not loaded: /System/Library/Frameworks/UserNotifications.framework/UserNotifications
Referenced from: /var/containers/Bundle/Application/1D41BD68-9B88-4D5D-B7AB-0D1C31979964/App.app/App
Reason: image not found
If I switch it to optional push notification (via Intercom) won't work anymore.
What is the reason? How can we fix that? Why is it even working in Xcode 9?
Update #1
using
#import UserNotification
does not fix it
Update #2
Its fixed by importing and using it actually (in AppDelegate.m) like this
UNNotificationRequest* unr = [UNNotificationRequest alloc];
unr = nil;
Why?
It is related to the same issue I have experienced already.
CABTMidiCentralViewController used in Storyboard only working if using code reference
Update #3
More generic question
Xcode sometimes removes linked library
UserNotification SDK is available on iOS 10+, Try to update the deployment Target to iOS 10 +
Can your please try removing the framework and adding that again ? I just created a new project this framework added in Xcode 10 and was able to run in the device without any errors.

Xcode UI Testing: lldb error "only available on iOS 9.0 or newer"

Background
I have a fairly detailed (around 2000 lines of swift code) automation framework built with Xcode 7.3 and Swift for our iOS app.
Up till a recent point, I was able to use lldb to build my framework i.e
insert breakpoint and run code up till that point
use po XCUIApplication().debugDescription and expr bla bla to build the logic
repeat
Problem
Pretty much all of a sudden, I now encounter the following error whenever running anything inside lldb's console:
(lldb) po XCUIApplication()
error: <EXPR>:2:1: error: 'XCUIApplication' is only available on iOS 9.0 or newer
XCUIApplication()
^
<EXPR>:2:1: note: add 'if #available' version check
XCUIApplication()
^
<EXPR>:2:1: note: add #available attribute to enclosing instance method
XCUIApplication()
^
<EXPR>:2:1: note: add #available attribute to enclosing extension
XCUIApplication()
^
<EXPR>:10:9: warning: initialization of variable '$__lldb_error_result' was never used; consider replacing with assignment to '_' or removing it
var $__lldb_error_result = __lldb_tmp_error
~~~~^~~~~~~~~~~~~~~~~~~~
Notes
Googling and research has not gotten me anywhere significant.
The one relevant thread I found was in the fastlane project. Unlike that comment, mine is a UI Test target.
Also, the test target's "iOS Deployment Target" is set to iOS 9.2 (in case that helps).
To the extent I remember, I haven't changed anything significantly in recent times.
My device is (and has always been) iOS 9+.
What could be going wrong?
Update 20 May 2016
Some exploration based on the answer below: https://stackoverflow.com/a/37335950/682912
The issue happens only on real devices. Simulators do not face this problem.
On real device (iPhone 6S+, iOS 9.2.1), I did a full reset of Content and Settings. This did not fix the issue.
This is a bug in the debug agent installed on your device. These are bound to the iOS version, so it probably happened when you upgraded your device. Anyway, please file a bug with http://bugreporter.apple.com.
If I'm right about the problem, it should only happen when debugging to the device, not on the simulator. That might allow you a temporary workaround till the bug gets fixed.
Double check your .xcconfig with your test target or any other means that may set your IPHONEOS_DEPLOYMENT_TARGET to lower than 9.0.
Since UITest is only available on iOS9.0 or later, change IPHONEOS_DEPLOYMENT_TARGET to 9.0+ should fix the issue.

SDWebImage on iOS 8.1 weird compile error

When I try to run project on real device (iPhone 5 and 5S with iOS 8.1) I get following compiler errors:
// ARC Semantic Issue - myPath/SDWebImage/UIImage+GIF.m:26:42: No visible #interface for 'UIImage' declares the selector 'initWithData:'
animatedImage = [[UIImage alloc] initWithData:data];
// ARC Semantic Issue - myPath/SDWebImage/UIImage+GIF.m:47:34: No known class method for selector 'animatedImageWithImages:duration:'
animatedImage = [UIImage animatedImageWithImages:images duration:duration];
// ARC Semantic Issue - myPath/SDWebImage/UIImage+GIF.m:155:21: No known class method for selector 'animatedImageWithImages:duration:'
return [UIImage animatedImageWithImages:scaledImages duration:self.duration];
My project was working normally until this morning. I changed nothing, just tried to debug on real device. The strangest part of that is I can run/debug on emulator (on any iPhone device with iOS 8) without any error.
When I downgrade deployment target from 8.1 to 8, XCode can successfully build and run the project for emulator and real device.
I tried completely removing SDWebImage and adding it back but didn't solve the problem.
I am using XCode 6.1 (Swift) and iOS 8.1 SDK on my project.
What might be causing the problem that suddenly appeared?
As has been said on other questions, the new "ModuleCache" directory within DerivedData has been responsible for many of these problems.
Here's the path:
/Users/[user]/Library/Developer/Xcode/DerivedData/ModuleCache
Simply delete the module cache, or the entire derived data directory as many have been doing on a daily basis for the last few iOS SDK iterations.
I came here looking for a different answer to a similar problem since this solution isn't fixing my current problem, but I figured I would share this as it will fix many of these.

Crash with RevMob on iOS

I recently upgraded the RevMob SDK of my cocos2d project, using Xcode 4.5. Below is a code to show what I have done:
#import <StoreKit/StoreKit.h>
#import <RevMobAds/RevMobAds.h>
- (void) applicationDidFinishLaunching:(UIApplication*)application{
[RevMobAds startSessionWithAppID:#"my app id"];
//some code here...
}
On running the project, on device or simulator, the app crashes with this error:
+[RevMobAds startSessionWithAppID:]: unrecognized selector sent to class
However, one thing which might be useful, is that when I added the RevMob framework to my Xcode, it gave me compilation errors (using LLVM GCC 4.2) for which I followed this answer.
This method was included in version 5.0.0 (RevMob changelog), so make sure that the framework that you are using is at least 5.0.0.

Resources