iOS Question Share to social media functionality - Help with inline objC

henrywood

Active Member
Licensed User
Hey !

I am trying to integrate social sharing functionality in my app through Objective C.

Could someone validate the methology - in particular the Objective C code ?

I would like to get an event in B4i when the user has completed sharing.

UPDATED: 09-05-2015: THIS VERSION DOES NOT WORK - PLEASE SEE POST #101 FOR A WORKING VERSION:
http://www.b4x.com/android/forum/threads/share-to-social-media-functionality-help-with-inline-objc.52849/page-6#post-336177

A BIG THANK YOU TO ALL WHO HELPED ME WITH THIS CODE !

Here is my code:

B4X:
'Code module

Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'Public variables can be accessed from all modules.

End Sub


#If OBJC

- (IBAction)shareToSocialMedia:(NSString *)txt (NSString *)url: (NSString *)image
{
   //NSString *text = @"How to add Facebook and Twitter sharing to an iOS app";
   NSString *text = txt;
   //NSURL *url = [NSURL URLWithString:@"http://roadfiresoftware.com/2014/02/how-to-add-facebook-and-twitter-sharing-to-an-ios-app/"];
   NSURL *url = [NSURL URLWithString:url];
   //UIImage *image = [UIImage imageNamed:@"roadfire-icon-square-200"];
   UIImage *image = [UIImage imageNamed:image];

   UIActivityViewController *controller =
   [[UIActivityViewController alloc]
   initWithActivityItems:@[text, url, image]
   applicationActivities:nil];

  controller.excludedActivityTypes = @[UIActivityTypePostToWeibo,
  UIActivityTypeMessage,
  UIActivityTypeMail,
  UIActivityTypePrint,
  UIActivityTypeCopyToPasteboard,
  UIActivityTypeAssignToContact,
  UIActivityTypeSaveToCameraRoll,
  UIActivityTypeAddToReadingList,
  UIActivityTypePostToFlickr,
  UIActivityTypePostToVimeo,
  UIActivityTypePostToTencentWeibo,
  UIActivityTypeAirDrop];

   [self presentViewController:controller animated:YES completion:^{
     [self sharedone];
   }];
}

- (void)sharedone:
{
   int status = 1;
   [B4IObjectWrapper raiseEvent:self :@"onsharingdone:" :@[@((int)status)]];
   //[B4IObjectWrapper raiseEventFromDifferentThread:self :@"onsharingdone:" :@[@((int)status)]];

}

#end if

Sub onSharingDone(Status As Int)
   Log("onSharingDone: Status = " & Status)
End Sub

Sub ShareToSocialMedia(txt As String, theURL As String, imageFile As String)

   Dim NativeMe As NativeObject = Me
   NativeMe.RunMethod("shareToSocialMedia:", Array As Object(txt, theURL, imageFile))

End Sub
 
Last edited:

narek adonts

Well-Known Member
Licensed User
changing the completion to a void will give you a notification that the view was presented.
you need to add this just after initializing UIActivityViewController

[controller setCompletionHandler:^(NSString*activityType, BOOL completed) {
[self.bi raiseEvent:nil event:mad:"activity_completed::" params:mad:[@((BOOL)completed),(activityType)]];
}];

and add

Sub activity_completed(status as boolean, type as string)

End sub

in the module where your OBJC code is situated.

Narek
 

henrywood

Active Member
Licensed User
Just in case somebody else needs the sharing functionality here with Narek's changes

B4X:
'Code module

Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'Public variables can be accessed from all modules.
   Private myPage As Page

End Sub


