NativeScript / NativeScript/nativescript-cli

Build for iOS fails when Podfile specifies platform 11 or later

オープン
#4,338 コメント 0 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug CocoaPods os: ios
主要言語
JavaScript
スター
1.1k
フォーク
204
平均マージ
1日 9時間
マージ済み PR(30日)
8

説明

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.1.1
  • Cross-platform modules: Not applicable
  • Android Runtime: Not applicable
  • iOS Runtime: Not applicable
  • Plugin(s): Any plugin with Podfile will do the job. For this report I've used nativescript-imagepicker.

Describe the bug
When the platform in Podfile is 11 or later, build for iOS fails with error:

ld: warning: directory not found for option '-F<path to project>/platforms/ios/build/Debug-iphonesimulator/QBImagePickerController'
ld: framework not found QBImagePickerController
clang: error: linker command failed with exit code 1 (use -v to see invocation)
note: Using new build systemnote: Planning buildnote: Constructing build description

To Reproduce

  1. Create new project: $ tns create myApp --js
  2. Navigate to project: $ cd myApp
  3. Add nativescript-imagepicker plugin: npm i --save --save-exact nativescript-imagepicker
  4. Open the Podfile in nativescript-imagepicker: code node_modules/nativescript-imagepicker/platforms/ios/Podfile and add the following line at the top:
platform :ios, '11.0'
  1. Now build for iOS: tns build ios or tns build ios --forDevice

The build will fail.
Expected behavior
The build should succeed.

Additional context
It looks like the problem is in the Pods - the specified platform is used only for building the framework, but not for the actual Pod target and the application. When building for iOS 11 or later, Xcode automatically builds for 64bits only, i.e. for arm64 (for device) or x86_64 (for simulator).
When CLI tries to build the project, it spawns xcodebuild with ONLY_ACTIVE_ARCH=NO, i.e. Xcode will build the project for all architectures based on the deployment target. As the default deployment target is 9, Xcode will build for both armv7 and arm64 (for device) or i386 and x86_64 (for simulator). As the Pods project has platform "11.0", the static framework will be build only for the 64bits arch, so the actual build of the project will not be able to find the framework for armv7/i386 and it fails.

Workarounds

  • Delete the platform: ios, '11.0' line from all plugins that add it.
    or
  • Specify IPHONEOS_DEPLOYMENT_TARGET = 11.0 in your <path to project's App_Resources>/iOS/build.xcconfig - this way when Xcode builds your project, it will build only for 64bits architecture and the build will succeed. NOTE: This way your app will not work on lower iOS targets.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

ドキュメントに記載された tns create、nativescript-imagepicker、Podfile platform 11.0、tns build ios の各コマンドで失敗を再現します。CLI の xcodebuild 呼び出しと、プラグインの Podfile および App_Resources/iOS/build.xcconfig とともに生成されたプロジェクトを調査します。Podfile platform が 11 以上で、workaround を必要とせずに iOS ビルドが成功すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript
領域
build-system, cli, mobile-dev
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。