apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 987 forks source link

Podspec tag does not generate podfile #621

Closed annakocheshkova closed 9 months ago

annakocheshkova commented 5 years ago

Bug Report

Problem

What is expected to happen?

Noticed this warning in customers' apps: "framework" tag with type "podspec" is deprecated and will be removed. Please use the "podspec" tag. Updated my plugin's plugin.xml with podspec tag instead of framework tag and installed the plugin. Podfile should be created and filled with referenced frameworks, pods should be installed.

What does actually happen?

Podfile is created but it is empty. No Pods folder inside platforms/ios.

STR

  1. plugin.xml:
...

<platform name="ios">
    ...

    <podspec>
         <config>
             <source url="https://github.com/CocoaPods/Specs.git"/>
         </config>
         <pods use-frameworks="true">
             <pod name="AppCenter" spec="~> 2.0.1" />
         </pods>
    </podspec>
</platform>
  1. Add my local plugin into the test app's config: <plugin name="my-cordova-plugin" spec="file:../my-cordova-plugin" />

  2. Run cordova platform add ios

  3. Observe the Podfile inside platforms/ios:

# DO NOT MODIFY -- auto-generated by Apache Cordova

platform :ios, '9.0'

target 'TestApp' do
    project 'TestApp.xcodeproj'

end

Environment, Platform, Device

macOS High Sierra

Version information

cocoapods 1.6.0 cordova-ios 5.0.1 node 10.15.1 cordova-lib 8.1.2 (and 9.0.2 as well has that error)

dsymutil -v
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  Optimized build.
  Default target: x86_64-apple-darwin17.7.0
  Host CPU: ivybridge

Checklist

annakocheshkova commented 5 years ago

@janpio can somebody please take a look at this? We really want to be able to update deprecated tags :slightly_smiling_face:

brodybits commented 5 years ago

@janpio https://github.com/janpio can somebody please take a look at this?

I suggest you ping us by email to dev@cordova.apache.org

And please keep in mind that this project is maintained by a bunch of very busy volunteers.

annakocheshkova commented 5 years ago

@brodybits thank you. I will :+1: Would really appreciate any feedback.

erisu commented 5 years ago

Can you also add to the description what version of Cordova CLI you are using?

Example

$ cordova -v
9.0.0 (cordova-lib@9.0.1)
annakocheshkova commented 5 years ago

Updated

erisu commented 5 years ago

Looking at the update,

cordova-lib 8.1.2 (and 9.0.2 as well has that error)

I suspect you are still using an older version of Cordova CLI, based from the lib version. Also, there is currently no 9.0.2 cordova-lib release.

The new pod tags were introduced in Cordova CLI 9.x.

First, could you try and upgrade your Cordova CLI?

npm uninstall -g cordova
npm install -g cordova@latest

$ cordova -v
9.0.0 (cordova-lib@9.0.1)

Also, for adding plugins, I would recommend using the Cordova command: cordova plugin add /path/to/plugin. Cordova CLI 9.x also manages plugins now in pacakge.json and no longer adds plugins to the config.xml

You could possibly add it manually to the devDependencies in package.json.

Example:

"devDependencies": {
  "cordova-ios": "^5.0.1",
  "cordova-plugin-appcenter": "file:../../../../tmp/test-plugin"
},
annakocheshkova commented 5 years ago

@erisu sorry, a typo. I just the updated cli before updating the description to 9.x version and it still doesn't work. I'll try adding plugins via plugin add but I remember trying it before and it didn't help 😞

annakocheshkova commented 5 years ago

@erisu yep, the same issue. Although, why would I add them to devDependencies? It's in dependencies.

KenAppman commented 5 years ago

same issue here, also add plugin into package.json but podfile still empty please help

annakocheshkova commented 4 years ago

Looks like we're not getting any help here? 😢

brodybits commented 4 years ago

I suggest you ping us via Slack or the email forum that I sent before. And I repeat my comment that this project is maintained by a bunch of overworked volunteers.

On Mon, Jul 8, 2019, 4:27 AM Anna Kocheshkova notifications@github.com wrote:

Looks like we're not getting any help here? 😢

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/apache/cordova-ios/issues/621?email_source=notifications&email_token=AAL42UCWVKR6RJKLDXWLU6TP6L25BA5CNFSM4HOCGFEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZMLKCY#issuecomment-509129995, or mute the thread https://github.com/notifications/unsubscribe-auth/AAL42UAIKRGTGP5YBLRCLNLP6L25BANCNFSM4HOCGFEA .

annakocheshkova commented 4 years ago

@brodybits I e-mailed to the email you sent above some time before

janpio commented 4 years ago

