liferay / liferay-mobile-sdk

Other
47 stars 56 forks source link

IOS: Using Liferay Mobile SDK as framework seems not working #14

Closed asotog closed 9 years ago

asotog commented 9 years ago

Hi, Currently working on project using mobile sdk and using pods, initially it built fine, but i needed to add a swift dependency, so set pods to use it as frameworks but not sure why mobile sdk seems to be not working fine with that configuration, also raised the issue on cocoa pods (pls look at it for more detail) but still getting errors, https://github.com/CocoaPods/CocoaPods/issues/3334#issuecomment-87753905 Thanks in advance

brunofarache commented 9 years ago

@asotog, that's a good coincidence.

I was just trying to get the Mobile SDK to work with some other Swift project. After some changes, I was able to lint the project successfully.

I'm not really sure what has fixed it but I suspect it was this change made by @jmnavarro 6a5880019037be428cc92c785748071c4268d481

He moved CommonCrypto library import out of the header file.

I just published version 6.2.0.14, trying using that and let us know. Here's the Swift project that is using it:

https://github.com/brunofarache/liferay-push-ios

asotog commented 9 years ago

mm i think that solved the issue but had to modify all the sdk generated services files in my project, also modified liferay screens bridging header to support it and some liferay screens services

brunofarache commented 9 years ago

Can you tell me what you had to change? Also having issues with another Swift project that depends on Screens + 6.2.0.14.

Getting: "LRBaseService.h cannot be found", probably the same error as you.

asotog commented 9 years ago

Liferay screens custom services inside Liferay-Screens/Source/Services, had

#import "LRBaseService.h"

so updated to

#import <Liferay_iOS_SDK/LRBaseService.h>

also liferay screens bridging header changed from

/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
#import <UIKit/UIKit.h>

//! Project version number for liferay-screens.
FOUNDATION_EXPORT double liferay_screens_VersionNumber;

//! Project version string for liferay-screens
FOUNDATION_EXPORT const unsigned char liferay_screens_VersionString[];

#import "MBProgressHUD.h"
#import "SMXMLDocument.h"
#import "UICKeyChainStore.h"
#import "ODRefreshControl.h"

#import "AssetListScreenletInterop.h"

// Default theme dependencies
#import "DTPickerPresenter.h"
#import "DTDatePickerPresenter.h"
#import "TNRadioButtonGroup.h"
#import "MDRadialProgressView.h"
#import "MDRadialProgressTheme.h"

// Liferay services
#import "LRUserService_v62.h"
#import "LRMobilewidgetsassetentryService_v62.h"
#import "LRMobilewidgetsddlrecordService_v62.h"
#import "LRMobilewidgetsuserService_v62.h"
#import "LRDDMStructureService_v62.h"
#import "LRDDLRecordService_v62.h"
#import "LRDLAppService_v62.h"
#import "LRAssetEntryService_v62.h"
#import "LRJournalArticleService_v62.h"

#import "LRCallback.h"
#import "LRSession.h"
#import "LRBatchSession.h"
#import "LRError.h"
#import "LRJSONObjectWrapper.h"

to

/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
#import <UIKit/UIKit.h>

//! Project version number for liferay-screens.
FOUNDATION_EXPORT double liferay_screens_VersionNumber;

//! Project version string for liferay-screens
FOUNDATION_EXPORT const unsigned char liferay_screens_VersionString[];

@import MBProgressHUD;
@import SMXMLDocument;
@import ODRefreshControl;
//#import "SMXMLDocument.h"
@import UICKeyChainStore;
//#import "UICKeyChainStore.h"
//#import "ODRefreshControl.h"
//
//#import "AssetListScreenletInterop.h"
//
//// Default theme dependencies
@import DTPickerPresenter;
//#import "DTPickerPresenter.h"
//#import "DTDatePickerPresenter.h"
@import TNRadioButtonGroup;

@import MDRadialProgress;
//#import "MDRadialProgressTheme.h"
//
//// Liferay services
//#import "LRUserService_v62.h"
#import "LRMobilewidgetsassetentryService_v62.h"
#import "LRMobilewidgetsddlrecordService_v62.h"
#import "LRMobilewidgetsuserService_v62.h"
//#import "LRDDMStructureService_v62.h"
//#import "LRDDLRecordService_v62.h"
//#import "LRDLAppService_v62.h"
//#import "LRAssetEntryService_v62.h"
//#import "LRJournalArticleService_v62.h"
//
#import <Liferay_iOS_SDK/LRCallback.h>
//#import "LRCallback.h"
#import <Liferay_iOS_SDK/LRSession.h>
#import <Liferay_iOS_SDK/LRBatchSession.h>
#import <Liferay_iOS_SDK/LRError.h>
#import <Liferay_iOS_SDK/LRJSONObjectWrapper.h>

still has some commented lines but is building fine now

jmnavarro commented 9 years ago

Today I was working on package Liferay Screens as a pod dependency (:

https://issues.liferay.com/browse/LMW-48

Will be ready for next version!

asotog commented 9 years ago

thats great, screens bridge header can be cleaned even more i guess :

/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
#import <UIKit/UIKit.h>

//! Project version number for liferay-screens.
FOUNDATION_EXPORT double liferay_screens_VersionNumber;

//! Project version string for liferay-screens
FOUNDATION_EXPORT const unsigned char liferay_screens_VersionString[];

@import MBProgressHUD;
@import SMXMLDocument;
@import ODRefreshControl;
//#import "SMXMLDocument.h"
@import UICKeyChainStore;
//#import "UICKeyChainStore.h"
//#import "ODRefreshControl.h"
//
//#import "AssetListScreenletInterop.h"
//
//// Default theme dependencies
@import DTPickerPresenter;
//#import "DTPickerPresenter.h"
//#import "DTDatePickerPresenter.h"
@import TNRadioButtonGroup;

@import MDRadialProgress;
//#import "MDRadialProgressTheme.h"
//
//// Liferay services
//#import "LRUserService_v62.h"
#import "LRMobilewidgetsassetentryService_v62.h"
#import "LRMobilewidgetsddlrecordService_v62.h"
#import "LRMobilewidgetsuserService_v62.h"
//#import "LRDDMStructureService_v62.h"
//#import "LRDDLRecordService_v62.h"
//#import "LRDLAppService_v62.h"
//#import "LRAssetEntryService_v62.h"
//#import "LRJournalArticleService_v62.h"
//
@import Liferay_iOS_SDK;
//#import "LRCallback.h"
//#import <Liferay_iOS_SDK/LRSession.h>
//#import <Liferay_iOS_SDK/LRBatchSession.h>
//#import <Liferay_iOS_SDK/LRError.h>
//#import <Liferay_iOS_SDK/LRJSONObjectWrapper.h>
jmnavarro commented 9 years ago

Yes, we're working on that direction

Screens will be a framework and it will be able to be imported just with pod LiferayScreens

Thanks!

brunofarache commented 9 years ago

OK, let me see if I understood it correctly.

  1. When you have dependencies that are written in Swift. Cocoapods requires you to add "use_frameworks!" to your Podfile.
  2. Once you do this, you need import them as frameworks: import FrameworkName (from .swift) @import FrameworkName; (from .m and apparently from bridging *.h files too)

In fact, it doesn't matter if FrameworkName is written in Swift or Obj-C, once you add "use_frameworks!", all dependencies must be imported as frameworks.

asotog commented 9 years ago

yep all dependencies are loaded as frameworks but you will need to explicitly import them with @import or import (for swift)

brunofarache commented 9 years ago

I can change the podspec module_name to LiferayiOSSDK so you can import like this and avoid underscores:

@ import LiferayiOSSDK;

Or is it better to call LiferayMobileSDK? Or maybe just Liferay or LRMobileSDK?

jmnavarro commented 9 years ago

For me LiferayMobileSDK is a better name. Obviously it's iOS for all of us (:

brunofarache commented 9 years ago

Renamed to LRMobileSDK: fd9c31d7dc2c17afac067661fffb6ffcfb4926eb

I picked this to make it consistent with LRPush, LROAuth and other frameworks like AFNetworking.

@import LRMobileSDK;

Podfile should be kept as it was before:

pod 'Liferay-iOS-SDK', '~> 6.2.0.15'

brunofarache commented 9 years ago

@jmnavarro, while using the portrait Screenlet I had compilation issues with the UIImageView+AFNetworking category. That's a problem with the AFNetworking version we are using and it was fixed here:

https://github.com/AFNetworking/AFNetworking/issues/2205

I will upgrade the Mobile SDK dependency to the latest AFNetworking version, this should fix Screens when using use_frameworks! as well.

jmnavarro commented 9 years ago

Cool, thanks for the info!