NativeScript / NativeScript/nativescript-cli

Build for iOS fails when Podfile specifies platform 11 or later

未关闭
#4,338 0 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug CocoaPods os: ios
主要语言
JavaScript
星标
1.1k
派生
204
平均合并
1 天 9 小时
30 天内合并 PR
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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用文档中记录的 tns create、nativescript-imagepicker、Podfile platform 11.0 和 tns build ios 命令重现该失败。检查 CLI 对 xcodebuild 的调用,以及生成的项目、插件 Podfile 和 App_Resources/iOS/build.xcconfig。完成标准是:在 Podfile platform 为 11 或更高时,iOS 构建能够成功,且不需要 workaround。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
build-system, cli, mobile-dev
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。