#If OBJC

  - (IBAction)share2SocialMedia:(NSString *)txt url:(NSString *)theurl img:(NSString *)theimg
{
   //NSString *text = @"How to add Facebook and Twitter sharing to an iOS app";
   NSString *text = txt;
   //NSURL *url = [NSURL URLWithString:@"http://roadfiresoftware.com/2014/02/how-to-add-facebook-and-twitter-sharing-to-an-ios-app/"];
   NSURL *url = [NSURL URLWithString:theurl];
   //UIImage *image = [UIImage imageNamed:@"roadfire-icon-square-200"];

  if([img hasPrefix:@"http://"] || [img hasPrefix:@"https://"] ) {
     UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:theimg]]];
   } else {
     UIImage *image = [UIImage imageNamed:theimg];
   }

   UIActivityViewController *controller =
   [[UIActivityViewController alloc]
   initWithActivityItems:@[text, url, image]
   applicationActivities:nil];

  controller.excludedActivityTypes = @[UIActivityTypePostToWeibo,
  UIActivityTypeMessage,
  UIActivityTypeMail,
  UIActivityTypePrint,
  UIActivityTypeCopyToPasteboard,
  UIActivityTypeAssignToContact,
  UIActivityTypeSaveToCameraRoll,
  UIActivityTypeAddToReadingList,
  UIActivityTypePostToFlickr,
  UIActivityTypePostToVimeo,
  UIActivityTypePostToTencentWeibo,
  UIActivityTypeAirDrop];

   [controller setCompletionHandler:^(NSString*activityType, BOOL completed) {
   [self.bi raiseEvent:nil event:@"activity_completed::" params:@[@((BOOL)completed),(activityType)]];
   }];

   [(_myPage).object presentViewController:controller animated:YES completion:nil];
}

#end if

Sub activity_completed(status As Boolean, T As String)
   Log("onSharingDone: Status = " & status & " - Type: " & T)
End Sub

Sub ShareToSocialMedia(p As Page, txt As String, theURL As String, imageFile As String)

   myPage = p
   Dim NativeMe As NativeObject = Me
   NativeMe.RunMethod("share2SocialMedia:", Array As Object(txt, theURL, imageFile))

End Sub
 
Last edited:

Pendrush

Well-Known Member
Licensed User
I'm unabele to compile with OBJC code.
Parsing code. 0.00
Compiling code. 0.03
Compiling layouts code. 0.01
Compiling debugger engine code. 1.02
Building Xcode project 0.02
Sending data to remote compiler. Error
B4i line: 3
Sub Process_Globals
expected method body

Out: Build settings from command line:
ARCHS = armv7
CODE_SIGN_IDENTITY = iPhone

********
error: no visible @interface for 'b4i_modshare' declares the selector 'presentViewController:animated:completion:'
[self presentViewController:controller animated:YES completion:nil];
~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: expected method body
- (IBAction)shareToSocialMedia:(NSString *)txt (NSString *)url (NSString *)image

error: unexpected '@' in program
[self.bi raiseEvent:nil event:mad:"activity_completed:" params:mad::[@((BOOL)completed),(activityType)]];

********
 
Last edited:

Pendrush

Well-Known Member
Licensed User
Error in compile
Parsing code. 0.03
Compiling code. 0.15
Compiling layouts code. 0.04
Compiling debugger engine code. 1.02
Building Xcode project 0.15
Sending data to remote compiler. Error
B4i line: 10
Sub Process_Globals
expected method body

Out: Build settings from command line:
ARCHS = armv7
CODE_SIGN_IDENTITY = iPhone
CONFIGURATION_BUILD_DIR = /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload
OTHER_CODE_SIGN_FLAGS = --keychain XXXXX
PRODUCT_NAME = B4i Example
PROVISIONING_PROFILE = XXXXXXXXXXXXXXXXXXXXXXX

=== BUILD TARGET B4iProject OF PROJECT B4iProject WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
/bin/mkdir -p /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/B4i\ Example.LinkFileList
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example.hmap
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-own-target-headers.hmap
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-non-framework-target-headers.hmap
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-project-headers.hmap
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-generated-files.hmap
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-target-headers.hmap

Create product structure
/bin/mkdir -p /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload/B4i\ Example.app

