transitioning to ios8 parse issues - ios

I am moving my app from xcode 5 to xcode 6 (sdk 8.0) and the entire app is crashing from random parse errors.
I have searched stack and other sites for answers, but most are just saying missing an #end or a bracket but with my code I am not noticing it.
Here is an example of some code erroring out below:
#import <UIKit/UIKit.h>
#interface UITabBar (FlatUI)
- (void)configureFlatTabBarWithColor:(UIColor *)color; UI_APPEARANCE_SELECTOR
- (void)configureFlatTabBarWithSelectedColor:(UIColor *)selectedColor; UI_APPEARANCE_SELECTOR
- (void)configureFlatTabBarWithColor:(UIColor *)color
selectedColor:(UIColor *)selectedColor;
#end
Here is a pic of that same code with the IDE errors:
Many other files have the exact same error. Any pointing to the issue would be appreciated. I have just updated to Xcode 6 and have been pulling my hair out.
Thanks

Related

Big Nerd Ranch UIKit import

Why is that when I follow Big Nerd Ranch 4th edition I always need to import #import <UIKit/UIKit.h> for any class that contains UIView, UIViewController, CG stuff but the code in the solutions is somehow working without it? Is there any Xcode compliance set up that can be made to make it work well with just #import <Foundation/Foundation.h> import?
For example, in 12th chapter, where they create TouchTracker app, their code is working just fine with:
#import <Foundation/Foundation.h>
#interface BNRLine : UIView
#property (nonatomic) CGPoint begin;
#property (nonatomic) CGPoint end;
#end
However, when I copy this code to my project it does not work without additional #import <UIKit/UIKit.h> line.
They probably use .pch imports. Basically it means that before every source file it will be imported and executed. This tutorial seems like a one you could see whats going on.
They may have additional imports inside a precompiled header file with a .pch extension. You can search for this file in their project.
In Xcode, if you command-click on the import statement you can bring up the detailed list of imports and that should answer any question you may have about what is being imported.

Unidentified box appears at run time

This one has me completely stumped. I'm resurrecting a graphics project that I did a little over a year ago in iOS 6 and XCode 4. It worked just fine then. Now I'm trying to run it in iOS 7 and XCode 6. My UIViewController looks like this in the storyboard, which is how it is supposed to look:
But when I run it, I get this. Notice the strange blue and gray box in the bottom center. I have no idea where this comes from!
I have literally commented out every line of code, so that the implementation file looks like this:
#import "PerspectiveViewController.h"
#implementation PerspectiveViewController
- (void)viewDidLoad
{
[super viewDidLoad];
}
#end
The interface file is like this:
#import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>
#interface PerspectiveViewController : GLKViewController
// all of the outlets for the controls, but nothing else
#end
Does anyone have any idea where that blue and gray box is coming from? There used to be a UITabBarController involved, but I stripped that out. Maybe there is still something left over?
The easiest way to debug views which you don't expect to be there is by using a tool like Xcode's UIView inspection or Reveal. You can see many more examples and some discussion in this question: How do I inspect the view hierarchy in iOS?

Swift dismiss/unwind to modals not working in xcode 6 beta 3

I've been trying to dismiss a modal using Storyboards but from reading an old beta release it seems those are broken. I tried adding the header to allow me to do unwind from the Obj-C side but still nothing.
this is in my swift file
#objc(BeersViewController) class BeersViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
#IBAction func unwindToBeersMainViewController(sender:UIStoryboardSegue) {
println("hello world");
}
}
this is in my header file
#import <UIKit/UIKit.h>
#interface BeersViewController
- (IBAction)unwindToBeersMainViewController: (UIStoryboardSegue *)segue;
#end
I then in storyboard dragged from the button to exit. When I try to run it in the simulator it just does nothing.
Any other ideas? I copied this from another thread on here but didn't seem to work past getting it to show up from exposing Obj-C to swift
In Xcode 6 Beta 4 this bug has been resolved. I had the same problem in one of my projects. After the upgrade everything worked fine :-)