Is this reproducible in a new, plain Cordova app? A minimal reproduction repository would really help to debug and later fix this issue. More information on how to create one: https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md

annakocheshkova commented 4 years ago

@janpio yes, on a new app. I will try to create a test repo tomorrow, although I posted the detailed STR in the description

annakocheshkova commented 4 years ago

@janpio created, just run cordova platform add ios: https://github.com/annakocheshkova/TestCordovaApp

janpio commented 4 years ago

Ok, my TestAppRepro/platforms/ios/Podfile looks like this:

# DO NOT MODIFY -- auto-generated by Apache Cordova
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target 'E:\Projects\throwaway\TestCordovaApp\TestAppRepro\platforms\ios\HelloCordova' do
    project 'E:\Projects\throwaway\TestCordovaApp\TestAppRepro\platforms\ios\HelloCordova.xcodeproj'
    pod 'Alarmofire', '~> 4.8.0'
end

Isn't this what is expected?

annakocheshkova commented 4 years ago

@janpio Hmm, on my PC it's not the same. Do you have an idea what might affect this? Cocoapods version is 1.6.2

janpio commented 4 years ago

I'm on Windows, so no cocoapods - maybe that's the reason? Some code that is not run on Windows and messes up the file after it was already correct?

Anyway, here is the full version info and output of the patform add command:

E:\Projects\throwaway\TestCordovaApp\TestAppRepro (master -> origin) (helloworld@1.0.0)
λ cordova -v
9.0.0 (cordova-lib@9.0.1)

E:\Projects\throwaway\TestCordovaApp\TestAppRepro (master -> origin) (helloworld@1.0.0)
λ cordova info
cordova-lib@9.0.1 with:
  cordova-common@3.2.0
  cordova-create@2.0.0
  cordova-fetch@2.0.1
  cordova-serve@3.0.0

Environment:
  OS: win32
  Node: v12.5.0
  npm: 6.9.0

Plugins:
  cordova-plugin-whitelist
  cordova-test-plugin

No Platforms Currently Installed

config.xml <<EOF
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>HelloCordova</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <plugin name="cordova-plugin-whitelist" spec="^1.3.4" />
    <plugin name="cordova-test-plugin" spec="file:../cordova-test-plugin" />
</widget>

EOF

package.json <<EOF
{
    "name": "helloworld",
    "displayName": "HelloCordova",
    "version": "1.0.0",
    "description": "A sample Apache Cordova application that responds to the deviceready event.",
    "main": "index.js",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "author": "Apache Cordova Team",
    "license": "Apache-2.0",
    "dependencies": {
        "cordova-plugin-whitelist": "^1.3.4",
        "cordova-test-plugin": "file:../cordova-test-plugin"
    },
    "cordova": {
        "plugins": {
            "cordova-plugin-whitelist": {},
            "cordova-test-plugin": {}
        },
        "platforms": []
    }
}

EOF

E:\Projects\throwaway\TestCordovaApp\TestAppRepro (master -> origin) (helloworld@1.0.0)
λ cordova platform add ios --verbose
No scripts found for hook "before_platform_add".
No version supplied. Retrieving version from config.xml...
Grabbing pinned version.
Using cordova-fetch for cordova-ios@^5.0.0
fetch: Installing cordova-ios@^5.0.0 to E:\Projects\throwaway\TestCordovaApp\TestAppRepro
Running command: npm install cordova-ios@^5.0.0 --production --save
Command finished with error code 0: npm install,cordova-ios@^5.0.0,--production,--save
Removing "cordova-" prefix from cordova-ios
Adding ios project...
PlatformApi successfully found for platform ios
Creating Cordova project for the iOS platform:
        Path: platforms\ios
        Package: io.cordova.hellocordova
        Name: HelloCordova
Copying iOS template project to E:\Projects\throwaway\TestCordovaApp\TestAppRepro\platforms\ios
iOS project created with cordova-ios@5.0.1
Checking for any plugins added to the project that have not been installed in ios platform
No differences found between plugins added to project and installed in ios platform. Continuing...
PlatformApi successfully found for platform ios
Generating platform-specific config.xml from defaults for iOS at E:\Projects\throwaway\TestCordovaApp\TestAppRepro\platforms\ios\HelloCordova\config.xml
Merging project's config.xml into platform-specific iOS config.xml
Merging and updating files from [www, platforms\ios\platform_www] to platforms\ios\www
  mkdir platforms\ios\www\cordova-js-src
  copy  platforms\ios\platform_www\cordova-js-src\exec.js platforms\ios\www\cordova-js-src\exec.js (new file)
  copy  platforms\ios\platform_www\cordova-js-src\platform.js platforms\ios\www\cordova-js-src\platform.js (new file)
  mkdir platforms\ios\www\cordova-js-src\plugin
  mkdir platforms\ios\www\cordova-js-src\plugin\ios
  copy  platforms\ios\platform_www\cordova-js-src\plugin\ios\console.js platforms\ios\www\cordova-js-src\plugin\ios\console.js (new file)
  copy  platforms\ios\platform_www\cordova-js-src\plugin\ios\logger.js platforms\ios\www\cordova-js-src\plugin\ios\logger.js (new file)
  copy  platforms\ios\platform_www\cordova.js platforms\ios\www\cordova.js (updated file)
  copy  www\css\index.css platforms\ios\www\css\index.css (updated file)
  copy  www\index.html platforms\ios\www\index.html (updated file)
  copy  www\js\index.js platforms\ios\www\js\index.js (updated file)
