iOS Enterprise: Build a plugin and link it

Hi,

how did you create for instance the twitter plugin and make it possible to just link to it in a project and then it magically works? :slight_smile:

If we build our plugins as part of the app project (by dragging in the plugin xcode projects as child projects of the app and link to the product) everything works fine.

If we build the plugins from a different location as standalone xcode projects, they build correctly, but when linking to the .a file, the plugin is not working.

Can’t find any documentation on how to do this. We’d like to have the plugins separated from the apps, or else there will be several places to update code whenever we change something in the plugin(s).

Thank you! [import]uid: 21746 topic_id: 34658 reply_id: 334658[/import]

Yeah, this is something I’m also struggling with… would be great to get some more docs on how to do this. [import]uid: 70847 topic_id: 34658 reply_id: 137715[/import]

Hi,

can someone shed some light here, please? We have tested one million different things (the plugin works, we have tested different ways of building and linking). It’s almost as if the plugin project has to be part of the app project at some point to work, and then it can be moved to it’s own project. But if it is then added to a different app, it does not work there…

So, point by point, how do we create one single static library “.a” file that can be dragged into any of our Enterprise projects, linked, and just work? [import]uid: 21746 topic_id: 34658 reply_id: 137749[/import]

I’ll get an answer for you guys asap…
[import]uid: 10668 topic_id: 34658 reply_id: 137781[/import]

Take a look at the App project. It demonstrates how to structure your app with a plugin.

Specifically for iOS plugins, you’ll notice a Plugin.xcodeproj. The output of that project is a .a static library. This is essentially what we are doing with the libnative-popup-twitter.a plugin.

Incidentally, the App.xcodeproj is structured to maximize convenience for using that plugin in your project. It lists this .a file as a dependency and automagically builds it. So you can always just pull the .a lib output of that and reuse it elsewhere if you wish.

[import]uid: 26 topic_id: 34658 reply_id: 137813[/import]

Hi Walter,

thanks for replying. Unfortunately, your advice on how to do this only gets us halfway to the goal. I’ll try to explain with a couple of use cases:

Usecase 1, success

  1. Copy App project from Enterprise folder
  2. Move all game files into Corona folder
  3. Implement our plugin code in the plugin project
  4. Build, run => works fine

Usecase 2, fails

  1. Copy App project from Enterprise folder - We’ll call this PROJECT A from now on
  2. Implement plugin code in the plugin project
  3. Build, run, archive => works fine
  4. Copy App project from Enterprise folder - PROJECT B
  5. Remove the plugins project in PROJECT B
  6. Move all game files into Corona folder
  7. Copy the plugin_library.a file from PROJECT A’s build folder into PROJECT B
  8. Link plugin_library.a
  9. Build, run => fails

The error message coming from Usecase 2 is:

lua_pcall failed with status: 2, error message is: module ‘plugin.library’ not found:resource (plugin.library.lu) does not exist in archive
no field package.preload[‘plugin.library’]
So, if we have to go the Usecase 1 route, we’ll have 10-20-30 copies of the same plugin source code laying around. Imagine the mess…

Please advice. Thanks! [import]uid: 21746 topic_id: 34658 reply_id: 137917[/import]

What architecture are you grabbing for the static library: iphoneos or iphoneos-simulator? And are you trying to run on device or Xcode simulator?

I bet there’s a mismatch here. For example, if I grab the iphoneos library and try to run on Xcode simulator, I see your error. But if I’m consistent, your issue goes away.

So the question is how do you create a static library that works on both device and simulator. Here’s how:

lipo -create “/path/to/iphoneos/staticlibrary.a” “/path/to/iphoneos-simulator/staticlibrary.a” -output “/path/to/dst/staticlibrary.a”
[import]uid: 26 topic_id: 34658 reply_id: 137990[/import]

Ahh, Walter, you are a genious :slight_smile: Thanks. I googled a little based on your advice and found this:

http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4

I opened the plugin project, selected the target and chose Add Build Phase > Add Run Script, pasted the script, and also the optional line at the end that opens the final build folder in Finder.

Copied the static library to our games projects, linked it and => SUCCESS :slight_smile:

Thanks. We’re now totally ready to sell our sweet Corona plugins. Anyone need Chartboost (iOS + Android), Airpush (Android) or TapJoy (iOS)? :smiley: [import]uid: 21746 topic_id: 34658 reply_id: 138136[/import]

Yeah, this is something I’m also struggling with… would be great to get some more docs on how to do this. [import]uid: 70847 topic_id: 34658 reply_id: 137715[/import]

Hi,

can someone shed some light here, please? We have tested one million different things (the plugin works, we have tested different ways of building and linking). It’s almost as if the plugin project has to be part of the app project at some point to work, and then it can be moved to it’s own project. But if it is then added to a different app, it does not work there…

So, point by point, how do we create one single static library “.a” file that can be dragged into any of our Enterprise projects, linked, and just work? [import]uid: 21746 topic_id: 34658 reply_id: 137749[/import]

I’ll get an answer for you guys asap…
[import]uid: 10668 topic_id: 34658 reply_id: 137781[/import]

Take a look at the App project. It demonstrates how to structure your app with a plugin.

Specifically for iOS plugins, you’ll notice a Plugin.xcodeproj. The output of that project is a .a static library. This is essentially what we are doing with the libnative-popup-twitter.a plugin.

Incidentally, the App.xcodeproj is structured to maximize convenience for using that plugin in your project. It lists this .a file as a dependency and automagically builds it. So you can always just pull the .a lib output of that and reuse it elsewhere if you wish.

[import]uid: 26 topic_id: 34658 reply_id: 137813[/import]

Hi Walter,

thanks for replying. Unfortunately, your advice on how to do this only gets us halfway to the goal. I’ll try to explain with a couple of use cases:

Usecase 1, success

  1. Copy App project from Enterprise folder
  2. Move all game files into Corona folder
  3. Implement our plugin code in the plugin project
  4. Build, run => works fine

Usecase 2, fails

  1. Copy App project from Enterprise folder - We’ll call this PROJECT A from now on
  2. Implement plugin code in the plugin project
  3. Build, run, archive => works fine
  4. Copy App project from Enterprise folder - PROJECT B
  5. Remove the plugins project in PROJECT B
  6. Move all game files into Corona folder
  7. Copy the plugin_library.a file from PROJECT A’s build folder into PROJECT B
  8. Link plugin_library.a
  9. Build, run => fails

The error message coming from Usecase 2 is:

lua_pcall failed with status: 2, error message is: module ‘plugin.library’ not found:resource (plugin.library.lu) does not exist in archive
no field package.preload[‘plugin.library’]
So, if we have to go the Usecase 1 route, we’ll have 10-20-30 copies of the same plugin source code laying around. Imagine the mess…

Please advice. Thanks! [import]uid: 21746 topic_id: 34658 reply_id: 137917[/import]

What architecture are you grabbing for the static library: iphoneos or iphoneos-simulator? And are you trying to run on device or Xcode simulator?

I bet there’s a mismatch here. For example, if I grab the iphoneos library and try to run on Xcode simulator, I see your error. But if I’m consistent, your issue goes away.

So the question is how do you create a static library that works on both device and simulator. Here’s how:

lipo -create “/path/to/iphoneos/staticlibrary.a” “/path/to/iphoneos-simulator/staticlibrary.a” -output “/path/to/dst/staticlibrary.a”
[import]uid: 26 topic_id: 34658 reply_id: 137990[/import]

Ahh, Walter, you are a genious :slight_smile: Thanks. I googled a little based on your advice and found this:

http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4

I opened the plugin project, selected the target and chose Add Build Phase > Add Run Script, pasted the script, and also the optional line at the end that opens the final build folder in Finder.

Copied the static library to our games projects, linked it and => SUCCESS :slight_smile:

Thanks. We’re now totally ready to sell our sweet Corona plugins. Anyone need Chartboost (iOS + Android), Airpush (Android) or TapJoy (iOS)? :smiley: [import]uid: 21746 topic_id: 34658 reply_id: 138136[/import]

i might come back to you about tapjoy etc :slight_smile:

and sorry for hijacking! [import]uid: 90610 topic_id: 34658 reply_id: 140324[/import]

Would be great if you shared a tutorial on how to achieve a simple plugin development with Enterprise :wink:

J. [import]uid: 19590 topic_id: 34658 reply_id: 140444[/import]

@haakon, I’m insterested in Chartboost (currently only on iOS, but I do intend to publish Android / Kindle versions too.) What might be the next steps for those who are interested in using it?

Naomi [import]uid: 67217 topic_id: 34658 reply_id: 140566[/import]

Hi,

we’re Enterprise users, thus we’re able to implement any SDK in the world. That’s what you need to get Chartboost going.

And sorry I don’t have the time to create a tutorial on how to create plugins => that’s really something Coronalabs needs to do. However, you’ll get quite far with the example projects in the Enterprise folder, and you’ll get help from the staff quite fast when asking on the forums. [import]uid: 21746 topic_id: 34658 reply_id: 140625[/import]

Hi haakon, about Chartboost, from what you posted, if I’m not mistaken, your intention is to sell Chartboost plugin? If so, what do I need to do to proceed to the next step, such as finding out more about it (cost, integration process, etc.)

Thanks!

Naomi [import]uid: 67217 topic_id: 34658 reply_id: 140641[/import]