Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build an Appcelerator Titanium iOS Module that requires a CocoaPods pod

I would like to build a native iOS module that requires a CocoaPods pod (https://cocoapods.org/pods/NearbyMessages).

I created a new module using the Titanium Command Line Interface:

ti create --type=module --platforms=ios ...

I followed the instructions from CocoaPods (https://guides.cocoapods.org/using/using-cocoapods.html) to create a Podfile:

platform :ios, '9.0'

target 'MyModule' do
  pod 'NearbyMessages'
end

I placed the Podfile into the "iphone" directory of my iOS module directory:

MyModule
 - LICENCE
 - README
 - assets
 - documentation
 - example
 - iphone
   - Podfile
   - ...
   - timodule.xml
   - titanium.xcconfig   

I installed the pod using the following command:

pod install

I opened XCode with the newly created *.xcworkspace file and added the following line to the end of the titanium.xcconfig file:

#include "Pods/Target Support Files/Pods-MyModule/Pods-MyModule.debug.xcconfig"

But unfortunately this leads to several errors, like:

  • "'Ti.Module.h' file not found" in the header file of my module
  • several "cannot use 'super' because it is a root class" in the implementation file of my module

I tried different variations of including the Pods config file but none of them were successful.

Can anybody please tell me how a correct XCode setup should look like to use the NearbyMessages pod in a native iOS module?

Thanks in advance and best regards!

like image 427
René Avatar asked Jun 06 '16 09:06

René


1 Answers

The build.py file needs to be updated to use the workspace file instead. Inside the build_module method, add the -workspace and -scheme parameters to xcodebuild. The lines should look like this:

rc = os.system("xcodebuild -workspace %s.xcworkspace -scheme %s -sdk iphoneos -configuration Release" %(manifest['name'],manifest['name']))

rc = os.system("xcodebuild -workspace %s.xcworkspace -scheme %s -sdk iphonesimulator -configuration Release" %(manifest['name'],manifest['name']))

After making this change, python build.py should work successfully.

I'm just at the point of figuring this out for myself, so there may need to be more steps, but that got me past the point you are at.

like image 135
Ron Piwetz Avatar answered Nov 13 '22 10:11

Ron Piwetz