ProcessInfoPlistFile Payload/B4i\ Example.app/Info.plist B4iProject/B4iProject-Info.plist
cd /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
builtin-infoPlistUtility /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/B4iProject-Info.plist -genpkginfo /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload/B4i\ Example.app/PkgInfo -expandbuildsettings -format binary -platform iphoneos -o /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload/B4i\ Example.app/Info.plist

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/main.o B4iProject/main.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/l1/slt7vrsd5xn8w_n1khzmlq340000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-generated-files.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-own-target-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-target-headers.hmap -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-project-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/armv7 -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload -F../../Libs -MMD -MT dependencies -MF /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/main.d --serialize-diagnostics /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/main.dia -c /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/main.m -o /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/main.o

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.o B4iProject/b4i_main.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/l1/slt7vrsd5xn8w_n1khzmlq340000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-generated-files.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-own-target-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-target-headers.hmap -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-project-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/armv7 -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload -F../../Libs -MMD -MT dependencies -MF /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.d --serialize-diagnostics /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.dia -c /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_main.m -o /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.o
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_main.m:116:47: error: expected method body
- (IBAction)share2SocialMedia:(NSString *)txt (NSString *)url: (NSString *)image
^
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_main.m:121:38: warning: incompatible pointer types sending 'NSURL *' to parameter of type 'NSString *' [-Wincompatible-pointer-types]
NSURL *url = [NSURL URLWithString:url];
^~~
In module 'Foundation' imported from ../../Libs/iCore.h:6:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURL.h:54:43: note: passing argument to parameter 'URLString' here
+ (instancetype)URLWithString:(NSString *)URLString;
^
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_main.m:123:41: warning: incompatible pointer types sending 'UIImage *' to parameter of type 'NSString *' [-Wincompatible-pointer-types]
UIImage *image = [UIImage imageNamed:image];
^~~~~
In module 'UIKit' imported from ../../Libs/iCore.h:7:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIImage.h:63:37: note: passing argument to parameter 'name' here
+ (UIImage *)imageNamed:(NSString *)name; // load from main bundle
^
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_main.m:141:66: warning: expression result unused [-Wunused-value]
[self.bi raiseEvent:nil event:mad:"activity_completed::" params:[@((BOOL)completed),(activityType)]];
^~~~~~~~~~~~~~~~~~
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_main.m:141:99: error: expected identifier
[self.bi raiseEvent:nil event:mad:"activity_completed::" params:[@((BOOL)completed),(activityType)]];
^
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_main.m:143:13: error: no visible @interface for 'B4I' declares the selector 'presentViewController:animated:completion:'
[self.bi presentViewController:controller animated:YES completion:nil];
~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 warnings and 3 errors generated.

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_modshare.o B4iProject/b4i_modshare.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/l1/slt7vrsd5xn8w_n1khzmlq340000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-generated-files.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-own-target-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-target-headers.hmap -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-project-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/armv7 -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload -F../../Libs -MMD -MT dependencies -MF /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_modshare.d --serialize-diagnostics /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_modshare.dia -c /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_modshare.m -o /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_modshare.o


Error: ** BUILD FAILED **


The following build commands failed:
CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.o B4iProject/b4i_main.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
 
Last edited:

henrywood

Active Member
Licensed User
Now I've edited post #4 again, but:

1. I am also not sure if this line:

B4X:
[self.bi raiseEvent:nil event:@"activity_completed::" params:@:[@((BOOL)completed),(activityType)]];
2. Also I don't know if the call to presentViewController is correct - ie. this line:

B4X:
[self presentViewController:controller animated:YES completion:nil];
3. I am unsure about the "correctness" of this line

B4X:
 NativeMe.RunMethod("share2SocialMedia:", Array As Object(txt, theURL, imageFile))
Maybe someone savyy in Objective C could please take a look (@Erel ?) ?
 

narek adonts

Well-Known Member
Licensed User
this line will not work

[self presentViewController:controller animated:YES completion:nil];


instead of self you must add a varibal refering the page which will show the viewcontroller and then refear it in OBJC

