jeduan / cordova-plugin-facebook4

Use the latest Facebook SDK in your Cordova and Ionic projects
Other
765 stars 510 forks source link

Podfile wrong editing for the pod dependencies #812

Closed deliverymanager closed 4 years ago

deliverymanager commented 4 years ago

In case someone uses other modules that they are editing the Podfile too, then this happens inside the podfile. The target 'Sample Project' do etc is declared twice, leading to the error Analyzing dependencies [!] The target Sample Project is declared multiple times for the project Sample Project.xcodeproj.

NOTE: I am using all the latest versions

# DO NOT MODIFY -- auto-generated by Apache Cordova
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
target 'Sample Project' do
    project 'Sample Project.xcodeproj'
end
use_frameworks!
    pod 'GoogleSignIn', '~> 4.4.0'
    pod 'GoogleUtilities', '~> 6.2.3'
    pod 'OneSignal', '2.11.0'
target 'Sample Project' do
    project 'Sample Project'
    pod 'GoogleSignIn', '~> 4.4.0'
    pod 'GoogleUtilities', '~> 6.2.3'
    pod 'OneSignal', '2.11.0'
    pod 'FBSDKCoreKit', '5.7.0'
    pod 'FBSDKLoginKit', '5.7.0'
    pod 'FBSDKShareKit', '5.7.0'
end
deliverymanager commented 4 years ago

Did someone else test the plugin with other plugins that use pods? Thank you

deliverymanager commented 4 years ago

For anyone else with the same problem a very tiring workaround when you are trying to install other plugins all together that require pods like: "cordova-plugin-googleplus", "onesignal-cordova-plugin", "cordova-plugin-facebook4"

The main problem is that all these three plugins plugins use pods and they all try to create a new pod target but with the same name! This give a multiple targets error during plugin add.

So they workaround that I have found is:

source 'https://github.com/CocoaPods/Specs.git' platform :ios, '11.0' use_frameworks! target 'Franky\'s BURGERS' do project 'Franky\'s BURGERS.xcodeproj' pod 'GoogleSignIn', '~> 4.4.0' pod 'GoogleUtilities', '~> 6.3.0' pod 'OneSignal', '2.11.0' pod 'FBSDKCoreKit', '5.7.0' pod 'FBSDKLoginKit', '5.7.0' pod 'FBSDKShareKit', '5.7.0' end



-Finally, run inside the platforms/ios "pod install --verbose".

After that I am able to build!
peterpeterparker commented 4 years ago

The main problem is that all these three plugins plugins use pods and they all try to create a new pod target but with the same name! This give a multiple targets error during plugin add.

could you provide a PR to solve this?

deliverymanager commented 4 years ago

No this is just an ugly workaround. The main issue is that the podfile is not edited correclty by none of those 3 plugins. So I had to edit it manually each time I add a plugin.

peterpeterparker commented 4 years ago

The main issue is that the podfile is not edited correclty by none of those 3 plugins.

It's what I mean, could you provide a PR to then "let the plugin edit correctly the podfile"?

deliverymanager commented 4 years ago

I will try!

peterpeterparker commented 4 years ago

Coolio, thx @deliverymanager !

spinninghamster commented 4 years ago

For anyone else with the same problem a very tiring workaround when you are trying to install other plugins all together that require pods like: "cordova-plugin-googleplus", "onesignal-cordova-plugin", "cordova-plugin-facebook4"

The main problem is that all these three plugins plugins use pods and they all try to create a new pod target but with the same name! This give a multiple targets error during plugin add.

So they workaround that I have found is:

  • First replace the platforms/ios/Podfile to become empty each time I add a plugin that uses a pod
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
  • Then install the plugin
  • Finally replace the podifile so that it contains all the pods for all the plugins used.

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!
target 'Franky\'s BURGERS' do
  project 'Franky\'s BURGERS.xcodeproj'
  pod 'GoogleSignIn', '~> 4.4.0'
  pod 'GoogleUtilities', '~> 6.3.0'
  pod 'OneSignal', '2.11.0'
  pod 'FBSDKCoreKit', '5.7.0'
  pod 'FBSDKLoginKit', '5.7.0'
  pod 'FBSDKShareKit', '5.7.0'
end

-Finally, run inside the platforms/ios "pod install --verbose".

After that I am able to build!

Strange. I get the exact same error, but when I check the file everything shows correctly.

deliverymanager commented 4 years ago

In your case are you adding multiple plugins?

deliverymanager commented 4 years ago

After much search I concluded that the real problem the podfile is not edited correctly when we have multiple plugins is the app name. If the app contains an apostrophe (') then it breaks. It also breaks when we have special chars that are replace by underscore.

The naming of the target is handled by the cordova-ios.

mahnuh commented 4 years ago

@deliverymanager it also breaks with app names that only contain letters, no spaces or special chars.

deliverymanager commented 4 years ago

In my case I have tried it with an app name eg: "Flower Shop" which just contains an empty space. But the prod file breaks and is not edited correctly when build with "Betty's Shop"

deliverymanager commented 4 years ago

OK after all the fuzz, what I ended up doing to resolve is to give a friendly name, single string. Then inside xCode before building, I corrected the Display Name to the actual one.

EDIT: This method fails when you try to upload on Apple Store, due to signing error that is cause by the change in the app name inside xCode. So dead end.

I think this error does not have to do with facebook cordova plugin. It is a mishandling of app name at the cordova-ios.

deliverymanager commented 4 years ago

Finally. The only robust solution I found was to name the project with an id that is in English and then use a plugin cordova transations to name the app in the language I wanted in the first place. This way the podfile is edited correctly and there is no need for any special workaround besides the translations.