PODS_ROOT and other pods env variables not set when compiling Ionic app

时光毁灭记忆、已成空白 提交于 2019-12-06 01:50:00

问题


I have built an Ionic 2 app which uses Intercom (a third-party extension). Intercom is installed using cocoapods.

When compiling my app I am given the errors:

diff: /Podfile.lock: No such file or directory
diff: /Manifest.lock: No such file or directory
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

This is being generated by the Build Phase [CP] Check Pods Manifest.lock:

diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
if [ $? != 0 ] ; then
    # print error to STDERR
    echo "error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation." >&2
    exit 1
fi
# This output is used by Xcode 'outputs' to avoid re-running this script phase.
echo "SUCCESS" > "${SCRIPT_OUTPUT_FILE_0}"

I have tried outputting the environment variables PODS_PODFILE_DIR_PATH and PODS_ROOT in the STDERROR echo from the script above and both are blank. I can probably get around this specific error by amending those paths myself, but clearly something else more fundamental is broken, so I need to fix the actual issue itself.

Why are these variables blank?

I have additional build phases for [CP] Copy Pods Resources and [CP] Embed Pods Frameworks which run some shell scripts. I have tried changing the order of these with no luck.

My Podfile.lock and Podfile (which was auto-generated anyway) both seem good:

Podfile:

# DO NOT MODIFY -- auto-generated by Apache Cordova
platform :ios, '8.0'
target 'niix' do
    project 'niix.xcodeproj'
    pod 'Intercom', '~> 3.2.2'
end

Podfile.lock:

PODS:
  - Intercom (3.2.12)

DEPENDENCIES:
  - Intercom (~> 3.2.2)

SPEC CHECKSUMS:
  Intercom: 3119e8ebf76d3da425bab717a08067398fcabfe6

PODFILE CHECKSUM: f99283bb8a4e56cb037a02390d2fbc4e76c97db9

COCOAPODS: 1.3.1

There are no errors when running pod install, and all files I expect are present.

Things I have tried already:

  • Running pod install (of course)
  • Running pod deintegrate, running Product > Clean in XCode, re-running pod install
  • Manually deleting the Podfile.lock and Pods directory, running a Clean in XCode and then re-running pod install
  • A good nights sleep and another attempt the next morning!

Things to note:

  • I am running from project.xcworkspace not project.xcodeproj
  • I am running the latest stable version of XCode 8.3.3
  • I am running the latest version of Cocoapods 1.3.1

回答1:


I've spent a long time trying to work this out and got nowhere. The app was built using Ionic 2, so the actual source code is stored elsewhere and built into a native XCode application.

Because of this I decided to delete the entire XCode directory. .xcodeproj, .xcworkspace, everything. I then rebuilt from Ionic.

On the second build I saw thats the Pods directory was there and everything was as it should be. I could compile and run first time without any issue.

My assumption is that the first build failed because I didn't have Cocoapods installed, so Ionic silently failed to run the pod install command upon set up. I guess it does something a little different to a traditional setup which is why I couldn't just run pod install afterwards.

So, in short, this was fixed by removing the iOS project:

ionic cordova platform rm ios

And re-adding it:

ionic cordova platform add ios

And then building:

ionic cordova run ios --device

But make sure you already have Cocoapods installed on your system first.



来源:https://stackoverflow.com/questions/46110728/pods-root-and-other-pods-env-variables-not-set-when-compiling-ionic-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!