mapbox / mapbox-gl-native

Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL
https://mapbox.com/mobile
Other
4.37k stars 1.33k forks source link

[iOS] Adding a MGLMapView in a storyboard crashes IB. #10573

Closed fabian-guerra closed 5 years ago

fabian-guerra commented 6 years ago

Platform: iOS 11 Mapbox SDK version: 3.7.0

Steps to trigger behavior

  1. Add a MGLMapView through storyboards.

Expected behavior

IB will work.

Actual behavior

IB crashes with the following message:

.../Main.storyboard: error: IB Designables: Failed to render and update auto layout status for ViewController (BYZ-38-t0r): The agent crashed

This work well using master branch.

dan-burt commented 6 years ago

I am getting this message on a new iOS project that I have just started. How do I resolve? Are there some initial properties I need to set on the MGLMapView object?

aaasifrz9 commented 6 years ago

When I add MGLMapView class at added UIView in storyboard. Storyboard got crashed. How can I fix it? Please help.

1ec5 commented 6 years ago

Is this a duplicate of #10072?

fabian-guerra commented 6 years ago

You are right. Even tho I didn't use cocoapods it's the same error. Duplicate of #10072

julianrex commented 6 years ago

@fabian-guerra just want to confirm - you weren't using CocoaPods?

cc @akitchen

fabian-guerra commented 6 years ago

@julianrex I confirm that I was not using cocoapods.

1ec5 commented 6 years ago

Reopening – #10072 is definitely caused by CocoaPods. This would be unrelated in that case. Do you have reliable steps to reproduce?

fabian-guerra commented 6 years ago

Import the SDK in a new app, or in the same test app storyboard add a map view. Has the same error as in #10072.

1ec5 commented 6 years ago

I can reproduce this issue in Xcode 9.4 with iOS map SDK v4.1.0-beta.1. With the “Developer” crash reporting preference turned on, I see this crash in IBDesignablesAgentCocoaTouch:

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (Code Signature Invalid)
Exception Codes:       0x0000000000000032, 0x000000011d458000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace CODESIGNING, Code 0x2

Same in Xcode 10 beta 1 with IBDesignablesAgent-iOS:

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (Code Signature Invalid)
Exception Codes:       0x0000000000000032, 0x00000001262f7000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace CODESIGNING, Code 0x2

The framework bundle isn’t codesigned. At build time, we rely on the “Code Sign On Copy” setting in the Embed Frameworks build phase. But apparently the designables agent now expects the bundle to be codesigned. I thought I’ve seen this work at times in the recent past, but perhaps I’m misremembering.

The codesigning issue explains why the macOS map SDK has never been affected by the designable crash, and why using a static framework can also avoid the crash.

In investigating this issue, I discovered that the designable agent has been renamed: #12140. That fix is necessary but insufficient for addressing the IB designable crash.

fabian-guerra commented 5 years ago

This seems more an Xcode bug than ours, https://github.com/mapbox/mapbox-gl-native/pull/12140 helped fix our side of the issue.

I made a test project with a UIView that had IBInspectables with an IB crash. I cleaned the project and restarted my Mac, that seemed to fix the crash I was having in the maps SDK project too.

I asked @julianrex to confirm if cleaning a project and restarting the mac fixed the crash and he confirmed that this fix works.

The solution for this ticket is clean the project and restart the mac (not only Xcode).

If anyone else encounters a way to re reproduce this issue feel free to re-open it.

tomoyuki28jp commented 5 years ago

I cleaned my project and restarted my Mac, but I'm still facing the error.

tomoyuki28jp commented 5 years ago

FYI: subclassing MGLMapView solved it.

stale[bot] commented 5 years ago

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

friedbunny commented 5 years ago

Fixed in #14379.