Tag: objective c

Embedded Content Contains Swift Code with Xcode 8 Beta

I am developing a command line macOS application(with Objective-C) which uses other 3rd party Swift libraries. I am retrieving an error says “dyld: Library not loaded: @rpath/libswiftAppKit.dylib“ Previous answers recommend to set “Embedded Content Contains Swift Code” flag to true. However, this flag is missing with Xcode 8 beta. I have tried “ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES“, which i […]

How to properly implement lazy instantiation with an @IBOutlet property in Swift

I am Learning iOS Development with Big Nerd Ranch’s latest iOS book. I have chosen to implement their apps in Swift. In one of their apps, they have the following code in Objective C: – (UIView *)headerView { // If you have not loaded the header view yet… if (!_headerView) { // Load HeaderView.xib [[NSBundle […]

iOS: UICollectionViewCell auto adjust size according to screen size

I am trying to create 10 cells in the collection view(same size as the screen). When I run my app in iphone5s simulator, the view contains exactly 5 cells. But when I switch to iphone6p simulator, the view contains more than 5 cells. How should I adjust the cell size so that the number of […]

Invalid Binary Or Invalid Swift Support

After I send my app for approval to the app store I get the message ‘Invalid Binary’ in the iTunes Connect. Then I get the following message in an email from Apple: Invalid Swift Support – The bundle contains an invalid implementation of Swift. The app may have been built or signed with non-compliant or […]

Swift: How to Open local pdf from my app to iBooks

I was in objective-c before. and this code below in objective C is working fine: in. h @property (retain)UIDocumentInteractionController *docController; and in .m NSString *path = [[NSBundle mainBundle] pathForResource:@”book” ofType:@”pdf”]; NSURL *targetURL = [NSURL fileURLWithPath:path]; docController = [UIDocumentInteractionController interactionControllerWithURL:targetURL]; if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@”itms-books:”]]) { [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]; NSLog(@”iBooks installed”); } else { NSLog(@”iBooks not […]

Overriding method with selector '***' has incompatible type '****' parse

I am using Parse. I am trying to query a list of the object in the database. I am using swift programming language. I think the reason cause this error is because obj-c and swift bridge. Can anyone help me ? Here is my code. override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { […]

app with Objective-C and swift code crash at launch in release mode, debug mode fine

My project is Objective-C based, and have some third party swift code. The app runs fine at debug mode, however, when I archive the app as release mode, the app will crash at launch screen. Set swift optimization level to None still has the same issue. I have crashlytics 3.7 installed, but it crashes at […]

Programmatically open NSWindow in another Desktop (Space)

In my OSX Project I want to: identify the Desktop (one of the expose Spaces) where a NSWindow resides; open a NSWindow in a determined Space, not only on current Space. Is there a way to do these simple tasks? Exploring the documentation (NSWindowController, NSWindow, NSScreen) I can’t find anything regarding multiple Desktop Management. Thanks […]

Proximity sensor in Swift (from Objective-C)

I’m a relatively new user to swift and now, I need to take advantage of the proximity sensor of an iPhone. I don’t matter the distance, but I want to know when something is near the iPhone. So I found this code in Objective-C that worked, but I need it in Swift. I have tried […]

How to call a factory method of an Objective-C class from Swift?

I have an obj-c class that uses a factory method to instantiate itself as a singleton. I added that class to my Swift bridge header and want to call this factory method from a swift class. However, XCode won’t let me. The obj-c code is: @interface MOAssistant : NSObject { … + (MOAssistant *)assistant; @end […]