kriserickson / cordova-piwik-plugin

Piwik Plugin for Apache Cordova
4 stars 0 forks source link

Linker error in iOS #1

Closed petehobo closed 9 years ago

petehobo commented 9 years ago

Hi Kris,

Thanks for the plugin, but I'm having trouble getting it to work on iOS. Any help would be appreciated.

Versions:

I created a sample application with:

  cordova create hello com.example.hello HelloWorld
  cd hello/
  cordova platform add ios
  cordova plugin add https://github.com/kriserickson/cordova-piwik-plugin

then ran the build:

  cordova build ios

That failed (as you hinted it might in the README, I'm including for completeness) with

The following build commands failed:
    CompileC build/HelloWorld.build/Debug-iphonesimulator/HelloWorld.build/Objects-normal/i386/PiwikTracker.o HelloWorld/Plugins/com.storefront.cordova.piwik/PiwikTracker.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Error code 65 for command: xcodebuild with args: -xcconfig,/Users/pete/tmp/hello/platforms/ios/cordova/build-debug.xcconfig,-project,HelloWorld.xcodeproj,ARCHS=i386,-target,HelloWorld,-configuration,Debug,-sdk,iphonesimulator,build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=/Users/pete/tmp/hello/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/pete/tmp/hello/platforms/ios/build/sharedpch
ERROR building one of the platforms: Error: /Users/pete/tmp/hello/platforms/ios/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project

I also tried

cordova build ios --device

as per http://stackoverflow.com/a/23093818 , but I got the same error, though with a different architecture (armv7 instead of i386).

Following your note in README.md, I opened the project in XCode, and changed the C dialect to GNU99. I tried all the others, but GNU99 seemed best (2 errors instead of 14 or so with the default). Unfortunately, I still get the following linker error:

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_CLLocationManager", referenced from:
      objc-class-ref in PiwikLocationManager.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

and despite Googling various different things I'm not having any luck. Can you help?

Thanks in advance,

Pete

PS If I check out the SDK, I seem to be able to compile it standalone, but I can't work out the importance differences in the XCode projects (there seem to be too many combinations to try), not do I know if there's a way to bring that compiled code into my Cordova project

kriserickson commented 9 years ago

Pete,

Sorry for the problems you are having with iOS and the plugin. I am the farthest person from an Xcode expert (whenever I have to work in it, I spend half my time Googling to get things like the linker working properly). The error from Armv7 (compiling for a device) looks like the Piwik library was not properly included (linker error), whereas the error on i386 (the simulator) I have no idea idea (Error code 65 is a pretty broad error). Have you tried building in XCode instead of from the command ilne, it might give you more information. As per your specs, they look pretty similar to what I was using, though I haven't compiled it against Cordova 4.3 yet...

Sorry I couldn't be of more help,

Kris

(P.S. You might try to see if you can get the Piwik sample app compiling https://github.com/piwik/piwik-sdk-ios)

On Tue, Apr 14, 2015 at 5:41 AM, Pete Holberton notifications@github.com wrote:

Hi Kris,

Thanks for the plugin, but I'm having trouble getting it to work on iOS. Any help would be appreciated.

Versions:

  • System Version: OS X Mavericks 10.9.5 (13F1066) (have also tried on Yosemite)
  • Kernel Version: Darwin 13.4.0
  • Cordova 4.3.0
  • Xcode 6.0.1 (6A317)

I created a sample application with:

cordova create hello com.example.hello HelloWorld cd hello/ cordova platform add ios cordova plugin add https://github.com/kriserickson/cordova-piwik-plugin

then ran the build:

cordova build ios

That failed (as you hinted it might in the README, I'm including for completeness) with

The following build commands failed: CompileC build/HelloWorld.build/Debug-iphonesimulator/HelloWorld.build/Objects-normal/i386/PiwikTracker.o HelloWorld/Plugins/com.storefront.cordova.piwik/PiwikTracker.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler (1 failure) Error code 65 for command: xcodebuild with args: -xcconfig,/Users/pete/tmp/hello/platforms/ios/cordova/build-debug.xcconfig,-project,HelloWorld.xcodeproj,ARCHS=i386,-target,HelloWorld,-configuration,Debug,-sdk,iphonesimulator,build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=/Users/pete/tmp/hello/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/pete/tmp/hello/platforms/ios/build/sharedpch ERROR building one of the platforms: Error: /Users/pete/tmp/hello/platforms/ios/cordova/build: Command failed with exit code 2 You may not have the required environment or OS to build this project

I also tried

cordova build ios --device

as per http://stackoverflow.com/a/23093818 , but I got the same error, though with a different architecture (armv7 instead of i386).

Following your note in README.md, I opened the project in XCode, and changed the C dialect to GNU99. I tried all the others, but GNU99 seemed best (2 errors instead of 14 or so with the default). Unfortunately, I still get the following linker error:

Undefined symbols for architecture armv7: "_OBJCCLASS$_CLLocationManager", referenced from: objc-class-ref in PiwikLocationManager.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

and despite Googling various different things I'm not having any luck. Can you help?

Thanks in advance,

Pete

— Reply to this email directly or view it on GitHub https://github.com/kriserickson/cordova-piwik-plugin/issues/1.

petehobo commented 9 years ago

Thanks for the quick response Kris. I'm in the same boat with XCode - been Googling a lot the last few days.

I'm not too stressed by the 65 error (it occurred before I changed the compiler as you suggested in the readme). The linker error comes from XCode.

I'll keep digging, and see if I can get the sample app working as you suggest. I'll let you know if I find anything useful.

Thanks again,

Pete

akush commented 9 years ago

update?

petehobo commented 9 years ago

No update from me, no. I hope to get back to this in the next week or two, but it's a lower priority for me at the moment

kriserickson commented 9 years ago

Sorry it took so long to get back to this, I had to install the plugin on a different project. You are required to make some changes in XCode for the plugin to work (if someone knows how to automate this, any suggestions would be helpful), you have to switch the C Language Dialect from C99 to GNU99 (see attachment). Also you have to make sure that Core Data, Core Location, Core Graphics and UIKit and frameworks have been added (I've added them to plugin.xml so they should be included now, but I have no idea how to automate changeing the C Language Dialect).

image

petehobo commented 9 years ago

Awesome - thanks Kris. Sorry for not getting any investigation done my side. I'm hoping to get back to my app soon, so will check it out. In the meantime, I'll close, and will reopen if I find any problems.

kriserickson commented 9 years ago

I've update the Piwik SDK and removed the requirement to change the C Language dialect (it appears that option is no longer in XCode 6.4 anyway.). Now all you have to do is a drag in a xcdatamodeld directory (which isn't optimal, but until Cordova plugins support adding a folders by reference it will be necessary).