for example:

B4X:
Dim myPage as Page=Page1

[(_myPage).object presentViewController:controller animated:YES completion:nil];
 

Pendrush

Well-Known Member
Licensed User
Just tried again, now has 8 errors
Parsing code. 0.00
Compiling code. 0.04
Compiling layouts code. 0.01
Compiling debugger engine code. 1.04
Building Xcode project 0.02
Sending data to remote compiler. Error
B4i line: 64
End Sub
expected method body

Out: Build settings from command line:
ARCHS = armv7
CODE_SIGN_IDENTITY = iPhone
CONFIGURATION_BUILD_DIR = /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload
OTHER_CODE_SIGN_FLAGS = --keychain XXXXX
PRODUCT_NAME = B4i Example
PROVISIONING_PROFILE = 020bfcc6-ff6d-4613-a448-bcd915cc4278

=== BUILD TARGET B4iProject OF PROJECT B4iProject WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
/bin/mkdir -p /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/B4i\ Example.LinkFileList
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example.hmap
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-own-target-headers.hmap
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-non-framework-target-headers.hmap
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-project-headers.hmap
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-generated-files.hmap
write-file /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-target-headers.hmap

Create product structure
/bin/mkdir -p /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload/B4i\ Example.app

ProcessInfoPlistFile Payload/B4i\ Example.app/Info.plist B4iProject/B4iProject-Info.plist
cd /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
builtin-infoPlistUtility /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/B4iProject-Info.plist -genpkginfo /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload/B4i\ Example.app/PkgInfo -expandbuildsettings -format binary -platform iphoneos -o /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload/B4i\ Example.app/Info.plist

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.o B4iProject/b4i_main.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/l1/slt7vrsd5xn8w_n1khzmlq340000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-generated-files.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-own-target-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-target-headers.hmap -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-project-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/armv7 -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload -F../../Libs -MMD -MT dependencies -MF /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.d --serialize-diagnostics /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.dia -c /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_main.m -o /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_main.o

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/main.o B4iProject/main.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/l1/slt7vrsd5xn8w_n1khzmlq340000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-generated-files.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-own-target-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-target-headers.hmap -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-project-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/armv7 -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload -F../../Libs -MMD -MT dependencies -MF /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/main.d --serialize-diagnostics /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/main.dia -c /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/main.m -o /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/main.o

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_modshare.o B4iProject/b4i_modshare.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/l1/slt7vrsd5xn8w_n1khzmlq340000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-generated-files.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-own-target-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-target-headers.hmap -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-project-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/armv7 -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload -F../../Libs -MMD -MT dependencies -MF /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_modshare.d --serialize-diagnostics /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_modshare.dia -c /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_modshare.m -o /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_modshare.o
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_modshare.m:60:47: error: expected method body
- (IBAction)share2SocialMedia:(NSString *)txt (NSString *)url: (NSString *)img
^
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_modshare.m:65:38: warning: incompatible pointer types sending 'NSURL *' to parameter of type 'NSString *' [-Wincompatible-pointer-types]
NSURL *url = [NSURL URLWithString:url];
^~~
In module 'Foundation' imported from ../../Libs/iCore.h:6:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURL.h:54:43: note: passing argument to parameter 'URLString' here
+ (instancetype)URLWithString:(NSString *)URLString;
^
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_modshare.m:67:7: error: use of undeclared identifier 'img'
if([img hasPrefix:mad:"http://"] || [img hasPrefix:mad:"https://"] ) {
^
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_modshare.m:67:37: error: use of undeclared identifier 'img'
if([img hasPrefix:mad:"http://"] || [img hasPrefix:mad:"https://"] ) {
^
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_modshare.m:68:97: error: use of undeclared identifier 'img'
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:img]]];
^
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_modshare.m:70:43: error: use of undeclared identifier 'img'
UIImage *image = [UIImage imageNamed:img];
^
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_modshare.m:74:39: error: use of undeclared identifier 'image'
initWithActivityItems:mad:[text, url, image]
^
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_modshare.m:89:65: error: unexpected '@' in program
[self.bi raiseEvent:nil event:mad:"activity_completed::" params:mad::[@((BOOL)completed),(activityType)]];
^
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_modshare.m:91:6: error: use of undeclared identifier '_myPage'; did you mean '__mypage'?
[(_myPage).object presentViewController:controller animated:YES completion:nil];
^~~~~~~
__mypage
In file included from /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_modshare.m:2:
/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/b4i_modshare.h:13:31: note: '__mypage' declared here
@property (nonatomic)B4IPage* _mypage;
^
1 warning and 8 errors generated.

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/LS_home.o B4iProject/LS_home.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/l1/slt7vrsd5xn8w_n1khzmlq340000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-generated-files.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-own-target-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-all-target-headers.hmap -iquote /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/B4i\ Example-project-headers.hmap -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/armv7 -I/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/Payload -F../../Libs -MMD -MT dependencies -MF /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/LS_home.d --serialize-diagnostics /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/LS_home.dia -c /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/B4iProject/LS_home.m -o /Users/YYYYY/b4iBuild/UploadedProjects/XXXXX/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/LS_home.o


