Make Electron app work with sandbox entitlement on MacOS, without rebuilding - electron

I have a MacOS app that was built with the Electron framework.
Its entitlements do not include com.apple.security.app-sandbox.
I am looking for ways to add this entitlement, but without rebuilding the app from source.
It is easy enough with the codesign utility to change the entitlement and re-sign it.
However, when doing so, the app will then crash at launch.
I have gone through this guide, added all the needed entitlements, and added the ElectronTeamId in the Info.plist.
However, the app crashes at launch. Here's what the crash report says :
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_secinit.dylib 0x19cea8154 _libsecinit_appsandbox.cold.5 + 92
1 libsystem_secinit.dylib 0x19cea8140 _libsecinit_appsandbox.cold.5 + 72
2 libsystem_secinit.dylib 0x19cea73d8 _libsecinit_appsandbox + 2044
3 libsystem_trace.dylib 0x1920c8b90 _os_activity_initiate_impl + 64
4 libsystem_secinit.dylib 0x19cea6b88 _libsecinit_initializer + 80
5 libSystem.B.dylib 0x19cebd6c0 libSystem_initializer + 272
6 dyld 0x1048cdf4c invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 164
7 dyld 0x1048f7784 invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 340
8 dyld 0x1048eded8 invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 528
9 dyld 0x1048b9f98 dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 168
10 dyld 0x1048edc80 dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 192
11 dyld 0x1048f71d4 dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 516
12 dyld 0x1048cde8c dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 172
13 dyld 0x1048d4a4c dyld4::PrebuiltLoader::runInitializers(dyld4::RuntimeState&) const + 44
14 dyld 0x1048e32a4 dyld4::APIs::runAllInitializersForMain() + 48
15 dyld 0x1048bddbc dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 3136
16 dyld 0x1048bd06c start + 488
I am happy doing any modifications from the outside (i.e. without recompiling the app from source), for example swapping the electron framework by a different one in the app bundle.
Any pointer much appreciated.

Related

Flutter PlatformView call [CAMetalLayer nextDrawable] blocked main thread over 5 seconds on iOS

I user Flutter PlatformView to Maps and navigation in my App, but I'm having serious performance problems.
My app always stuck over 5 second on the iPhone which device system is iOS12 and below. And, never occur on the iPhone device system above iOS 12.
I have this problem as son as I upgrade Flutter from 1.17 to 2.0.1, I find my app always stuck when I use map and navigation function over 30 mins.
I got the reason [CAMetalLayer nextDrawable] which cause my app stuck by use stuck check tools. There is call stack:
0 libsystem_kernel.dylib semaphore_timedwait_trap + 8
1 libdispatch.dylib _dispatch_sema4_timedwait$VARIANT$armv81 + 60
2 libdispatch.dylib _dispatch_semaphore_wait_slow + 72
3 QuartzCore -[CAMetalLayer nextDrawable] + 1424
4 Flutter std::__1::__function::__func<SkSurface::MakeFromCAMetalLayer(GrRecordingContext*, void const*, GrSurfaceOrigin, int, SkColorType, sk_sp<SkColorSpace>, SkSurfaceProps const*, void const**)::$_0, std::__1::allocator<SkSurface::MakeFromCAMetalLayer(GrRecordingContext*, void const*, GrSurfaceOrigin, int, SkColorType, sk_sp<SkColorSpace>, SkSurfaceProps const*, void const**)::$_0>, GrSurfaceProxy::LazyCallbackResult (GrResourceProvider*, GrSurfaceProxy::LazySurfaceDesc const&)>::operator()(GrResourceProvider*&&, GrSurfaceProxy::LazySurfaceDesc const&) (SkSurface_GpuMtl.mm:0)
5 Flutter GrSurfaceProxyPriv::doLazyInstantiation(GrResourceProvider*) (SkRefCnt.h:320)
6 Flutter GrResourceAllocator::assign(int*, int*, GrResourceAllocator::AssignError*) (GrResourceAllocator.cpp:396)
7 Flutter GrDrawingManager::flush(SkSpan<GrSurfaceProxy*>, SkSurface::BackendSurfaceAccess, GrFlushInfo const&, GrBackendSurfaceMutableState const*) (GrDrawingManager.cpp:219)
8 Flutter GrDrawingManager::flushSurfaces(SkSpan<GrSurfaceProxy*>, SkSurface::BackendSurfaceAccess, GrFlushInfo const&, GrBackendSurfaceMutableState const*) (GrDrawingManager.cpp:537)
9 Flutter SkCanvas::onFlush() (GrDirectContext.cpp:375)
10 Flutter std::__1::__function::__func<flutter::FlutterPlatformViewsController::SubmitFrame(GrDirectContext*, std::__1::shared_ptr<flutter::IOSContext>, std::__1::unique_ptr<flutter::SurfaceFrame, std::__1::default_delete<flutter::SurfaceFrame> >, std::__1::shared_ptr<fml::SyncSwitch> const&)::$_1, std::__1::allocator<flutter::FlutterPlatformViewsController::SubmitFrame(GrDirectContext*, std::__1::shared_ptr<flutter::IOSContext>, std::__1::unique_ptr<flutter::SurfaceFrame, std::__1::default_delete<flutter::SurfaceFrame> >, std::__1::shared_ptr<fml::SyncSwitch> const&)::$_1>, void ()>::operator()() (SkCanvas.h:2758)
11 Flutter fml::SyncSwitch::Execute(fml::SyncSwitch::Handlers const&) (mutex:501)
12 Flutter flutter::IOSExternalViewEmbedder::SubmitFrame(GrDirectContext*, std::__1::unique_ptr<flutter::SurfaceFrame, std::__1::default_delete<flutter::SurfaceFrame> >, std::__1::shared_ptr<fml::SyncSwitch> const&) (functional:1831)
13 Flutter flutter::Rasterizer::DrawToSurface(flutter::LayerTree&) (memory:4211)
14 Flutter std::__1::__function::__func<flutter::Rasterizer::Draw(fml::RefPtr<flutter::Pipeline<flutter::LayerTree> >, std::__1::function<bool (flutter::LayerTree&)>)::$_1, std::__1::allocator<flutter::Rasterizer::Draw(fml::RefPtr<flutter::Pipeline<flutter::LayerTree> >, std::__1::function<bool (flutter::LayerTree&)>)::$_1>, void (std::__1::unique_ptr<flutter::LayerTree, std::__1::default_delete<flutter::LayerTree> >)>::operator()(std::__1::unique_ptr<flutter::LayerTree, std::__1::default_delete<flutter::LayerTree> >&&) (rasterizer.cc:344)
15 Flutter flutter::Rasterizer::Draw(fml::RefPtr<flutter::Pipeline<flutter::LayerTree> >, std::__1::function<bool (flutter::LayerTree&)>) (memory:2620)
16 Flutter std::__1::__function::__func<flutter::Rasterizer::Draw(fml::RefPtr<flutter::Pipeline<flutter::LayerTree> >, std::__1::function<bool (flutter::LayerTree&)>)::$_2, std::__1::allocator<flutter::Rasterizer::Draw(fml::RefPtr<flutter::Pipeline<flutter::LayerTree> >, std::__1::function<bool (flutter::LayerTree&)>)::$_2>, void ()>::operator()() (functional:1831)
17 Flutter fml::MessageLoopImpl::FlushTasks(fml::FlushType) (ref_ptr.h:121)
18 Flutter fml::MessageLoopDarwin::OnTimerFire(__CFRunLoopTimer*, fml::MessageLoopDarwin*) (message_loop_darwin.mm:76)
19 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28
20 CoreFoundation __CFRunLoopDoTimer + 864
21 CoreFoundation __CFRunLoopDoTimers + 248
22 CoreFoundation __CFRunLoopRun + 2168
23 CoreFoundation CFRunLoopRunSpecific + 552
24 GraphicsServices GSEventRunModal + 100
25 UIKit UIApplicationMain + 236
26 myapp main (main.m:37)
27 libdyld.dylib start + 4
I don't know how to avoid the stuck When I user my app,Can someone help me solve this problem?

