floatinghotpot / cordova-mobfox-pro

Enhanced MobFox plugin for Cordova/PhoneGap. Banner, Interstitial and Video Ad. Support many other Ad network with server-side integration.
8 stars 3 forks source link

Will not compile... #1

Closed jgberg closed 10 years ago

jgberg commented 10 years ago

Hello Raymond, Thanks for creating this plugin. There's a problem though. After I've installed it under a new install of Cordova 3.6 by cordova plugin add com.rjfun.cordova.mobfox And then I try to compile it using Xcode 6.x via: cordova build the compilation fails with the following error:

In file included from /Users/xxx/Documents/app-Cordova3.6/platforms/ios/App/Plugins/com.rjfun.cordova.mobfox/CDVMobFox.m:2:
In file included from App/Plugins/com.rjfun.cordova.mobfox/CDVMobFox.h:5:
App/Plugins/com.rjfun.cordova.mobfox/MobFoxAds.h:3:9: fatal error: 'MobFox/MobFox.h' file not found
#import <MobFox/MobFox.h>
        ^
1 error generated.

** BUILD FAILED **

The following build commands failed:
    CompileC build/App.build/Debug-iphonesimulator/App.build/Objects-normal/i386/CDVMobFox.o App/Plugins/com.rjfun.cordova.mobfox/CDVMobFox.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Error: /Users/xxx/Documents/app-Cordova3.6/platforms/ios/cordova/build: Command failed with exit code 65
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Process.ChildProcess._handle.onexit (child_process.js:802:5)
floatinghotpot commented 10 years ago

the header file is in the MobFox.framework coming with plugin, it should be copied and added to project automatically.

could you please check whether it exists?

jgberg commented 10 years ago

Here are the files located under the Cordova app in ./platforms/ios/App/Plugins/com.rjfun.cordova.mobfox/

CDVMobFox.h CDVMobFox.m libGoogleAdMobAds.a libMovFoxAds.a MobFox.framework MobFoxAds.h

The header is there, but it's not finding it...

floatinghotpot commented 10 years ago

Can you check whether the MobFox.framework has been added to the project?

If not, manually add it.

add_framework

jgberg commented 10 years ago

I haven't even looked at Xcode yet because it won't compile with: cordova build which has to run first. And it won't. But anyway, here's what you asked for... screen shot 2014-10-14 at 7 18 13 pm

floatinghotpot commented 10 years ago

You don't have to run cordova build, just let Xcode to build and check the error.

Sometimes the cordova CLI script does not add file correctly, and I found it often fail to bulid or install after upgrade to Cordova v3.6.3. But it works fine in Xcode.

cordova prepare must be run first.

jgberg commented 10 years ago

No that isn't right: You have to run Cordova Build if you work in in CordovaApp/www so that it gets copied into the platforms directory, each and every time you make a change there. And working without Xcode that way is documented by Apache.

With that said, I did a cordova prepare which fixed nothing.

Can you please simply create a vanilla Cordova 3.6 app, install your plugin and do a cordova build... that's all I did... It's completely vanilla and should work...

I think the way you're including it isn't right... It's like not on the path for the include... I've given you the exact compilation line above... But i'm not an Xcode guy, so I don't know how to fix it... Even though i've done C++ and C for years and years, Objective-C and Xcode looks like a rats nest to me and I'm afraid to touch anything.

floatinghotpot commented 10 years ago

It is cordova prepare do the copying work.

cordova prepare # copy
cordova build # copy and build
cordova run # copy, build, and install to device/simulator to run

After running this command, please import the ios project into Xcode, to see what was happening. I guess the MobFox.framework is not added correctly by cordova CLI. (very minor situation it may happen with unknown reason)

jgberg commented 10 years ago

That's what I did and it fails on the build before I ever get to Xcode... It fails on the 2nd line above...

floatinghotpot commented 10 years ago

only run cordova prepare, it only copy file, and will not build.

then import into Xcode, and check whether MobFox.framework is added, like the screenshot I post.

floatinghotpot commented 10 years ago

it's not wrong. any header file in a framework should be include like this.

jgberg commented 10 years ago

From what I can see, it's there... screen shot 2014-10-14 at 8 21 38 pm