App display error in iOS7 Xcode5 in MKPolyline

I am updating my old app to iOS7. In that app i am displaying line over map using MKPolyline.
its working fine in iOS6 and Xcode 4.6 but doesnt work in my new xcode and displayed error on the codes of MKPolyline.
Is apple has change MapKit Framework. what should i have to update?
On the MKPolyline codes display this error
Unknown type name 'MKPolyline'
But if i Control-Click the MKPolyline than it will take me to the MapKit class.
First of all i think this is the problem with the #import code. You said that this is an old app. please show us the #import code for mapkit framework.
If it like this:
#import "MapKit/MKMapView.h"
than change it to this:
#import <MapKit/MapKit.h>
I think this will solve the unknown class error. if still its display error than use MKGeodesicPolyline instead of MKPolyline. You can find nice explanation here.
Hope it help.

iOS MKMapView not displaying map in the simulator

I've just started learning iOS development for iPhone, and following a couple of examples regarding how to display a mapView with the MapKit Framework, I found that google map tiles are not displayed, I only get an empty view (grey tiles), at least in the iPhone simulator (I haven't tried on a device).
I also get this error message:
/SourceCache/GoogleMobileMaps_Sim/GoogleMobileMaps-363.1.2/googlenav/mac/Loader.mm:235
server returned error: 403
I found solutions for similar problem when developing for Android, but not for iOS. Could somebody help me with this issue? Adding the MapKit framework to the project is supposed to be enough to get this working, or maybe am I missing some extra settings that are not mentioned in the tutorials I've followed?
Thanks!
This is the simple sample code I used:
// ViewController.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#interface ViewController : UIViewController
#property (strong, nonatomic) IBOutlet MKMapView *mapView;
#end
// ViewController.m
#import "ViewController.h"
#implementation ViewController
#synthesize mapView=_mapView;
- (void)viewDidUnload {
[super viewDidUnload];
[self setMapView:nil];
}
... more methods...
And in .xib file, I connected a MKMapView to the file's owner mapView outlet. And at this point, according to the tutorial, I am supposed to be able to see a default US map when running the simulator, but I'm always getting the error I posted before at the debug area, and map view displays only the grey empty grid.
I had the same problem - my UIMapView was only showing the grid, but not the actual map. I quit the simulator and then launched the project again - now it showed the map! It seems like iOS simulator does loses the connection sometimes, even though you might be connected on your computer.
Thank you all for your input!
Have you set the delegate to files owner(self)?
Also have you included mapkit framework and the related header files?
For whatever reason, my iOS simulator sometimes just loses connection to the internet (my computer has connection, but the simulator doesn't recognize it). Once I quit and relaunched my simulator, my maps started showing.
The iOS simulator comes with the official maps app included. Open that and verify that it can get tiles, it could be a network issue. Without any code, outlets, delegates or anything the map should show map data.
An empty map view (grey tiles) as you've described I have seen on the iPhone simulator and a device when trying to specify a map region (see code below for example), however the user has not granted access to their location in app settings. Removing this piece of code when running on the simulator resolved the issue.
MKCoordinateRegion mapRegion;
mapRegion.center = self.mapView.userLocation.coordinate;
mapRegion.span.latitudeDelta = 0.02;
mapRegion.span.longitudeDelta = 0.02;
[self.mapView setRegion:mapRegion animated: YES];
In case anyone looking for the solution. Network issue is solely responsible for this issue. Make sure your simulator has network connection and if it is able to load default apple map, you're good to go.
This issue is a little bit tricky because it involves lots of cases, but for me, it was not loading because of the network monitoring application, eg. Charles, make sure that you have an internet connection and it's unmonitored
I solved this problem by connecting to WIFI with my phone. I didn't have a SIM card installed in my phone, so it just showed the tiles. Just make sure you have network connection.

Resources