/clang:-1: linker command failed with exit code 1 (use -v to see invocation)

ld: ‘/Users/falco/Unity/MemoPa/MemoPaiOS/Libraries/Plugins/iOS/libdivesensor.a(Native_Sensors_Plugin.o)’ does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Buildsettings search bitcode
EnableBitCode no

Swift SharkORM を使用するには?

新規プロジェクトを XCode で作成して、一旦閉じる。(SharkORMTest)

ターミンナルより SharkORMTest に移動

pod init

Profile に 以下の様に編集

# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'

target 'SharkOrmTest' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  #use_frameworks!
  pod 'SharkORM'

  # Pods for SharkOrmTest

  target 'SharkOrmTestTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'SharkOrmTestUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

以下のコマンドを実行
pod install

xcode にて SharkOrmTest.xcodeproj ではなく SharkOrmTest.xcworkspace を開く

SharkHeader.h ブリッジヘッダーファイルを作成

#ifndef SharkHeader_h
#define SharkHeader_h

#include <SharkORM/SharkORM.h>

#endif /* SharkHeader_h */

build settings
-> objective-c Bridging Heatter に以下を追加

$(SRCROOT)/$(PRODUCT)/SharkHeader.h

上記を忘れると以下のエラーが出ます。

Use of undeclared type 'SRKDelegate'
Use of undeclared type 'SRKObject'

テーブルに対応するクラスを作成

import Foundation
import SharkORM

class Sentence: SRKObject {
    @objc dynamic var _id : NSNumber?
    @objc dynamic var categoryId : NSNumber?
    @objc dynamic var english : String?
    @objc dynamic var japanese : String?
    @objc dynamic var okCount : NSNumber?
    @objc dynamic var ngCount : NSNumber?
    @objc dynamic var average : NSNumber?
}

以下、追加

import SharkORM

class AppDelegate: UIResponder, UIApplicationDelegate, SRKDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        SharkORM.setDelegate(self)
        SharkORM.openDatabaseNamed("myDatabase")
        initDb()
        return true
    }

    func initDb() {

        insertData(english:"this is a pen.")
        insertData(english:"this is an apple.")
        insertData(english:"can you speack japanese.")

        var results = Sentence.query().fetch()
        print(String(format: "count:%d", (results?.count)!))
        for sentence in results! {
            let s = sentence as! Sentence
            print((sentence as AnyObject).english)
        }

    }

    func insertData( english: String ) {
        var a = Sentence()
        a.english = english
        a.commit()
    }

色々とハマタ

sample 見ながら SharkORM を組み込んだら、以下のエラー


ld: library not found for -lSharkORM

本家のサンプルでも同様のエラー
原因わからず、使うのをやめようと思ったら基本的事がわかってなかった orz

以下、実行

pod init

Podfile に以下追加

pod 'sharkORM'

以下のコマンド実行

pod install

プロジェクトファイルで以下のファイルを開く(*これ知らなかった、read.me ファイル無いし)

SharkBooksSample.xcworkspace

とりえあず実行できた!


  BackView *bv = [[BackView alloc] initWithFrame:rect];
  [self.view addSubview:bv];

- (id)initWithFrame:(CGRect)theFrame {
    self = [super initWithFrame:theFrame];
    
    self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.8];
    
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.bounds = [[self layer] bounds];

    CGRect rect = [[self layer] bounds];
    UIBezierPath *outerRectanglePath = [UIBezierPath bezierPathWithRect:rect];
    CGRect rect2 = CGRectMake(rect.size.width/2 - 50, rect.size.height/2- 50, 100, 100);
    UIBezierPath *interRectanglePath = [UIBezierPath bezierPathWithRect:rect2];
    
    [outerRectanglePath appendPath:interRectanglePath];
    maskLayer.path = outerRectanglePath.CGPath;
    maskLayer.position = CGPointMake( rect.size.width / 2.0 , rect.size.height / 2.0 );
    
    maskLayer.fillRule = kCAFillRuleEvenOdd;
//    maskLayer.fillRule = kCAFillRuleNonZero;
    [self layer].mask = maskLayer;
    
    return self;
}
© 2024 Falco Tech Blog Suffusion theme by Sayontan Sinha