Programing

기기에서 프레임 워크가 충돌하는 iOS 앱, dyld : 라이브러리가로드되지 않음, Xcode 6 베타

lottogame 2020. 2. 9. 20:30
반응형

기기에서 프레임 워크가 충돌하는 iOS 앱, dyld : 라이브러리가로드되지 않음, Xcode 6 베타


이 충돌은 차단 문제였으며 다음 단계를 사용하여 문제를 재현했습니다.

  • Cocoa Touch Framework 프로젝트 생성
  • 신속한 파일과 클래스 Dog 추가
  • 장치를위한 프레임 워크 구축
  • Swift에서 싱글 뷰 애플리케이션 생성
  • 앱 프로젝트로 프레임 워크 가져 오기
  • ViewController의 프레임 워크에서 신속한 클래스 인스턴스화
  • 기기에서 앱 빌드 및 실행

시작시 앱이 즉시 다운되었습니다. 콘솔 로그는 다음과 같습니다.

dyld: Library not loaded: @rpath/FrameworkTest03.framework/FrameworkTest03
  Referenced from: /var/mobile/Applications/FA6BAAC8-1AAD-49B4-8326-F30F66458CB6/FrameworkTest03App.app/FrameworkTest03App
  Reason: image not found

iOS 7.1 및 8.0 장치에서 빌드하려고 시도했지만 모두 동일한 충돌이 발생합니다. 그러나 앱을 빌드하고 시뮬레이터에서 잘 실행할 수 있습니다. 또한 Link Binary With Libraries 에서 Required to Optional 으로 프레임 워크를 변경할 수 있지만 Dog 의 인스턴스를 만들 때 응용 프로그램이 충돌하는 문제를 완전히 해결하지 못했습니다 . 장치와 시뮬레이터에서 동작이 다릅니다. 베타 버전의 Xcode를 사용하여 장치의 프레임 워크를 배포 할 수 없다고 생각합니다. 누구든지 이것에 빛을 비출 수 있습니까?


대상의 General 탭에는 Embedded Binaries 필드가 있습니다. 프레임 워크를 추가하면 충돌이 해결됩니다.

Apple 개발자 포럼에서 참조 하십시오 .


iOS가 8 이상인 경우

대상의 General 탭 아래 Embedded Binaries 섹션에 프레임 워크를 추가하십시오. 이것은 런타임에 링크 될 수 있도록 프레임 워크를 컴파일 된 것으로 복사합니다.

여기에 이미지 설명을 입력하십시오

왜 이런 일이 발생합니까? : 연결하는 프레임 워크가 동적으로 링크 된 프레임 워크로 컴파일되어 런타임에 링크되기 때문입니다.

참고 : 사용자 정의 프레임 워크 포함은 iOS> 8에서만 지원되므로 이전 버전의 iOS에서 작동하는 대체 솔루션은 다음과 같습니다.

iOS 8 미만

이 프레임 워크에 영향을 미치는 경우 (소스 코드 / 빌드 프로세스에 액세스 할 수 있음)이 프레임 워크를 동적으로 링크되지 않고 정적으로 링크되도록 변경할 수 있습니다. 이로 인해 코드가 런타임에 링크되지 않고 컴파일 된 앱에 포함되므로 프레임 워크를 포함하지 않아도됩니다.

방법 : 프레임 워크의 빌드 설정 탭 아래에있는 연결 섹션에서 Mach-O 유형 을 정적 라이브러리로 변경하십시오 . 이제 임베디드 바이너리 아래에 프레임 워크를 포함시킬 필요가 없습니다.

정적 프레임 워크

자산 포함 : 이미지, 오디오 또는 xib / nib 파일과 같은 것을 포함하려면 번들 (본질적으로 디렉토리, 여기에 더 많은 정보는 bit.ly/ios_bundle)을 생성 한 다음 NSBundle을 사용하여 번들에서 자산을로드하는 것이 좋습니다.


프레임 워크를 프로젝트로 드래그하는 것만으로는 충분하지 않습니다. 같은 야구장에 있지만 아이를 찾을 수없는 것과 같습니다. 다음과 같이하세요:

1) 프레임 워크 만들기

  • 프레임 워크를 개발하십시오.
  • 개발이 완료되면 COMMAND+ B프레임 워크를 구축하고 "Build Succeeded"를 받도록하십시오.

여기에 이미지 설명을 입력하십시오

2) 프레임 워크에 액세스

  • 프레임 워크 프로젝트가 성공적으로 빌드되면 프로젝트의 Products폴더에서 액세스 할 수 있습니다 .

