Post not yet marked as solved
my IOS version is 9.0, Now i want to get the unique value of the Device, i think of using IMEI, but i did some tests, i always cannot get the IMEI of the device,could you tell me other ways to know unique value of the device?
Post not yet marked as solved
hi all,i need to get crash logs programmatically when my application restarts after a crash. I know that if I enable a configuration given by apple, crashlogs are maintained in the device, which I can access using itunes / xcode. But i want to do it programmatically in my next app restart,Thanks in advance for any helpregardsjniba
Post not yet marked as solved
I read today in the Swift book:__weak typeof(self) weakSelf = self;
self.block = ^{
__strong typeof(self) strongSelf = weakSelf;
[strongSelf doSomething];
}
// Excerpt From: Apple Inc. “Using Swift with Cocoa and Objective-C (Swift 3.1).”When I saw '__strong' I got a bit concerned - in the past I had always used "typeof(self) strongSelf = weakSelf;, think the typeof made strongSelf strong.Yikes! Did I get it wrong all these years???
Post not yet marked as solved
Hello everyone, Is there a way to make an application widget like button appears all the time, even on the home screen. I want to make a floating button which will appear on top of all the apps. I want to build an application similar to assistive which will appear on home screen and on top of other apps.
Post not yet marked as solved
Dear Apple,The requirement of my application is that can delete cache/cookies in WKWebview. I tried somthing and it working as well in iOS 9 upwards. But there are no way to do it in iOS 8. Please let me know if there is a way to remove cache/cookies in iOS 8 or it can not remove?#Note: I want to remove cookies immediately, ie stay at WKWebview but click url to another site it will delete.Thanks,Phong Tran.
Post not yet marked as solved
Is it possible that AppA and AppB which are from the same developer share some local resources on a given device.For instance:Can the data written by App A, be read by App B (through Shared Defaults or any other mechanism)?The following link is to a similar question raised on stackoverlfow. I wanted to be certain thus, raising this question on Apple Dev Forums.https://stackoverflow.com/questions/9079378/shared-resources-for-two-apps-from-the-same-developer
Post not yet marked as solved
UIImageWriteToSavedPhotosAlbum work well in iOS 9/10but crashed in iOS 11what 's problem?NSData* imgdata = [NSData dataWithContentsOfFile:path]; if (nil != imgdata) { UIImage* saveImg = [[UIImage alloc] initWithData:imgdata]; if (nil != saveImg) { UIImageWriteToSavedPhotosAlbum(saveImg, nil, nil, nil); return 1; } }
Post not yet marked as solved
After spending a few hours to integrate swift files successfully to my Objective-C based iOS project, I face the next challenge now :In one of my Objective-C class header (Say, MyObjCClass.h), I do the forward declaration for MySwiftClass.In the respective .m file, I define an instance of MySwiftClass _swiftClassInstance.In the init method of MyObjCClass, I try to instantiate it as follows :
_swiftClassInstance = [[MySwiftClass alloc] init];
When I compile the code, I get 2 errors :Receiver 'SocketIOClient' for class message is a forward declarationReceiver type 'SocketIOClient' for instance message is a forward declarationI have already done following :Imported MyProject-Swift.h in the MyObjCClass.m file.Marked the swift class with @objc and openSo, what can be the reason for the issue?
Post not yet marked as solved
Will Apple continue to support it, or will we wake up one day to find that Swift is the only viable language?It's a serious question. Careers depend on it. I don't accept the "No comment" approach that Apple usually takes. It's cruel.I'm willing to put the time into learning Swift if I have to. I'm not going to do it if I don't. I want to know.Frank
Post not yet marked as solved
I have the following code:@implementation NSWindow (Coordination)
- (NSPoint)convertPointFromScreen:(NSPoint)point
{
NSRect rect = NSMakeRect(point.x, point.y, 1, 1);
return [self convertRectFromScreen:rect].origin;
}I get a compiliation warning:Category is implementing a method which will also be implemented by its primary classI know Swift has builtin preprocessor directives to detect SDK version, but don't know how to do this in objc. Any suggestions?
I am really struggling to find how one creates a file that doesn't already exist in Objective-C, and then use that file write data. In C, one uses a fopen command, usually wrapped in an if statement to catch a failure...if ((file_pointer = fopen(file_name, "wb")) == NULL) { fprintf(stderr, "could not create file.\n"); exit(EXIT_FAILURE);}You have created a file, and you have a file_pointer to use as you write data to your file ... fprintf(file_pointer, %d, someInt); So easy.With Objective-C and Xcode... I'm already getting the feeling like there's many ways to skin a cat... but I can't get any of them to work for me.I see some people use an NSData method...BOOL written = [dataBuffer writeToFile:destinationPath options:0 error:NULL]; //assumes a NSData file *dataBuffer and NSString *destinationPath.But this doesn't work, no file is actually created.I also tried:NSFileHandle *file;NSData *data = [...file = [NSFileHandle fileHandleForUpdatingAtPath: @"/tmp/filename.xyz"];[file writeData: data];But this also failed to create a file. There also seems to be a whole other trajectory using NSFileManager and a "createFileAtPath" method, which I ALSO could not get to work. HELP! What am I missing?
Post not yet marked as solved
Google's flutter almost matches the performance of Apple's Native and has the universal advantage of the whole platform, which tends to replace OBJC/Swift. What is Apple's opinion on the future development of flutter?
ps:and will apple gvie special treatment for developers who use flutter,or forbidden flutter in the future?if so,we should make a plan from now on.
Post not yet marked as solved
We are developing 8 SDKs, which are to be shared as XCFrameworks. The SDKs are interdependent on each other and also we have dependency on third party XCFrameworks which they have shared as Cocoapods.
Below is a simple demo of how the dependency graph looks, (@Apple - image attachment will be very helpful here)
A -> B, C
B -> D, E, F
C -> G, H
D, E, F -> H
H -> I, J
I -> K
here G and J are third party XCFrameworks. K is a third party FAT framework, written completely in Objective C. other letters denote the SDKs we are writing fully in Swift with Objective-C compatibility.
You can read the first line as A is dependent on B and C.
We started developing the SDKs by adding all these as Development Pods to a sample iOS Client. The only issue we faced was that even a small change in any of the pods required to clean build the entire project. We got around this setting "Legacy Build System" in Workspace settings.
When we approached release, we generated XCFrameworks and tried adding them to the Client.
We faced the following issue in almost all our frameworks. Because we had class names matching the SDK names, just like the old FAT framework.
‘FrameworkName’ is not a member type of ‘FrameworkName’ errors inside swiftinterface - https://forums.swift.org/t/frameworkname-is-not-a-member-type-of-frameworkname-errors-inside-swiftinterface/28962
Then we renamed all the frameworks and got struck with the following issue.
XCFramework requires to target iOS 13 for inter-framework dependencies with Objective-C compatibility - https://forums.swift.org/t/xcframework-requires-to-target-ios-13-for-inter-framework-dependencies-with-objective-c-compatibility-tested-with-xcode-11-beta-7/28539
We are supporting from iOS 9. So moving to iOS 13 is not even an option. We were not able to find the exact cause of this issue for so long even after exploring the generated .swiftinterface file which was throwing these issues. We found that issue could be because of using inheritance in the following way.
X is a Swift class, made Objective C compatible by inheriting NSObject. When we have another class Y from any of the other SDKs, inheriting X like below, this issue will be thrown.
For example, we have in Framework H.
@objc class X: NSObject { }
and then in framework D, which depends on H, we have
class Y: X { }
We removed it in one place and the issue resolved. We had this pattern all over the eight SDKs and we removed all those.
Then when we tried to build, we ran into the following issue.
'@objc' instance method in extension of subclass requires iOS 13.0.0.
We moved all @objc extension methods to the class. Those were mostly delegates and data source methods from common UIKit classes.
After facing these issues with XCFrameworks in the Client app, we decided to remove the development pod setup and manually drag and drop the xcodeproj files of all the SDKs into the Client app. Also we had to manually add the third party frameworks.
This way, some of the above issues can be identified during development instead of release time.
Now, the situation is that, when we make changes to any of the SDKs, it will be not be reflected unless we do a clean build, which takes a lot of time and is not desirable.
Even then, in some cases, the client app just throws Unable to import D or any other framework, in which we have made some changes. Then we to select that framework in the scheme, build it once and then select on to the Client App and build it again to see the change in our app.
This workflow is cumbersome and painful in the long run. Kindly suggest better alternative setups for developing multiple XCFrameworks.
Our next problem is when generating XCFrameworks, we need each SDK to use the XCFramework of the other dependent SDKs. For this, we have to work our way from the bottom most framework. Generate it, add to the one above it and then move on to the next.
This also feels like a burden in the long run. We seriously hope there are better ways to do it. Kindly suggest those.
We have not used Swift Package Manager (SPM) because most of our customers use Cocoapods for dependency management and the remaing few just drag the frameworks manually into their projects.
If SPM can act as a magic pill and solve all these issues at once, then we can consider using it.
In the OC project, iOS14 WidgetKit target was added, but consistent error
Cannot find type "ConfigurationIntent" in scope,
type 'Provider' does not conform to protocol 'IntentTimelineProvider'
What is strange is that after adding a new OC project, the compilation is successful,
Tool: Xcode12-beta & Simulator
How to get access to old projects?
Post not yet marked as solved
I've inherited a large project. Digging around the codebase has been tough because "Jump To Definition" isn't working consistently.
The codebase is almost entirely in Objective-C, and I'm seeing usage of the target-action pattern like:
// ViewController1.m (void)viewDidLoad {
	[super viewDidLoad];
	UIButton *button = [UIButton new];
	[button addTarget: self action:@selector(selected) forControlEvents: UIControlEventTouchUpInside];
}
(void)selected {
		NSLog(@"selected in View Controller 1");
}
When I command + control + click on the "selected" method name inside of the @selector attribute, it will jump to the definition of the wrong method. The incorrect method has the same signature: it is named "selected" and takes no arguments. But that implementation is in an unrelated class in a different source file.
My first instinct was that this is a bug when using @selector, but I was not able to duplicate in a simple sample project - two source files that have a selector with the same name will behave as expected when trying to Jump to Definition. I thus believe this to be an issue due to the nature of the inherited project - it's very large, and there are over 200 existing warnings. It takes a very long time to index. I wonder if that has anything to do with it?
Are there any tips for dealing with "Jump to Definition" not working in a legacy project? I plan on fixing the warnings at some point, but if there's another thing I can do in the meantime it would be helpful as I familiarize myself with the code.
Post not yet marked as solved
Hi,
In Xcode 12 beta I can see warning - the Legacy build system will be removed in a future release.
How can I know what Xcode version it will be removed?
Thanks!
Post not yet marked as solved
Hi, I recently got myself a Macbook Pro and noticed that the CPU on it tends to run really hot under nominal loads which is leading to thermal throttling.
So, I started looking into ways I can get the CPU die temperature and modify the current fan speed curve. My goal is to create a background process that basically overrides the current default of 0 rpm for temperatures below 42 C and reverts to system default for higher temperatures.
powermetrics command gave me the temperature and fan speed information that I needed. But, I haven't found anything that would allow me to change the fan curve or set a particular rpm value via a terminal command or hardware level APIs. Can anyone please provide me some information around it?
Post not yet marked as solved
In the Xcode 12 betas I'm seeing an issue with importing Swift modules with @objc annotations.
Given two Swift modules which expose classes of the same name:
// FrameworkOne
@objc
public class Thing: NSObject {
		public override init() {}
		@objc
		public func doSomething() {}
}
// FrameworkTwo
@objc
public class Thing: NSObject {
		public override init() {}
		@objc
		public func doSomethingElse() {}
}
And if I have imported both of the frameworks into an ObjC file and interact with the classes in either of them:
#import <Foundation/Foundation.h>
@import FrameworkOneObjC;
@import FrameworkTwoObjC;
@interface Example : NSObject
@end
@implementation Example
(void) example
{
		Thing *thing = [[Thing alloc] init];
}
@end
Then I'm seeing this build error:
'Thing' has different definitions in different modules; first difference is definition in module 'FrameworkOne.Swift' found method name 'doSomething'
But in 'FrameworkTwo.Swift' found method name 'doSomethingElse'
Is this expected behaviour? If so, is there any way to opt out?
In my case FrameworkOne & FrameworkTwo are external dependencies, and I'm unable to change the names of the classes.
Post not yet marked as solved
Hi,
I am writing a Swift framework that primarily serves as a wrapper for a linear algebra library written in C. The framework therefore is a mixture of Swift and Objective C (the Objective C part is there to serve as a bridge to allow the Swift code to talk to the C
I have reviewed the documents on Clang modules and looked at various code examples on the Web. However, I am still not finding a clear path and have had difficulties getting the code to compile (I am also unclear what the official recommendations are for achieving the goal I desire). Here are a few questions:
1) Is it good practice to create mixed languages frameworks that are a combination of Swift and Objective C++? If so, are there examples available that show best practices? If not, what is a workaround?
2) I don’t want to expose the Objective C++ part of the code to the consumer of my framework. I am not clear how to do this. I have read about private modules. However, I am unclear about how to properly use private modules in this context and again lack clear examples.
3) What is the recommended practice when creating module.map files in XCode when XCode itself generates a default module.map file when building a framework? Again, there are some examples on the Web, but I am unclear whether they are correct an none of them explicitly suits my goals.
4) Where is the official documentation on how to properly use module.map files in XCode especially with respect to building frameworks that rely on both Swift and Objective C++?
5) Although I know that if this weren’t a framework, I could create a bridging header to allow Swift to talk to Objective C++. However, in the case of a module there is an umbrella header. My understanding of the umbrella header is that it pertains to code that will consume the framework, not for other code in the framework itself. Can you somehow combine an umbrella header and a bridging header in a framework?
Thanks in advance
Post not yet marked as solved
Hello! I'd like to ask, is there any method how could I detect whether an application started to share or record my screen? It seems there isn't any notification from the system but maybe it's possible to detect somehow. Programmatically or from the CLI.