Skip to content
This repository has been archived by the owner on May 9, 2018. It is now read-only.

Version 1.6.0 don't work with cocoapods. (Offline MBTiles) #578

Closed
cadizjavier opened this issue Feb 5, 2015 · 11 comments
Closed

Version 1.6.0 don't work with cocoapods. (Offline MBTiles) #578

cadizjavier opened this issue Feb 5, 2015 · 11 comments

Comments

@cadizjavier
Copy link

I just try to upgrade one of my projects to the latest version released (1.6.0) and it stops working raising an exception.
The isolated scenario is simple. I start a new project, install mapbox trough cocoapods, write the most basic code to start running a simple map and an exception is raised at the RMConfiguration file

`NSAssert(_accessToken, @"An access token is required in order to use the Mapbox API. Obtain a token on your Mapbox account page at https://www.mapbox.com/account/apps/.");`

Then i download the mapbox-ios-sdk sample and update the mapbox binary library to the 1.6.0 version (the example is using 1.5.0) and everything works fine, even with the same simple code to render a map. The problem happens when using cocoapods.

I'm using the the offline mbtiles feature (in the official example the offline layer - 2nd tab).
Running the latest stable XCode 6.1.1 and the latest stable cocoapods 0.35

@JohnRbk
Copy link

JohnRbk commented Feb 5, 2015

Can you check to see if your code is setting the access token? Here is the property you should set https://www.mapbox.com/mapbox-ios-sdk/api/Classes/RMConfiguration.html#//api/name/accessToken

@cadizjavier
Copy link
Author

No, my code isn't setting the access token since the app is completely offline. Just for the record this works great with version 1.5.X and ask me for a token when using 1.6.0
BUT if using the binary distribution (not cocoapods) suddenly all works great.

I try to describe an isolated scenario.

  • Download the mapbox ios sdk official example
  • That example is using the 1.5.0 version. Update the binary version with the latest. Replace the files and run the project. Everything works fine. Not asked for a token.
  • Now, copy and paste the same project and in this new one delete the mapbox binary distribution and install the latest mapbox ios sdk (1.6.0) through cocoapods. Run the project and you will see that is asking for a token now.

Just the same project. One with binary distribution and one using cocoapods.

@charlesa101
Copy link

Is accesstoken now required for offline tiles ?

@friedbunny
Copy link
Contributor

Two issues here:

I believe a token shouldn't be required for offline tiles, this seems like a small remnant of API v4 support from before we could rely on accessToken always being set.

Map/RMMapboxSource.m (L361-L364):

+ (BOOL)isUsingLargeTiles
{
    return ([[RMConfiguration sharedInstance] accessToken] && [[UIScreen mainScreen] scale] > 1.0);
}

Here's the crash stack:

