15

I've looked at a bunch of answers here and none have fixed my issue.

I have an Xcode workspace with a custom framework and an iOS app project. The project has been working fine until this morning, now it builds but immediately crashes:

dyld: Library not loaded: @rpath/ONCKit.framework/ONCKit
  Referenced from: /private/var/mobile/Containers/Bundle/Application/4DF67A3F-6255-4276-8812-8C742A363995/atero_t.app/atero_t
  Reason: no suitable image found.  Did find:
    /private/var/mobile/Containers/Bundle/Application/4DF67A3F-6255-4276-8812-8C742A363995/atero_t.app/Frameworks/ONCKit.framework/ONCKit: mmap() error 1 at address=0x100118000, size=0x000B8000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/4DF67A3F-6255-4276-8812-8C742A363995/atero_t.app/Frameworks/ONCKit.framework/ONCKit
    /private/var/mobile/Containers/Bundle/Application/4DF67A3F-6255-4276-8812-8C742A363995/atero_t.app/Frameworks/ONCKit.framework/ONCKit: mmap() error 1 at address=0x100280000, size=0x000B8000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/4DF67A3F-6255-4276-8812-8C742A363995/atero_t.app/Frameworks/ONCKit.framework/ONCKit

I've been experimenting with build settings all day and I'm just totally lost.

mfaani
  • 33,269
  • 19
  • 164
  • 293
olynoise
  • 2,016
  • 2
  • 19
  • 32

8 Answers8

13

Incase this helps anyone, none of the solutions I kept finding on the web were working for me. Pulled my hair our for 2 days, and tried everything. I revoked in-house cert, new provisioning profile, added files to embedded, etc.

Could not for the life of me figure out what was wrong until I noticed that in Keychain access my Apple WWDR and iOS Distributions certs were being set to "Always Trust" instead of "Use Systems Default". Switched my certs back to "Use Systems Defaults" and everything went back to working as it should. I have no idea why and how this works but it did.

Geoherna
  • 3,523
  • 1
  • 24
  • 39
  • 5
    I actually don't believe it. This was my problem too. It was fine for me on my local machine running on a device with Xcode but when launching an IPA generated from a Jenkins build job it was failing due to a difference in how trust settings were configured for the certificate. The error in no way indicates that it's anyway related to certificates. You've saved me several more days of pain. – Fergal Rooney Sep 22 '16 at 14:19
  • 2
    This really solves my problem. I cannot believe this can be caused such misleading attribute in Keychain! – wilson100 Feb 01 '18 at 07:47
12

I came across this issue today and resolved it the same way. Revoke and regenerate code signing solves this issue. But to shed some light on the "why" part of it.

Apple went ahead and changed the certificate contents. To be more precise, it added a new "OU" (organizational unit) field under Subject. By revoking and regenerating the code signing, it added the missing field and the problems went away.

BlitzHiryu
  • 144
  • 2
  • 5
  • This OU field is added in which section? In Issuer or in Subject?? Could you please point out that? – bikram990 Sep 09 '15 at 10:03
  • Amended the answer for more clarity. OU is the organizational unit which can be found under the subject section. – BlitzHiryu Sep 16 '15 at 02:05
12

It turns out that Xcode cache some device specific stuff which can get mixed up if you are running your apps on multiple devices. The simple fix is to delete Xcode cache. The following command clean it up for you

rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/com.apple.dt.Xcode
Tarik
  • 539
  • 7
  • 16
1

Just changing the code signing profile fixed the issue. Go to Target. Then selected a different option in General->Signing->Team

Asma Zubair
  • 418
  • 1
  • 4
  • 11
0

Just for any other people that, like me, come across this problem more recently and are wondering where and how exactly to revoke which code signing entity (it's in Preferences > Account):

Everything was working fine for me, too, in the morning. I read somewhere else about rebooting. So, before going through another lengthy signing-identities-provisioning-profiles session, I just restarted my machine. And that fixed it apparently without any further efforts needed.

Swift, Xcode 7.3 on OS X 10.11.4.

marco
  • 900
  • 10
  • 21
0

Clean Xcode's derived data

Launch Finder > Go > Go To Folder > Paste the line below

~/Library/Developer/Xcode/DerivedData

Now restart Xcode.

Mohit Tomar
  • 5,173
  • 2
  • 33
  • 40
0

Well, in my case, I'm using cocoapods, and from the pod files, change:

target 'CoreMotionExample' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

# Pods for CoreMotionExample
pod 'Firebase/Analytics'

to

target 'CoreMotionExample' do
# Comment the next line if you don't want to use dynamic frameworks
# use_frameworks!

# Pods for CoreMotionExample
pod 'Firebase/Analytics'

Then things begin to work... I don't know why

Ren
  • 37
  • 2
  • 4
  • 1
    Are you using a free developer account for signing? External frameworks don't work with free accounts since iOS 13.3.1, so that could be why switching to static libraries solves it for you. – Breiby Mar 06 '20 at 14:43
0

my problem was solved by removing "use_frameworks!" and replacing it with "use_modular_headers!" in Podfile and doing pod update and pod install in terminal.

hope this will help you as it did for me after scratching my head for a week in this problem.