Swift crash in swift_getSingletonMetadata, "type metadata accessor"

I've been getting some weird crash logs from my Mac app. Here's the crashed thread:
OS Version: Mac OS X 10.14.6 (18G103)
Report Version: 104
Exception Type: SIGSEGV
Exception Codes: SEGV_MAPERR at 0x0
Crashed Thread: 8
Thread 8 Crashed:
0 ??? 0x0000000000000000 0x0 + 0
1 libswiftCore.dylib 0x00007fff79a743f3 swift_getSingletonMetadata + 578
2 PowerPhotos 0x000000010323f30d type metadata accessor for PowerPhotos.IPAssetCollectionUpdate (<compiler-generated>:0)
3 libswiftCore.dylib 0x00007fff79a8c94c swift::TargetProtocolConformanceDescriptor<swift::InProcess>::getCanonicalTypeMetadata() const + 171
4 libswiftCore.dylib 0x00007fff79a8da24 swift_conformsToSwiftProtocolImpl(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, llvm::StringRef) + 291
5 libswiftCore.dylib 0x00007fff79a8d884 swift_conformsToProtocolImpl(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*) + 99
6 PowerPhotos 0x000000010339e7a9 swift::swift50override_conformsToProtocol(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, swift::TargetWitnessTable<swift::InProcess> const* (*)(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*)) + 56
7 libswiftCore.dylib 0x00007fff79a6215a swift::_conformsToProtocol(swift::OpaqueValue const*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptorRef<swift::InProcess>, swift::TargetWitnessTable<swift::InProcess> const**) + 41
8 libswiftCore.dylib 0x00007fff79a65f97 _conformsToProtocols(swift::OpaqueValue const*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::TargetWitnessTable<swift::InProcess> const**) + 230
9 libswiftCore.dylib 0x00007fff79a65369 _dynamicCastToExistential(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::DynamicCastFlags) + 488
10 libswiftCore.dylib 0x00007fff79836517 Swift._print_unlocked<A, B where B: Swift.TextOutputStream>(A, inout B) -> () + 550
11 PowerPhotos 0x00000001031e2483 PowerPhotos.IPArchiveUpdateOperation.(loadFromReplay in _C3BCBD43848FA0F2A85DA8591115A6A7)() -> PowerPhotos.IPArchiveLoadResult (<compiler-generated>:0)
12 PowerPhotos 0x00000001031e1700 PowerPhotos.IPArchiveUpdateOperation.(loadFromPreferredDatabase in _C3BCBD43848FA0F2A85DA8591115A6A7)() -> (PowerPhotos.IPArchiveLoadResult, Swift.Error?) (IPArchiveUpdateOperation.swift:430)
13 PowerPhotos 0x00000001031e08fa PowerPhotos.IPArchiveUpdateOperation.perform() throws -> Any (IPArchiveUpdateOperation.swift:218)
14 PowerPhotos 0x00000001031e179c #objc PowerPhotos.IPArchiveUpdateOperation.perform() throws -> Any (<compiler-generated>:0)
15 BWFoundation 0x00000001036c8173 -[BWOperation main] (BWOperation.m:124)
16 PowerPhotosKit 0x0000000103898e71 -[IPOperation main] (IPOperation.m:287)
17 Foundation 0x00007fff502f5ced -[__NSOperationInternal _start:] + 684
18 Foundation 0x00007fff5031fca7 __NSOQSchedule_f + 226
19 libdispatch.dylib 0x00007fff7a0055f8 _dispatch_call_block_and_release + 11
20 libdispatch.dylib 0x00007fff7a00663d _dispatch_client_callout + 7
21 libdispatch.dylib 0x00007fff7a008de6 _dispatch_continuation_pop + 413
22 libdispatch.dylib 0x00007fff7a0084a3 _dispatch_async_redirect_invoke + 702
23 libdispatch.dylib 0x00007fff7a0143bc _dispatch_root_queue_drain + 323
24 libdispatch.dylib 0x00007fff7a014b46 _dispatch_worker_thread2 + 89
25 libsystem_pthread.dylib 0x00007fff7a2466b3 _pthread_wqthread + 582
26 libsystem_pthread.dylib 0x00007fff7a2463fd start_wqthread + 12
27 ??? 0x0000000054485244 0x0 + 0
Frame 11 is the last time my own code is seen, that line of code looks like this:
return IPArchiveLoadResult(error: NSError(description: "Replay did not complete \(replayDatabase.replayState.debugDescription)"))
So it looks like the call to debugDescription is what's generating the rest of the stack trace, to create that interpolated string. This ultimately ends up in frame 3 which references 'type metadata accessor for PowerPhotos.IPAssetCollectionUpdate'.
But here's the weird thing: IPAssetCollectionUpdate has absolutely nothing to do with the code that's calling this stuff. It's in an entirely different part of the application. So I think it's mostly coincidental that this is triggering whatever metadata loading Swift is doing here.
Looking at IPAssetCollectionUpdate, I think I see what's probably tripping it up:
#available(OSX 10.15, *)
struct IPAssetCollectionUpdate {
let assetCollection: PHAssetCollection
let diff: CollectionDifference<PHAsset>
}
Notice that IPAssetCollectionUpdate is marked as available only on macOS 10.15, and the crashes are all occurring on macOS 10.14. PHAssetCollection and PHAsset do exist on macOS 10.14, but CollectionDifference does not. This isn't a problem in the rest of the app, since everything's protected by the #available directive, but it seems that the Swift runtime is still trying to dig into this struct and generate some internal metadata and blowing up when it can't handle CollectionDifference. Or something like that?
Anyway, that's the setup, so my questions are:
Should this be considered a Swift bug? It seems like with everything properly annotated with availability directives, I should be able to ship this on macOS 10.14 and not have things crash, since I'm never actually using this struct at all on 10.14.
Regardless of whose fault it is, is there any way I can change this code so that it doesn't blow up on 10.14? The best I can think of is to break it out into a loadable bundle in my app and load the bundle manually when running on 10.15. That seems like a lot of work for this silly problem though, and I'd like to know if there's some other simpler way to handle this.
I'm compiling this using Xcode 11.5 and Swift 5.
OK, Stack Overflow was a good rubber duck for me here, I was able to avoid the crash by doing the following:
struct IPAssetCollectionUpdate {
let assetCollection: PHAssetCollection
let typeErasedDiff: Any
var diff: CollectionDifference<PHAsset> {
return self.typeErasedDiff as! CollectionDifference<PHAsset>
}
}
It's terrible, but it works. But my question about whether this should be considered a Swift bug remains, and whether there's a more sanctioned way to write this type of code.

My UE4 demo application crashes after launch

My demo UnrealEngine4 ios application crashes immediately after launch. At the same time, android build works fine. Here is the crash log:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
VM Region Info: 0 is not in any region. Bytes before following region: 4366614528
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 0000000104454000-000000010a1f0000 [ 93.6M] r-x/r-x SM=COW ...podealUE4Demo
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [5038]
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 UE4Demo 0x0000000106081624 FOutputDevice::LogfImpl+ 29546020 (char16_t const*, ...) + 204
1 UE4Demo 0x00000001060815b8 FOutputDevice::LogfImpl+ 29545912 (char16_t const*, ...) + 96
2 UE4Demo 0x0000000105feff88 FDebug::AssertFailed+ 28950408 (char const*, char const*, int, char16_t const*, ...) + 312
3 UE4Demo 0x0000000105ed5eec FGenericPlatformTime::GetSecondsPerCycle64+ 27795180 () + 244
4 UE4Demo 0x0000000105f17c4c FThreadHeartBeat::Get+ 28064844 () + 464
5 UE4Demo 0x0000000106009bfc FDebug::EnsureFailed+ 29055996 (char const*, char const*, int, char16_t const*, int) + 384
6 UE4Demo 0x000000010600a288 FDebug::OptionallyLogFormattedEnsureMessageReturningFalseImpl+ 29057672 (bool, char const*, char const*, int, char16_t const*, ...) + 116
7 UE4Demo 0x0000000105ef1780 LLMMap<PointerKey, unsigned int, ELLMTag>::Remove+ 27907968 (PointerKey const&) + 464
8 UE4Demo 0x0000000105eefae0 FLLMTracker::TrackFree+ 27900640 (void const*, ELLMTracker, ELLMAllocType) + 112
9 UE4Demo 0x0000000105f1c49c FMemory::Free+ 28083356 (void*) + 200
10 CFNetwork 0x00000001bb945ce0 XTubeManager::~XTubeManager+ 204000 () + 56
11 CFNetwork 0x00000001bb945c28 XTubeManager::~XTubeManager+ 203816 () + 12
12 CFNetwork 0x00000001bb920300 -[__NSURLSessionLocal dealloc] + 48
13 libobjc.A.dylib 0x00000001ba565b9c (anonymous namespace)::AutoreleasePoolPage::pop+ 129948 (void*) + 672
14 libobjc.A.dylib 0x00000001ba54e220 call_load_methods + 732
15 libobjc.A.dylib 0x00000001ba54fe54 load_images + 180
16 dyld 0x000000010e54e390 dyld::notifySingle+ 9104 (dyld_image_states, ImageLoader const*, ImageLoader::InitializerTimingList*) + 444
17 dyld 0x000000010e560314 ImageLoader::recursiveInitialization+ 82708 (ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 440
18 dyld 0x000000010e55f370 ImageLoader::processInitializers+ 78704 (ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 136
19 dyld 0x000000010e55f42c ImageLoader::runInitializers+ 78892 (ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 84
20 dyld 0x000000010e54e6d8 dyld::initializeMainExecutable+ 9944 () + 220
21 dyld 0x000000010e5532a0 dyld::_main+ 29344 (macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 4304
22 dyld 0x000000010e54d044 _dyld_start + 68
The only thing I'm doing on launch is showing a menu widget (which works fine in editor and android).
As I understand from the log, the main problem is outside of my code. It seems like FMemory::Free and other things are just service processes after crash. And I'm pretty sure that there is no my code in the call stack.
It's an -ObjC flag. I have this flag in UE4 project settings, but it seems that these setting has no effect on XCode project. At least for UE4.21.2.
I figured out a solution that worked for me:
System Preferences
Battery
Click Battery on the left-side panel
Uncheck "Automatic Graphics Switching"
Upon starting the epic games launcher again, it worked for me and didn't crash anymore.

Xcode 7 crashing when debugging

I'm often getting crash when I try to debug my app in Xcode 7 with iPhone simulator (5s, iOS 8.4):
Process: Xcode [6913]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 7.1 (9079)
Build Info: IDEFrameworks-9079000000000000~8
App Item ID: 497799835
App External ID: 813804225
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Xcode [6913]
User ID: 501
Date/Time: 2015-11-02 13:37:44.248 +0300
OS Version: Mac OS X 10.10.5 (14F1021)
Report Version: 11
Anonymous UUID: CB3D1F12-E033-1160-2F9F-69DC0A89468E
Sleep/Wake UUID: DA9F3D65-3E86-4A1C-9E41-2E921CDFD798
Time Awake Since Boot: 290000 seconds
Time Since Wake: 1500 seconds
Crashed Thread: 26 <DBGLLDBSessionThread (pid=42149)> Dispatch queue: DVTInvalidationPreventionQueue
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
VM Regions Near 0:
-->
__TEXT 000000010798f000-0000000107993000 [ 16K] r-x/rwx SM=COW /Applications/Xcode.app/Contents/MacOS/Xcode
Application Specific Information:
ProductBuildVersion: 7B91b
Thread 26 Crashed:: <DBGLLDBSessionThread (pid=42149)> Dispatch queue: DVTInvalidationPreventionQueue
0 com.apple.LLDB.framework 0x0000000113efd3cb swift::ModuleFile::getModule(llvm::ArrayRef<swift::Identifier>) + 443
1 com.apple.LLDB.framework 0x0000000113f1116b swift::ModuleFile::associateWithFileContext(swift::FileUnit*, swift::SourceLoc) + 1739
2 com.apple.LLDB.framework 0x0000000113f175bd swift::SerializedModuleLoader::loadAST(swift::ModuleDecl&, llvm::Optional<swift::SourceLoc>, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, bool) + 589
3 com.apple.LLDB.framework 0x0000000113f199cf swift::SerializedModuleLoader::loadModule(swift::SourceLoc, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >) + 5423
4 com.apple.LLDB.framework 0x0000000113b58004 swift::ASTContext::getModule(llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >) + 276
5 com.apple.LLDB.framework 0x0000000113efd385 swift::ModuleFile::getModule(llvm::ArrayRef<swift::Identifier>) + 373
6 com.apple.LLDB.framework 0x0000000113f1116b swift::ModuleFile::associateWithFileContext(swift::FileUnit*, swift::SourceLoc) + 1739
7 com.apple.LLDB.framework 0x0000000113f175bd swift::SerializedModuleLoader::loadAST(swift::ModuleDecl&, llvm::Optional<swift::SourceLoc>, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, bool) + 589
8 com.apple.LLDB.framework 0x0000000113f199cf swift::SerializedModuleLoader::loadModule(swift::SourceLoc, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >) + 5423
9 com.apple.LLDB.framework 0x0000000113b58004 swift::ASTContext::getModule(llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >) + 276
10 com.apple.LLDB.framework 0x0000000113efd385 swift::ModuleFile::getModule(llvm::ArrayRef<swift::Identifier>) + 373
11 com.apple.LLDB.framework 0x0000000113f1116b swift::ModuleFile::associateWithFileContext(swift::FileUnit*, swift::SourceLoc) + 1739
12 com.apple.LLDB.framework 0x0000000113f175bd swift::SerializedModuleLoader::loadAST(swift::ModuleDecl&, llvm::Optional<swift::SourceLoc>, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >, bool) + 589
13 com.apple.LLDB.framework 0x0000000113f199cf swift::SerializedModuleLoader::loadModule(swift::SourceLoc, llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >) + 5423
14 com.apple.LLDB.framework 0x0000000113b58004 swift::ASTContext::getModule(llvm::ArrayRef<std::__1::pair<swift::Identifier, swift::SourceLoc> >) + 276
15 com.apple.LLDB.framework 0x00000001143a09bd lldb_private::SwiftASTContext::GetModule(lldb_private::ConstString const&, lldb_private::Error&) + 365
16 com.apple.LLDB.framework 0x00000001143a21d6 lldb_private::SwiftASTContext::ValidateSectionModules(lldb_private::Module&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) + 114
17 com.apple.LLDB.framework 0x000000011412d5ef lldb_private::Module::GetSwiftASTContext(lldb_private::Error*) + 2579
18 com.apple.LLDB.framework 0x000000011425922f SymbolFileDWARF::GetSwiftASTContext(lldb_private::Error*) + 83
19 com.apple.LLDB.framework 0x00000001143218dc std::__1::__function::__func<lldb_private::Target::GetSwiftASTContext(lldb_private::Error&, bool, char const*)::$_0, std::__1::allocator<lldb_private::Target::GetSwiftASTContext(lldb_private::Error&, bool, char const*)::$_0>, void (std::__1::shared_ptr<lldb_private::Module>&&)>::operator()(std::__1::shared_ptr<lldb_private::Module>&&) + 646
20 com.apple.LLDB.framework 0x000000011431c66d lldb_private::Target::GetSwiftASTContext(lldb_private::Error&, bool, char const*) + 1945
21 com.apple.LLDB.framework 0x000000011418a7ba lldb_private::formatters::swift::SwiftMetatype_SummaryProvider(lldb_private::ValueObject&, lldb_private::Stream&, lldb_private::TypeSummaryOptions const&) + 318
22 com.apple.LLDB.framework 0x000000011446b9c9 lldb_private::CXXFunctionSummaryFormat::FormatObject(lldb_private::ValueObject*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, lldb_private::TypeSummaryOptions const&) + 85
23 com.apple.LLDB.framework 0x0000000114165512 lldb_private::ValueObject::GetSummaryAsCString(lldb_private::TypeSummaryImpl*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, lldb_private::TypeSummaryOptions const&) + 202
24 com.apple.LLDB.framework 0x00000001141655ab lldb_private::ValueObject::GetSummaryAsCString(lldb::LanguageType) + 105
25 com.apple.LLDB.framework 0x0000000112427788 lldb::SBValue::GetSummary() + 78
26 com.apple.dt.dbg.DebuggerLLDB 0x000000011237985f -[DBGLLDBDataValue _calculateSummary] + 117
27 com.apple.dt.dbg.DebuggerLLDB 0x0000000112379500 __67-[DBGLLDBDataValue _fetchSummaryFromLLDBOnSessionThreadIfNecessary]_block_invoke + 104
28 com.apple.dt.DVTFoundation 0x0000000107a915ec ___DVTPreventInvalidationForObjectAllowingRecursiveCallsDuringBlock_block_invoke_2 + 49
29 libdispatch.dylib 0x00007fff8ddffe73 _dispatch_client_callout + 8
30 libdispatch.dylib 0x00007fff8de0eee9 _dispatch_sync_f_invoke + 39
31 com.apple.dt.DVTFoundation 0x0000000107a91596 ___DVTPreventInvalidationForObjectAllowingRecursiveCallsDuringBlock_block_invoke + 133
32 libdispatch.dylib 0x00007fff8ddffe73 _dispatch_client_callout + 8
33 libdispatch.dylib 0x00007fff8de0eee9 _dispatch_sync_f_invoke + 39
34 com.apple.dt.DVTFoundation 0x0000000107a913f2 _DVTPreventInvalidationForObjectAllowingRecursiveCallsDuringBlock + 372
35 com.apple.dt.DVTFoundation 0x0000000107a91745 _DVTPreventInvalidationAllowingRecursiveCallsDuringBlock + 35
36 com.apple.dt.dbg.DebuggerLLDB 0x0000000112378ba8 __44-[DBGLLDBDataValue _addSessionThreadAction:]_block_invoke + 122
37 com.apple.dt.dbg.DebuggerLLDB 0x000000011238c168 -[DBGLLDBSession handleNextActionWithState:withRunPending:] + 435
38 com.apple.dt.dbg.DebuggerLLDB 0x00000001123872f8 DBGLLDBSessionThread(void*) + 997
39 libsystem_pthread.dylib 0x00007fff873ec05a _pthread_body + 131
40 libsystem_pthread.dylib 0x00007fff873ebfd7 _pthread_start + 176
41 libsystem_pthread.dylib 0x00007fff873e93ed thread_start + 13
I use Swift language and several frameworks in my app, here is Cartfile:
github "robb/Cartography"
github "ReactiveCocoa/ReactiveCocoa" "v4.0.0-alpha.3"
github "realm/realm-cocoa"
Maybe someone already seen such crash or maybe have idea about it.
What solved this exact crash for me, Xcode 7.1.1 (which previously was reproducible on my breakpoint 100% of the time) was rerunning carthage bootstrap, and the crashes vanished.
Try deleting DerivedData. This worked for me. I think intermediate build products from Xcode 6 cause Xcode 7 to crash.
I had the same Swift issue and reinstalling Xcode fix the thing.
By reinstalling I mean removing xcode.app bundle, and removing files from
- /Library/Developer
- /Library/Developer/Application Support/Xcode
- ~/Library/Developer
- ~/Library/Developer/Application Support/Xcode
+ I did the same for Simulator app
Plus I removed all the xcode and simulator preferences, what probably wasn't necessary too - remove DerivedData folder would be enough
Probably removing and re-download XCode isn't necessa
And don't forget to make a backup before.
A solution might be disabling module debugging.
Search for CLANG_ENABLE_MODULE_DEBUGGING in you're project and set it to no.
I had the same problem in Xcode 9.1 when I tried to run the app on a real device.
I just delete the app from the device and when I rerun the project, the Xcode doesn't crash anymore.
Experienced this in my project despite the CLANG_ENABLE_MODULE_DEBUGGING flag being lowered. This is probably edge case but worth sharing anyways.
It was being caused by my latest commit where I accidentally declared a property as a protocol instead of id.
#property (nonatomic, strong) MyObjectProtocol *selectedItem;
and was fixed when I changed it to:
#property (nonatomic, strong) id<MyObjectProtocol> selectedItem;
A big whoops on my end but no thanks to Xcode!!

Run app deployed with XCode 7 gives a crash

I develop app in xcode 6.
And then device connected i run app with debug.
After i can disconnect device from xcode and again run app. And it's runs.
But today begins some problems
i run app with run button in xcode 7 -> app run normally, and work good.
After i disconnect device from my mac, and try run app by press app icon on device and got crash
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000197747270 __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001977e516c pthread_kill + 108
2 libsystem_c.dylib 0x00000001976beb14 abort + 108
3 ...g_rt.asan_ios_dynamic.dylib 0x00000001019d56d0 0x101984000 + 333520
4 ...g_rt.asan_ios_dynamic.dylib 0x00000001019c955c 0x101984000 + 283996
5 ...g_rt.asan_ios_dynamic.dylib 0x00000001019ccf28 0x101984000 + 298792
6 ...g_rt.asan_ios_dynamic.dylib 0x00000001019c9640 0x101984000 + 284224
7 ...g_rt.asan_ios_dynamic.dylib 0x00000001019cd0e8 0x101984000 + 299240
8 ...g_rt.asan_ios_dynamic.dylib 0x00000001019bef50 0x101984000 + 241488
9 ...g_rt.asan_ios_dynamic.dylib 0x00000001019c8d18 0x101984000 + 281880
10 dyld 0x0000000120095234 ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 256
11 dyld 0x00000001200953ec ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 32
12 dyld 0x0000000120091688 ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 328
13 dyld 0x000000012009161c ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 220
14 dyld 0x00000001200914d8 ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 136
15 dyld 0x00000001200917a0 ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 80
16 dyld 0x0000000120086150 dyld::initializeMainExecutable() + 196
17 dyld 0x00000001200898bc dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 2664
18 dyld 0x0000000120085040 _dyld_start + 64
How to understand what library gives a crash?
Project on ObjectiveC, use CoreData, RestKit, MagicalRecord, FacebookSDK, GoogleSDK, VKSdk, Fabric (Crashlytics and Twitter)
Yeah, it's calls: "Welcome from Apple".
How you know XCode 7 give use new opportunity AddressSenitizer!
So remember DISABLE it's if you want run app without connected device to debug XCode mode.

Resources