android - 使用 Apportable 将 iOS 应用程序转换为 Android - 构建时出现各种引用和定义错误

标签 android ios objective-c apportable

我正在尝试使用 Apportable 转换 iOS 应用。

不幸的是,我在使用命令 apportable build 进行构建时遇到了一些错误。我曾尝试使用 Google 并在 StackOverflow 上搜索该问题的解决方案。发现在 configuration.json 中添加“add_params”可能会有所帮助,但这不起作用,我不完全知道要在那里添加什么。 构建输出:

Packaging resources.
scons: *** [assets/ResourceRules.plist] Source `/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/ResourceRules.plist' not found, needed by target `assets/ResourceRules.plist'.
Build/android-armeabi-debug/Cromian.CHASER/Chaser/libChaser.a(ChooseShoppingLocationViewController.m.o):/Users/Anders/Documents/Xcode/iOS_code/Cromian/Chaser/chaser_app/Chaser/ChooseShoppingLocationViewController.m:function L_OBJC_CLASSLIST_REFERENCES_$_54: error: undefined reference to 'OBJC_CLASS_$_MKPointAnnotation'
Build/android-armeabi-debug/Cromian.CHASER/Chaser/libChaser.a(ChooseShoppingLocationViewController.m.o):/Users/Anders/Documents/Xcode/iOS_code/Cromian/Chaser/chaser_app/Chaser/ChooseShoppingLocationViewController.m:function L_OBJC_CLASSLIST_REFERENCES_$_94: error: undefined reference to 'OBJC_CLASS_$_MKUserLocation'
Build/android-armeabi-debug/Cromian.CHASER/Chaser/libChaser.a(ChooseShoppingLocationViewController.m.o):/Users/Anders/Documents/Xcode/iOS_code/Cromian/Chaser/chaser_app/Chaser/ChooseShoppingLocationViewController.m:function L_OBJC_CLASSLIST_REFERENCES_$_99: error: undefined reference to 'OBJC_CLASS_$_MKPinAnnotationView'
scons: *** [Build/android-armeabi-debug/Chaser/apk/lib/armeabi/libverde.so] Error 1
scons: building terminated because of errors.
Anders-Friis-MacBook-Pro:chaser_app Anders$ 

MKPointAnnotationMKUserLocationMKPinAnnotationView 我仍然有问题。 它们用于以下类:

选择ShoppingLocationViewController.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import "NotificationController.h"

@interface ChooseShoppingLocationViewController : UIViewController <MKMapViewDelegate>
@property (strong, nonatomic) CLLocation *shoppingLocation;
@end

选择ShoppingLocationViewController.m

@interface ChooseShoppingLocationViewController ()
@property (strong, nonatomic) IBOutlet MKMapView *mapView;
@property (strong, nonatomic) MKPointAnnotation *shoppingLocationAnnotation;
@end

...

- (MKPointAnnotation *)getNewShoppingLocationAnnotation
{
    MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
    annotation.title = YOUR_SHOPPING_AREA_TEXT;
    return annotation;
}

...

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    userLocation.title = @"";
    CLLocationCoordinate2D location = [userLocation coordinate];
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(location, DISTANCE_SPAN, DISTANCE_SPAN);

    if (self.isFirstUserLocation) {
        dispatch_queue_t animateQueue = dispatch_queue_create("show user location", NULL);
        dispatch_async(animateQueue, ^{
            sleep(1.0);
            dispatch_async(dispatch_get_main_queue(), ^{
                [self.mapView setRegion:region animated:YES];
                [self.mapView selectAnnotation:self.shoppingLocationAnnotation animated:YES];
            });
        });
        self.isFirstUserLocation = NO;
    }
}

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnnotation >)annotation {
    if ([annotation isKindOfClass:[MKUserLocation class]]) {
        return nil;
    }

    MKPinAnnotationView *pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"DETAILPIN_ID"];
    [pinView setAnimatesDrop:YES];
    [pinView setCanShowCallout:YES];
    [pinView setSelected:YES];
    return pinView;
}

现在是否允许将这些类与 Apportable 一起使用?

顺便说一句,如果我尝试删除这些类的使用,我仍然会遇到错误:

scons: *** [assets/ResourceRules.plist] Source `/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/ResourceRules.plist' not found, needed by target `assets/ResourceRules.plist'.
scons: building terminated because of errors.

最佳答案

重复符号错误表明 StoreViewAnnotation 在 StoreViewAnnotation.m 和 main.m 中都定义了。 main.m 是否导入 StoreViewAnnotation.m 而不是 StoreViewAnnotation.h?

ChooseShoppingLocationViewController.m 错误看起来像是应用程序中缺少符号。

关于 _UIRefreshControl 的错误是因为 UIRefreshControl 还没有在 Apportable 平台上实现。现在,您需要绕过它。

关于android - 使用 Apportable 将 iOS 应用程序转换为 Android - 构建时出现各种引用和定义错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21644711/

相关文章:

android - Canvas坐标系的单位是什么? - 安卓

ios - 如何在 iTunes Connect 的实时应用程序中更改 SKU?

ios - 为什么 EmptyView() 不能在带有 SwiftUI 的 WatchOS 上运行?

ios - OCMock 方法中的 stub block

iphone - 将 zip 文件从 iOS 应用流式传输到 Web 浏览器

iOS CoreData - 序列化整个对象而不是创建实体

ios - 如何在 Flutter 插件的 Swift 编写的 iOS 部分中使用 Objective-C 框架

java - 当对象 `A` 更改时更新对象 `B` - Android 编程

android - Android 3.0(Honeycomb)如何处理 "paste"事件?

android - BottomNavigationView 自定义项目图像