floatinghotpot commented 10 years ago

yes, i see, it's weird.

I re-test the plugin with following commands, and ... no problem.

cordova create test1 com.rjfun.test1 test1; 
cd test1; 
cordova platform add ios; 
cordova platform add android;
cordova plugin add com.rjfun.cordova.mobfox;
rm -r www/*; 
cp -r plugins/com.rjfun.cordova.mobfox/test/* www/; 
cordova prepare;
cordova run android; 
cordova run ios;

it build okay with cordova CLI, but has some problem connecting device and install.

so I build it in xcode and run, i get following screen:

iphone_sim_mobfox

floatinghotpot commented 10 years ago

can you try re-create a clean project and test my steps above?

jgberg commented 10 years ago

I have a clean project... I have done this a lot already. Are you running Cordova 3.6 ? I also don't do android yet. The only difference is that that my create line is slightly different than yours: cordova create zines-Cordova3.6 com.blahblah.app Zines Your directory and app name are the same... maybe that causes and issue?

When I look at the 'mobfox framework' in your plugin it does not have symbolic links at the top level to reach in the A directory and below... I see this described in some docs somewhere... Does your install have such symlinks? The error suggest the framework isn't setup right, causing the import to fail..

So heres an ls of the MobFox.framework installed in your plugin:

 ls -RF MobFox.framework
Versions/

MobFox.framework/Versions:
A/

MobFox.framework/Versions/A:
Headers/    MobFox      Resources/

MobFox.framework/Versions/A/Headers:
MobFox.h                    MobFoxTableViewHelper.h
MobFoxBannerView.h              MobFoxVideoInterstitialViewController.h
MobFoxNativeAdController.h

MobFox.framework/Versions/A/Resources:
Info.plist          LICENSE.txt         MPCloseButtonX.png      README.markdown
LICENSE             MPAdBrowserController.nib   MPCloseButtonX@2x.png       README.txt
floatinghotpot commented 10 years ago

Yes, I am using cordova 3.6.3

As to the symbol links. As I cannot find any clue from your problem, so I just did a update, and remove the symbol links from MobFox.framework. (but frankly, it should be any problem, as I tested both pass before commit and publish. so weird)

I cannot explain your problem. Can you pack your project in a zip and give me a download link?

jgberg commented 10 years ago

What symbolic links do you have? I have NONE in the plugin or in the MobFox.framework... Can you do an 'ls -RF" of the MobFox.framework?

floatinghotpot commented 10 years ago

BTW, my env:

Mac OS: v10.9.5 Xcode: v6.0.1 Cordova: v3.6.3

Any difference?

jgberg commented 10 years ago

I'm running the latest of all three... the same as you. Cordova: 3.6.3-0.2.13 (via cordova -v)

floatinghotpot commented 10 years ago

No clue at all.

The only thing I can imagine is the framework is not recognized correctly.

Can you remove the MobFox.framework, and then re-add it manually?

floatinghotpot commented 10 years ago

downloaded, may remove the file now.

floatinghotpot commented 10 years ago

I did not find any symbol links in the MobFox.framework of your project. It's the root cause.

I think cordova CLI did not handle the symbol links correctly.

Can you update to plugin v1.0.1? I just removed all the symbol links and use direct files.

jgberg commented 10 years ago

how do i update to plugin v1.0.1?

floatinghotpot commented 10 years ago
cordova plugin rm com.rjfun.cordova.mobfox
cordova plugin add com.rjfun.cordova.mobfox

then check the config.xml in plugin folder and make sure the version code is: 1.0.1, like this:

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
    xmlns:android="http://schemas.android.com/apk/res/android"
    id="com.rjfun.cordova.mobfox"
    version="1.0.1">
jgberg commented 10 years ago

That worked! That is: cordova prepare;cordova build resulted in a successful compile.

Ok... I'll look at using it in the morning... Thanks.

jgberg commented 10 years ago

getting this compilation issue under Xcode: screen shot 2014-10-14 at 9 34 23 pm

floatinghotpot commented 10 years ago

it's a warning when assign long to int, may ignore it.

jgberg commented 10 years ago

I just like cleanliness... but ok