2015-03-10 15:15:52.384 MB Example[2937:6142484] *** Assertion failure in -[RMConfiguration accessToken], /Users/jason/Documents/Mapbox/mapbox-ios-example-master/Pods/Mapbox-iOS-SDK/MapView/Map/RMConfiguration.m:140
2015-03-10 15:15:52.391 MB Example[2937:6142484] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An access token is required in order to use the Mapbox API. Obtain a token on your Mapbox account page at https://www.mapbox.com/account/apps/.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000107474b95 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010710cbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x00000001074749fa +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x00000001057d5b0f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
    4   MB Example                          0x000000010510c263 -[RMConfiguration accessToken] + 195
    5   MB Example                          0x000000010514a6a9 +[RMMapboxSource isUsingLargeTiles] + 73
    6   MB Example                          0x000000010513847d -[RMMapView setTileSourcesMinZoom:] + 157
    7   MB Example                          0x0000000105125014 -[RMMapView performInitializationWithTilesource:centerCoordinate:zoomLevel:maxZoomLevel:minZoomLevel:backgroundImage:] + 3028
    8   MB Example                          0x0000000105125d28 -[RMMapView initWithFrame:andTilesource:centerCoordinate:zoomLevel:maxZoomLevel:minZoomLevel:backgroundImage:] + 408
    9   MB Example                          0x0000000105125b46 -[RMMapView initWithFrame:andTilesource:] + 198
    10  MB Example                          0x00000001050d0816 -[OfflineLayerViewController viewDidLoad] + 326
    11  UIKit                               0x0000000105f7bb60 -[UIViewController loadViewIfRequired] + 738
    12  UIKit                               0x0000000105f7bd5e -[UIViewController view] + 27
    13  UIKit                               0x0000000105fc007f -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 360
    14  UIKit                               0x0000000105fbc22a -[UITabBarController _setSelectedViewController:] + 311
    15  UIKit                               0x0000000105ec3aae +[UIView(Animation) performWithoutAnimation:] + 65
    16  UIKit                               0x0000000105fbbb12 -[UITabBarController _setViewControllers:animated:] + 3105
    17  MB Example                          0x00000001050d0304 -[AppDelegate application:didFinishLaunchingWithOptions:] + 1652
    18  UIKit                               0x0000000105e469a8 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 240
    19  UIKit                               0x0000000105e475b7 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2540
    20  UIKit                               0x0000000105e4a38e -[UIApplication _runWithMainScene:transitionContext:completion:] + 1349
    21  UIKit                               0x0000000105e4928c -[UIApplication workspaceDidEndTransaction:] + 179
    22  FrontBoardServices                  0x0000000109d65f85 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
    23  CoreFoundation                      0x00000001073a849c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    24  CoreFoundation                      0x000000010739e1e5 __CFRunLoopDoBlocks + 341
    25  CoreFoundation                      0x000000010739dfa5 __CFRunLoopRun + 2389
    26  CoreFoundation                      0x000000010739d3e6 CFRunLoopRunSpecific + 470
    27  UIKit                               0x0000000105e48cf9 -[UIApplication _run] + 413
    28  UIKit                               0x0000000105e4bab0 UIApplicationMain + 1282
    29  MB Example                          0x00000001050cfc5f main + 111
    30  libdyld.dylib                       0x00000001079ad145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

incanus added a commit that referenced this issue Mar 11, 2015
@incanus
Copy link
Contributor

incanus commented Mar 11, 2015

Is accesstoken now required for offline tiles ?

No, but this may have been an unintentional change. Will investigate.

@incanus
Copy link
Contributor

incanus commented Mar 11, 2015

Actually, yes, let's just go with requiring an access token for all uses of RMMapboxSource, because we don't want to get into connectivity-checking logic just to see if a string should be set or not.

The base CocoaPods issue remains here though, so will address.

@cadizjavier
Copy link
Author

What should i do then if i only use the offline MBTile support ?
Can i set a random string just to bypass the NSAssert check ? Like this
[[RMConfiguration sharedInstance] setAccessToken:@"<random string>"];
What is the correct approach here ?

@incanus
Copy link
Contributor

incanus commented Mar 20, 2015

That would work fine if you remember to set it valid again if/when you ever need online tiles.

@cadizjavier
Copy link
Author

Yes, i just have tested it and it works just fine without troubles. Upgraded Mapbox from 1.4.1 to 1.6.0 and cocoapods 0.35 to 0.36 and that was the only issue. Thanks.

@faelivrin
Copy link

But when I have my device in plane mode or without connectivity, I can't load my offline maps... Setting a random string to the access token doesn't fix this issue.

@faelivrin
Copy link

I have just solved this issue. You have to make a downgrade of cocoapods from 0.36.x to 0.36. With this command "sudo gem uninstall cocoapods", you will see all installed versions and you have to choose the 0.36.x versions.

albertschulz referenced this issue in albertschulz/mapbox-ios-sdk Jun 4, 2015
MarkSpit referenced this issue in MarkSpit/mapbox-ios-sdk Jun 16, 2015
earltedly referenced this issue in activeintime/mapbox-ios-sdk Jul 13, 2015
…to release

# By Justin R. Miller (12) and others
# Via Jason Wray (3) and others
* 'release' of https://github.com/mapbox/mapbox-ios-sdk:
  Strengthen GL language, add Swift Offline example
  update private header matches
  bump podspec version
  updated changelog for 1.6.1
  explicit public headers in podspec
  explicit module name
  podpsec formatting improvements
  refs #580: pare down Proj4 headers to barest needed for CocoaPods
  refs #580: properly find CocoaPods-based resource bundle
  Smooth edges of user location annotation icon's shadow
  ensure access token is set for v4 API access
  update link
  #578: Unrequire access token for large tiles
  fixes #601: catch bad token during development
  fixes #581: properly check for valid offline source
  Add NSLocationAlwaysUsageDescription check to assert
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants