dyld: Library not loaded - crash with Xcode 8 - ios

I am working through the Stanford CS193 course on iOS/Swift. I did run into a rather technical problem while programming the second Twitter assignment. I was having difficulty running on my device (iPhone 6) although the simulator worked fine. I suspected I needed to upgrade from Xcode 7.2 to Xcode 8 and so I did that. After fixing obvious new errors (e.g. new try implemented on system objects), I still cannot get it to run - it (the simulator) exits with:
dyld: Library not loaded: #rpath/libswiftCoreLocation.dylib
Referenced from: /Users/peterwills/Library/Developer/Xcode/DerivedData/Smashspace-hdbpvcoeyafnkuaqzjqknhkcnful/Build/Products/Debug-iphonesimulator/Twitter.framework/Twitter
Reason: image not found
The culprit is a Twitter framework distributed with the course. I did a clean and rebuild of this framework but it still crashes with this message.
Any suggestions will be very much appreciated.
BTW, I build the framework for a generic iOS device and I am simulating an iPhone 6+. In fact, it crashes for any simulated device. Also, I have searched widely to get help on this (99.9% of the problems I have had are solved with a Google search) but had no luck with this. I believe that is because the error message happens in a variety of unrelated situations. In my case, it was not there in previous versions of Xcode and it is related to the cs193 Twitter framework.

Related

iOS: Embedded Framework not found, but only on *some* installs

The current AppStore version of my app is seeing crashes for hundreds of users, where bundled frameworks cannot be found. This didn't come up in testing, and I've been unable to reproduce the problem, whether on the simulator or a device, regardless of whether I wipe the device clean and to a fresh install, or install over an existing version.
The error log I've obtained from a user indicates:
Dyld Message: Library not loaded: #rpath/OMGHTTPURLRQ.framework/OMGHTTPURLRQ
Referenced from: /var/containers/Bundle/Application/BB320110-3C64-4772-9A3A-208F4CAD84B5/PicTapGo.app/PicTapGo
Reason: image not found
However, upon review, that framework certainly IS included in the actual bundle that was sent to the App Store, in the Frameworks folder. In the Xcode project, Runtime Search Paths includes '#executable_path/Frameworks', and that's where the frameworks are bundled.
This is the first time we've linked against a dynamic lib (which is a must, because the lib includes Swift code), so it's possible (likely, even), that I'm missing something crucial about embedded frameworks here.
Again, the strange thing about this is that I can wipe my iPhone clean, and reinstall this version from the App Store, and the error does not occur. In every configuration I've tested (including with our beta testers), the library loads just fine. This means that the framework is missing for only SOME users. Further, there doesn't appear to be any rhyme or reason to the failure. It's happening on all manner of iOS devices, on all versions of iOS 9 (though I don't see any iOS 8 crashes listed in the Xcode organizer). I've been completely unable to reproduce the issue, but for affected users, it happens consistently.
Any idea why only some devices would be unable to find a bundled framework? Does the App Store monkey with your bundle configuration in some circumstances?
After some investigation, it appears that the libraries did indeed disappear. Snooping the actual library binaries that were shipped to the App Store, they ended up only getting built for arm64. Still working on how this happened (maybe some CocoaPods weirdness), but this neatly explains the dyld failures in the wild. For arm64 architectures (iPhone 5s and later), everything is A-OK. For the 4s, 5, 5c, and older iPads, dyld couldn't find the lib. Apparently, the App Store strips out non-compatible architectures when they process the app, and that portion of the bundle is just plain missing on armv7 devices. Looking at the crash reports available, none of them are on arm64 devices.
All of the "library not found" crashes, with a log like the one noted above, are on iOS9. There are similar crashes on iOS 8, but with a different message. I'm assuming it's the one I'm able to reproduce locally ("no suitable image found... Did find <somelib>: mach-o, but wrong architecture"), and this dovetails with the idea that iOS8 devices would get the full fat binary. Lib would be there, but no arm7.
This failure wasn't evident during normal development. I use an iPhone 6 as a primary testing device, and my beta team is apparently all on newer devices as well. I had relied on the simulator to test on older devices. It looks like that's a Bad Idea™ for at least one reason I can cite now. In the future, I'll be testing on an actual, factual armv7 device before sending things into the world.
So, for anyone experiencing dyld failures in the future, this is one more thing to look for. Will update this if that doesn't turn out to be the case.
EDIT: One more tidbit from the autopsy, for posterity - The way we ended up with arm64-only in the AppStore build is by bundling the debug version of the library, not the AppStore version. I bundled the frameworks by creating a new Copy phase, and dragging the frameworks from the Products group of the CocoaPods. However, the actual binary you get when configuring a copy phase that way depends on which scheme you currently have active. If you have a Debug scheme active, you get the debug build of the library. If you have an AppStore scheme active, you get an AppStore build. This is a hard-coded path in the Xcode project, and regardless of which scheme you choose for your main project's build in the future, you'll be bundling the version you originally dragged.
By default, Debug builds only build the active architecture, meaning the Debug libraries were missing armv7 support.

XCode error when trying to run Unity3D app

I am trying to run my iOS app that I developed in Unity on XCode but I am getting this error:
dyld: Symbol not found: _gEnableStylusTouch
Referenced from: /Users//Library/Developer/CoreSimulator/Devices/91CAEC4E-6706-4B87-AA7A-323CB629C56E/data/Containers/Bundle/Application/E591C7A6-EA53-470E-BDF0-8CF2C3DDF686/dsapp.app/dsapp
Expected in: flat namespace
in /Users//Library/Developer/CoreSimulator/Devices/91CAEC4E-6706-4B87-AA7A-323CB629C56E/data/Containers/Bundle/Application/E591C7A6-EA53-470E-BDF0-8CF2C3DDF686/dsapp.app/dsapp
This is only happening when I am running on the iPhone6 simulator. It works on all the simulators before iPhone6.
Here are some details of my environment:
Unity3D version: 5.3.3f1
XCode version: 7.2.1
Does anyone know how I can get rid of this error, I have read other related questions that say this problem has to do with linked frameworks and libraries but I am still unsure of how I can solve this issue. Any help is appreciated.
EDIT
Note that I am also getting this error when I submit to the apple store. It needs to be fixed otherwise I can't get my app in the store.
Added screenshots below.
In the Unity3D player settings for iOS, I changed the scripting backend from Mono to IL2CPP and selected Universal as my architecture and it worked. I submitted to the apple store with no errors and it was successfully reviewed and accepted. I'm not exactly sure why it solved the issue, I was just fiddling around with different options.

Wikitude SDK for iOS crashing on iOS 9 Device

I want to code an app with augmented reality support by Wikitude. For that I use the native SDK for iOS from Wikitude. Setup and everything works, like it is described on their website/documentation.
When I run the app from Xcode on my iDevice, the app launches and crashes immediately with the following error:
dyld: Library not loaded: #rpath/libswiftSecurity.dylib
Referenced from:/private/var/mobile/Containers/Bundle/Application/some-number/App.app/Frameworks/WikitudeNativeSDK.framework/WikitudeNativeSDK
Reason: image not found
I have googled my way through the web now, still no solution found about how to fix this problem/bug/whateverthismightbe. I cleaned the whole project, removed the DerivedData-Files, restarted Xcode, nothing works.
My setup is: OS X 10.11, Xcode 7.0.1, iOS 9.0.2
Maybe someone had this problem too and solved it, would be nice to know!
Thanks in advice.

Quickblox link error _iconv on simulator builds

Am adding QuickBlox to my iOS app and getting a link error for _iconv, _iconv_open &_iconv_close.
I have added all the libraries/frameworks as per QuickBlox's instructions. The only differences I can see is that in their instructions they use the libraries from the iOS 5.0 folder while mine are all in iOS 7.0, and that I have added libxml2.dylib not libxml.dylib (as libxml2.dylib is in that iOS7 folder).
Curiously this occurs only on iPhone simulator builds - building for a device is fine.
Simple enough to fix this by including libiconv.dylib - when I first ran into this problem it was part of a much larger issue caused by xcode always looking for the armvx libs instead of 386 ones for the simulator. Not quite sure why it now only needs that library for the simulator build though.
Have posted this as the answer for anyone glancing here to see if it was answered.

XCode missing some iOS debug symbols

I am collecting crash logs for my app but sometimes I have a problem where I can't decode the CoreFoundation and other SDK related Symbols. The lines that are from my app I can read so I have no problem there, but it seems that I can't read the Apple symbols unless they came from a build of iOS that I at one point had on my phone. This is a problem because with iOS 6 it seems that there are a few different builds out there depending on which device you have and I skipped the 6.0.x updates and went right to 6.1.2.
How can I get all these symbols without tracking down friends with different iOS versions and plugging their phone in with XCode running so it will extract the symbols? There must be an easier way!
The only other way, which doesn't work for all iOS versions especially not the last bug fix versions, is answered here: Xcode software image for user iOS in order to symbolicate iOS calls

Resources