79

静的ライブラリを構築する必要があります。iPhoneとiPadアプリで使いたい。シミュレーターを実行しようとすると、リンクエラーが発生します。私はiOS開発に不慣れです。親切に助けてください。

ld:警告:ファイル/Users/valuelabs/Desktop/DruvaProject/libraries/libnetUtils.aを無視します。ファイルは、リンクされているアーキテクチャではないアーカイブ用にビルドされました(i386)アーキテクチャi386の未定義のシンボル:
"_ OBJC_CLASS _ $ _ netUtils"、から参照:ViewController.oのobjc-class-ref:アーキテクチャi386のシンボルが見つかりませんclang:エラー:リンカーコマンドが終了コード1で失敗しました(呼び出しを確認するには-vを使用してください)

アーキテクチャにi386を追加してみました。しかし運がない

4

11 に答える 11

77

この同じ問題に苦労し、ビルド設定の更新、リンカー検索パスのクリアなど、受け入れられているすべての回答に従った後、私はついに自分に合った回答を見つけました。

ビルドする前に、iOSデバイスではなく正しいタイプ(iPhoneシミュレーター)を選択していることを確認してください。次に、再構築します。それ以外の場合は、Mac(i386)のシミュレータでiOSデバイス(アームプロセッサ)用に構築されたライブラリを使用しようとしています。明白なはずでしたが、そうではありませんでした。

前:

iOSデバイスの設定

後:

iPhone5.1シミュレータ設定

次に、ナビゲーターの[製品]グループを確認し、静的ライブラリ(.aファイル)を右クリックして[Finderに表示]を選択すると、Debug-iphoneosではなくDebug-iphonesimulatorフォルダーにあることがわかります。もともとフォルダ名は気にならなかったのか、もっと早く考えたのかもしれません。

お役に立てれば。

于 2013-01-03T17:11:24.723 に答える
42

Sometimes these types of errors irritates you!

Removing Derived Data Works for me:

Steps to fix

1) In XCODE > Windows > Project > Select your project > Delete derived Data > Quit XCODE and Reopen it > If you get MAC-O-Linker builed failed error > Refere this link > Clean and Build again.

于 2015-06-08T05:36:40.593 に答える
28

Your libnetUtils.a is being built for a different architecture than your target.

Check the libnetUtils build settings. The architectures that it is being built for and its list of supported architectures must be a (weak) superset of your target's architecture. The complexity here is that the resulting architecture is spread over various settings: "Architectures", "Build active architecture only" and "Valid Architectures".

"Build active architecture only" settings make this particularly confusing. For example, suppose you are building for the simulator. If the "Build active architecture only" setting for Debug is set to NO, it will be building all the architectures listed in "Architectures" and "Valid architectures" (probably armv7, etc). But if libnetUtils has that setting set to Yes (Debug: Yes) it is only building for i386. So when your linker tries to link armv7 with i386, it fails.

于 2013-02-06T01:28:57.837 に答える
26

If I get the ignore file warning - I would run lipo -info on ignored file to find it's architecture as below

lipo -info libnetUtils.a

That would print either of i386, armv6, armv7, armv7s, x86_64 etc. In general, that architecture has to match with your target build platform. E.g.

  • i386 = ios simulator or 32 bit build on mac os x
  • armv6 armv7 arm7s = ios device
  • x86_64 = 64 bit build on mac os x

Depending on the mismatch, either you have to rebuild your library for your target platform or change your target platform.

Note: For fat binaries, lipo -info will print a combination of above architectures.

于 2014-05-19T06:22:00.113 に答える
9

私のアドバイスが正しいかどうかは実際にはわかりませんが、これを確認してみてください。

  • プロジェクトを選択します
  • 「ビルド設定」を選択します
  • アーキテクチャを確認してください:
    • 有効なアーキテクチャは「armv6armv7」である必要があります
    • サポートされているプラ​​ットフォームは「iphonesimulatoriphoneos」である必要があります(おそらくiPad、わかりません)
    • ベースSDK– iOS SDK(私はiOS 5.0を持っています)。

私がキャプテンであるかどうか私を判断しないでください:)

于 2012-05-29T16:50:26.210 に答える
5

これは、使用しようとしているライブラリがiOSシミュレータ用にユニバーサルにコンパイルされていないことを意味します(i386シンボルはMac用です)。ただし、実際のデバイスで実行すると正常に動作するはずです。

于 2012-05-29T16:37:17.390 に答える
4

You should also check if Deployment Target within Build Settings is the same for dependant and dependency. I noticed that I had iOS 13 being set for a static library target, while iOS 10.0 was defined for a framework that consumes that library. Switchin both to 10.0 resolved the issue.

于 2020-01-21T07:28:16.773 に答える
3

Had the same problem, and tried diverse solutions from the page to no avail. I still had a message telling me my library was not build for arm64.

Finally how I resolved it :

  • opened the project.pbxproj for the library in a text editor
  • searched for VALID_ARCHS
  • there were 4 occurrences, 2 of which did not contain arm64
  • I manually added arm64 in the chain (VALID_ARCHS = "arm64 i386 armv7 armv7s")
  • rebuild the lib and it was all right

Seems sometimes the build settings displayed by XCode is incomplete, and doesn't correspond precisely to the project file.

于 2014-10-02T14:41:19.390 に答える
0

To me it was fixed setting the Build Active Architecture Only to Multiple values, to do that, you have to expand it and set Debug to YES and Release to No. And now, it compiles on my device.

于 2018-10-19T20:34:33.543 に答える
-1

This issue will not occur when we run the application on device. You can check it by running the code on iOS device.

于 2017-01-24T15:38:53.537 に答える
-2

I had an architecture of armv7s as well. I deleted it and made sure the armv6 and armv7 were the only two listed. It works now

于 2013-02-05T15:32:37.633 に答える