Current launch storyboard undefined
Not changing launch storyboard setting in info plist.
Wrote out iOS Bundle Version "1.0.0" to E:\Projects\throwaway\TestCordovaApp\TestAppRepro\platforms\ios\HelloCordova\HelloCordova-Info.plist
No need to update build settings for launch storyboard support.
Set PRODUCT_BUNDLE_IDENTIFIER to io.cordova.hellocordova.
Did not update build settings for launch storyboard support.
iOS Product Name has not changed (still "HelloCordova")
This app does not have icons defined
This app does not have splash screens defined
Updating launch storyboard images at platforms\ios\HelloCordova\Images.xcassets\LaunchStoryboard.imageset\
Updating Storyboard image set contents.json
This app does not have additional resource files defined
Prepared iOS project successfully
Installing plugin "cordova-plugin-whitelist" following successful platform add of ios
Cannot find plugin.xml for plugin "cordova-plugin-whitelist". Please try adding it again.
CordovaError: Cannot find plugin.xml for plugin "cordova-plugin-whitelist". Please try adding it again.
    at new PluginInfo (C:\ProgramData\scoop\persist\nvm\nodejs\v12.5.0\node_modules\cordova\node_modules\cordova-common\src\PluginInfo\PluginInfo.js:422:15)
    at PluginInfoProvider.get (C:\ProgramData\scoop\persist\nvm\nodejs\v12.5.0\node_modules\cordova\node_modules\cordova-common\src\PluginInfo\PluginInfoProvider.js:35:32)
    at Function.runInstall (C:\ProgramData\scoop\persist\nvm\nodejs\v12.5.0\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:263:41)
    at C:\ProgramData\scoop\persist\nvm\nodejs\v12.5.0\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:76:35
    at processTicksAndRejections (internal/process/task_queues.js:82:5)

Now someone working on macOS has to do the same to reproduce what you reported or not.

sushichop commented 4 years ago

@annakocheshkova

Hi! I investigated your cordova plugin for test and cordova app project. Then finally I fixed it(, though some workaround is also needed...)

See https://github.com/annakocheshkova/TestCordovaApp/pull/1 .

janpio commented 4 years ago

Can you help increase the Cordova logic that stumbled over these inaccuracies as well @sushichop? That would be neat.

annakocheshkova commented 4 years ago

Hey @sushichop thank you so much for your help! I checked out your branch, repeated your steps and it helped! Right now I'm figuring out what exactly was the issue. I used Alarmofire just for the repro but now my plugin works as well. I also noticed that if I downgrade my CLI from 9.0.0 to cordova 8.0.0, it stops working. Does this mean that I'll have to keep the old tag in the plugin.xml for the users who are still on the old CLI version?

sushichop commented 4 years ago

@annakocheshkova

About the original issue(Bug Report) I don't know exactly why installing plugin failed at your environment first time because I don't have your environment log message..😅 But I assume, at least, your cordova-lib version was old as @erisu said above and you had to need to recreate your cordova app project.

About the second issue?(using Alamofire with CocoaPods and Cordova) As I wrote at annakocheshkova/TestCordovaApp#1, I fixed typo, correct version, set swift version and minimum iOS version.. This issue basically depends on how to use CocoaPods and Cordova, I think.

About cordova-cli version IMHO, if you want to use cordova using cocoacods, you need cordova-cli 9.0.0 or later. Recent cocoacods feature has come with cordova-ios 5.0.0 that expects cordova-cli 9.0.0 or later. See https://cordova.apache.org/announcements/2019/03/18/cordova-lib-release-9.0.0.html. And the latest version is more preferable.

I hope these information is helpful😀

janpio commented 4 years ago

This might be relevant if you need to publish a version with changes that doesn't work with older Cordova CLI: https://cordova.apache.org/docs/en/9.x/plugin_ref/spec.html#engines-and-engine

jcesarmobile commented 9 months ago

Closing as it’s working fine and looks like it was caused because of old cordova/cordova-ios versions.