【问题标题】:Convert iOS app to Android using Apportable - various reference and definition errors when building使用 Apportable 将 iOS 应用程序转换为 Android - 构建时的各种引用和定义错误
【发布时间】:2014-02-08 10:12:56
【问题描述】:

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

不幸的是,我在使用命令apportable build 构建时遇到了一些错误。我试图谷歌并在 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 有疑问。 它们用于以下类:

ChooseShoppingLocationViewController.h

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

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

ChooseShoppingLocationViewController.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.

【问题讨论】:

    标签: android ios objective-c apportable


    【解决方案1】:

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

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

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

    【讨论】:

    • 感谢您的回答!感谢您的回答,我用StoreViewAnnotationUIRefreshControl 修复了错误。但是我仍然对 ChooseShoppingLocationViewController 有问题。我用ChooseShoppingLocationViewController 的代码编辑了这个问题
    • 您可以通过查看文件 ./{appname}.approj/targets/{appname}/Release.final 来找到应用尝试包含的资产。然后您可以使用 configuration.json 进行调整。例如,在 Release.final 中找到 ResourceRules.plist。然后将该文本放入配置的 remove_params 部分。如果需要添加替代项,请进入 add_params 部分。
    • 我用ResourceRules.plist 解决了这个错误。发生这种情况是因为路径使用“Xcode.app”引用 XCode,但我安装了 Xcode 4.6.3,因此将 Xcode 5 重命名为“Xcode5.app”,所以我只是将引用更改为“Xcode5.app”并且它起作用了。但我的ChooseShoppingLocationViewController 中仍然出现错误,除非我取消注释带有MKPointAnnotationMKUserLocationMKPinAnnotationView 的部分,如已编辑问题中所述。你知道为什么吗?
    猜你喜欢
    • 2023-03-19
    • 1970-01-01
    • 2019-03-06
    • 1970-01-01
    • 2016-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多