Error: ** BUILD FAILED **


The following build commands failed:
CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_modshare.o B4iProject/b4i_modshare.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
 

narek adonts

Well-Known Member
Licensed User
this is the OBJC code that sould work.

B4X:
#IF OBJC
- (void)share2SocialMedia:(NSString *)txt :(NSString *)theurl :(NSString *)theimg
{
   //NSString *text = @"How to add Facebook and Twitter sharing to an iOS app";
   NSString *text = txt;
   //NSURL *url = [NSURL URLWithString:@"http://roadfiresoftware.com/2014/02/how-to-add-facebook-and-twitter-sharing-to-an-ios-app/"];
   NSURL *url = [NSURL URLWithString:theurl];
   //UIImage *image = [UIImage imageNamed:@"roadfire-icon-square-200"];
   UIImage*image;
  if([theimg hasPrefix:@"http://"] || [theimg hasPrefix:@"https://"] ) {
    image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:theimg]]];
   } else {
     image = [UIImage imageNamed:theimg];
   }

   UIActivityViewController *controller =
   [[UIActivityViewController alloc]
   initWithActivityItems:@[text, url, image]
   applicationActivities:nil];

  controller.excludedActivityTypes = @[UIActivityTypePostToWeibo,
  UIActivityTypeMessage,
  UIActivityTypeMail,
  UIActivityTypePrint,
  UIActivityTypeCopyToPasteboard,
  UIActivityTypeAssignToContact,
  UIActivityTypeSaveToCameraRoll,
  UIActivityTypeAddToReadingList,
  UIActivityTypePostToFlickr,
  UIActivityTypePostToVimeo,
  UIActivityTypePostToTencentWeibo,
  UIActivityTypeAirDrop];

   [controller setCompletionHandler:^(NSString*activityType, BOOL completed) {
   [self.bi raiseEvent:nil event:@"activity_completed::" params:@[@((BOOL)completed),(activityType)]];
   }];

   [(self._mypage).object presentViewController:controller animated:YES completion:nil];
}

# end if

Sub activity_completed(status As Boolean, T AsString)Log("onSharingDone: Status = " & status & " - Type: " & T)
End Sub

Sub ShareToSocialMedia(p AsPage, txt AsString, theURL AsString, imageFile AsString)

myPage = pDim NativeMe AsNativeObject = Me
NativeMe.RunMethod("share2SocialMedia:::", Array(txt, theURL, imageFile))

End Sub
 
Last edited:

henrywood

Active Member
Licensed User
@narek Thanks a million !

But is the call from B4i then still OK - I am this line:

B4X:
NativeMe.RunMethod("share2SocialMedia:", Array As Object(txt, theURL, imageFile))
 
Top