ionic-team / ionic-native-google-maps

Google maps plugin for Ionic Native
Other
221 stars 125 forks source link

Ionic 4- Compiles/Deploys fine to iOS device from CLI, but linking error when compiling within XCode #211

Closed mxdmedia closed 5 years ago

mxdmedia commented 5 years ago

I'm submitting a ... (check one with "x")

If you choose 'problem or bug report', please select OS: (check one with "x")

cordova information: (run $> cordova plugin list)

cordova-plugin-device 2.0.2 "Device"
cordova-plugin-googlemaps 2.6.2 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.0.1 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"

If you use @ionic-native/google-maps, please tell the package.json (only @ionic-native/core and @ionic-native/google-maps are fine mostly)

"@ionic-native/core": "^5.0.0",
 "@ionic-native/google-maps": "^5.5.0",

Current behavior: Building/Running from the CLI worked fine until I installed/started using ionic-native-google-maps and the associated cordova plugin. Once I tried to add a map to my project, building/running from the CLI via ionic cordova run ios works perfectly, however opening the project in XCode and trying to build from there throws the following:

ld: library not found for -lPods-{MY-APP_NAME}
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am currently running the latest version of xcode, and the latest version of cocoapod (1.6.1).

Expected behavior: I would expect the app to build in both the CLI as well as in XCode.

Related code, data or error log (please format your code or data):

First off, I have a repo of an example here (with the API keys removed): https://github.com/mxdmedia/ionic-gmap-test In order to generate the project (in case this is where I went wrong) I did the following (again, API keys sanitized)

ionic start GMapsTest sidemenu
cd GMapsTest/
ionic integrations enable cordova
ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="MY-API-KEY" --variable API_KEY_FOR_IOS="MY-API-KEY"
npm install --save @ionic-native/google-maps
ionic cordova prepare ios
ionic cordova run ios  #<-- fails at cert signing, open in XCode, set up my cert
ionic cordova run ios  #<-- successful build, pushes to phone, all runs fine.

However, if I then open the project in XCode, the build fails with:

ld: library not found for -lPods-GMapsTest
clang: error: linker command failed with exit code 1 (use -v to see invocation)
pk563 commented 5 years ago

@mxdmedia I think you gotta open your xcode workspace file and sign with your developer account first before running again.

mxdmedia commented 5 years ago

The certificate is definitely signed- as I mentioned in my second to last step (in the comment), after the first CLI build fails (due to the certificate not being signed yet). At that step, I open everything up in XCode and set up the certificate signing, etc.. Upon running the CLI command a second time, everything compiles, and it runs fine on the device.

My issue is that if I try to then compile/run it from within XCode (as I would do to send the app off to the app store review process), the build fails- not due to a certificate issue, but because of that linking step.

Edit- Also, if I remove the google maps cordova plugin, and the google maps ionic-native component, all compiles without issue in XCode and deploys to the device. Thus I do not believe this is a cert signing issue.

wf9a5m75 commented 5 years ago

What's the cordova, cordova-ios, and cocoapod versions?

mxdmedia commented 5 years ago

Cordova is: 9.0.0 (cordova-lib@9.0.1) cordova-ios is: cordova-ios@5.0.1 cocoapod is: 1.6.1

wf9a5m75 commented 5 years ago

I guess your pod repository is old. Please try this:

$> cd platform/ios/

$> pod repo update 

$> pod install
mxdmedia commented 5 years ago

I gave that a try, however it did not seem to help. Still getting the same error on build within XCode.

wf9a5m75 commented 5 years ago

Please tell me which file (filename) do you open.

mxdmedia commented 5 years ago

The file is platforms/ios/MapTest.xcodeproj

Edit: And that seemed to be the issue. I didn't notice the .xcworkspace file that was generated. My last gmaps project was Ionic 3, and I dont remember there being such a file. Thanks for pointing me in the right direction!