여기에 이미지 설명을 입력하십시오

  • 마우스 오른쪽 버튼을 클릭 .framework하고 "파인더에 표시"를 선택하십시오.

여기에 이미지 설명을 입력하십시오

3) 프로젝트에 프레임 워크 배치

  • .frameworkFinder 윈도우에서 앱 프로젝트의 "Framework"폴더로 드래그 앤 드롭 합니다.

여기에 이미지 설명을 입력하십시오

4) 프레임 워크를위한 앱 프로젝트 구성

  • 프로젝트에서 최상위 레벨을 선택하십시오

여기에 이미지 설명을 입력하십시오

  • 목표를 선택하십시오

여기에 이미지 설명을 입력하십시오

  • "빌드 단계"로 이동 한 다음 "이진을 라이브러리와 링크"로 이동하여 프레임 워크가 선택 항목 으로 포함되어 있는지 확인하십시오 .

여기에 이미지 설명을 입력하십시오

  • 여전히 "빌드 단계"에서 왼쪽 상단으로 이동하여 +버튼을 선택하십시오 . 드롭 다운에서 "New Copy Files Phase"를 선택하십시오.

여기에 이미지 설명을 입력하십시오

  • 새로운 "파일 복사"섹션으로 스크롤 Destination하여 "프레임 워크"로 설정했는지 확인하십시오 . 서브 패스를 비워 두십시오. 그런 다음 +왼쪽 하단 버튼을 클릭하십시오 .

여기에 이미지 설명을 입력하십시오

  • 프로젝트 계층 구조가 제공됩니다. 3 단계에서 프레임 워크를 추가 한 "Frameworks"폴더로 스크롤하거나 맨 위에있는 검색 표시 줄에서 검색하십시오. 프레임 워크를 선택하고 "추가"를 클릭하십시오.

여기에 이미지 설명을 입력하십시오

  • "Code Sign On Copy"가 선택된 상태로 프레임 워크가 포함되어 있는지 확인하십시오.

여기에 이미지 설명을 입력하십시오

5) 청소 후 프로젝트를 실행하십시오.

  • COMMAND+ SHIFT+K
  • COMMAND+R

먼저 Command + Option + Shift + K 후에 빌드하십시오. 여전히 실패하면 아래 단계를 수행하십시오.

Xcode 8 에서이 오류가 발생 하면 대상의 일반 탭에서 프레임 워크 상태를 필수 대신 선택 사항으로 변경하십시오 .

여기에 이미지 설명을 입력하십시오


Swift3 / Xcode 8.1을 사용하여 프레임 워크를 만들고 Objective-C / Xcode 8.1 프로젝트에서 사용했습니다. 이 문제를 해결하려면에서 Always Embed Swift Standard Libraries옵션 을 활성화해야했습니다 Build Options.

Have a look at this screenshot:

여기에 이미지 설명을 입력하십시오


I got same kind of issue in iOS 9.x version

ISSUE IS: App crashes as soon as I open the app with below error.

dyld: Library not loaded: /System/Library/Frameworks/UserNotifications.framework/UserNotifications Referenced from: /var/containers/Bundle/Application/######/TestApp.app/TestApp Reason: image not found

I have resolved this issue by changing Required to Optional in Linked Frameworks and Libraries for UserNotifications.framework framework.


You need to add the framework to a new Copy Files Build Phase to ensure that the framework is copied into the application bundle at runtime..

See How to add a 'Copy Files build phase' to my Target for more information.

Official Apple Docs: https://developer.apple.com/library/mac/recipes/xcode_help-project_editor/Articles/CreatingaCopyFilesBuildPhase.html


I had to (on top of what mentioned here) add the following line to Runpath Search Paths under Build Settings tab:
@executable_path/Frameworks

여기에 이미지 설명을 입력하십시오


Add the framework in Embedded Binaries 여기에 이미지 설명을 입력하십시오

Then Clean and Build.


In my case the solution was to remove the compiled framework from the Embedded Binaries, which was a standalone project in the workspace, clean and rebuild it, and finally re-add to Embedded Binaries.


If you are using a third-party framework, and using Cocoapods as your dependency manager, try doing a pod install to refresh your pods.

This crash was occurring on a third-party library I was using, so glad the above solution worked for me, hope it works for you!


Surprisingly, not all of the necessary pieces are documented here, at least for Xcode 8.

My case was a custom-built framework as part of the same workspace. It turns out it was being built incorrectly. Based on jeremyhu's last response to this thread:

https://forums.developer.apple.com/thread/4687

I had to set Dynamic Library Install Name Base (DYLIB_INSTALL_NAME_BASE) under Build Settings of the Framework and then rebuild it. It was incorrectly set to $(LOCAL_LIBRARY_DIR) and I had to change it to @rpath.

So in the link processing stage, it was instructing the host App to dynamically load it at runtime from /Library/Frameworks/fw.Framework/fw (as in, the root of the filesystem) rather than path-to-App/Frameworks/fw.Framework/fw

Regarding all the other settings: it does have to be in 3 places in Build Phases, but these are all set at once when you just add it to the Embedded Binaries setting of the General tab of the hosting App.

I did not have to set up an extra Copy Files phase, which seems intuitively redundant with respect to the embedding stage anyway. By checking the tail end of the build transcript we can assure that that's not necessary.

PBXCp /Users/xyz/Library/Developer/Xcode/DerivedData/MyApp-cbcnqafhywqkjufwsvbzckecmjjs/Build/Products/Debug-iphoneos/MyFramework.framework

[Many verbose lines removed, but it's clear from the simplified transcript in the Xcode UI.]

I still have no idea why Xcode set the DYLIB_INSTALL_NAME_BASE value incorrectly on me.


My environment: Cocos2d 2.0, Box2d, Objective C

In addition to doing the other answers above I finally went to the General tab and made WatchKit Optional.

일반 링크 된 프레임 워크 및 라이브러리를 대상으로합니다.


여기에 이미지 설명을 입력하십시오

Resolved for me by unselecting "Copy only when installed" on Build Phases->Embed Frameworks


I had the same issue. I tried building my project with an iPhone that I never used before and I didn't add a new framework. For me, cleaning up worked fine (Shift+Command+K). Maybe it's because I use beta 5 of Xcode 7 and an iPhone 6 with iOS 9 Beta, but it worked.


In my case, my project is written by objective-c and in the library there are Swift files. So I changed "Always Embed Swift Standard Libraries" in my project’s Build Settings tab to Yes and it became totally okay.


If have development pod Delete your app from simulator install from pod -> clean - > run again...


The same thing was when I've created a new Configuration and Build Scheme.

So the solution for me was to run

pod install

for this newly created Configuration.


After trying all the methods available on internet and my own trial and error tricks 100 times. Finally I was able to solve it. – Apeksha Sahu 6 mins ago
Goto iTunes in Mac --> accounts-->Authorize this computer – Apeksha Sahu 5 mins ago
second step.... Goto developer in settings in iPad and iPhone and reindex with identifiers and clear trust computers everything. It worked for me........ ....... After reinstalling Mac OSHigh seria 10.13.15 version from Mac OS seirra beta latest version, to reinstalling Xcode latest version, after updating all certificates. etc etc etc... as many methods as you can think I did. – 여기에 이미지 설명을 입력하십시오


Try with changing flag ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES (in earlier xcode versions: Embedded Content Contains Swift Code) in the Build Settings from NO to YES.


If you're using Xcode 11 or newer:

  1. Navigate to the settings of your target and select General.

대상 설정 / 일반

  1. Scroll down to Frameworks, Libraries and Embedded Content.

  2. Make sure the Embed & Sign or Embed Without Signing value is selected for the Embed option if necessary.

프레임 워크, 라이브러리 및 임베디드 컨텐츠 섹션


  1. Go to file in xcode -> Workspace settings
  2. Click the arrow next to which appears /Users/apple/Library/Developer/Xcode/DerivedData
  3. Select the Derived data and move it to Trash.
  4. Quite the xcode and reopen it.
  5. Clean the project and run again.

Above steps resolved my issuses.


It is a runtime error that is caused by Dynamic Linker

dyld: Library not loaded: @rpath/...
...
Reason: image not found

The error Library not loaded with @rpath[About] indicates that Dynamic Linker cannot find the framework.

  1. Check if the framework was added to General -> Embedded Binaries

  2. Check if the @rpath - Build Settings -> Runpath Search Paths contains a path with the same destination/subpath as was setup in Build Phases -> Embed Frameworks -> Destination, Subpath

Read more here


In case anyone is still experiencing this issue, despite following all the steps outlined in the many other answers, you may need to revoke and recreate your code signing certificate, as per the following:

https://developer.apple.com/library/ios/qa/qa1886/_index.html

참고URL : https://stackoverflow.com/questions/24333981/ios-app-with-framework-crashed-on-device-dyld-library-not-loaded-xcode-6-beta



반응형