ImageMagick なる外部ライブラリーがありこれを使おうかと色々調べたがあまりAndroid C#で利用している情報が見つからず結果断念。

https://github.com/MolotovCherry/Android-ImageMagick7

 

代わりに ImageSharp を利用することに

Visual Stuido の NuGet より、SixLabors.ImageSharp を選択して、Version 1.0.4 を指定してダウンロード

(最新だと、netstandard2.0  をサポートしていない?)

Package より netstandard2.0 フォルダーより以下のファイルをAssets/Plugins に保存

SixLabors.ImageSharp.dll
System.Numerics.Vectors.dll
System.Buffers.dll
System.Runtime.CompilerServices.Unsafe.dll
System.Memory.dll
System.Text.Encoding.CodePages.dll

あとは、Android でビルド

以下が画像を変換するコード(楽ちん)

  // 色々な画像をPNGに変換 
    public static byte[] ConvertToPNG(byte[] imageData)
    {
        using (var image = SixLabors.ImageSharp.Image.Load(imageData)) {
            using (var outputStream = new MemoryStream()) {
                image.Save(outputStream, new PngEncoder());
                return outputStream.ToArray();
            }
        }
    }

iOS でももちろん動作します。

The app references non-public selectors in Payload/*.app/Frameworks/UnityFramework.framework/UnityFramework: applicationWillFinishLaunchingWithOptions:, didReceiveRemoteNotification:

App ストアにアップすると謎エラー

 

ググると、Xcode のバグではないかと…

対処方法は、メソッド名を変更

didReceiveRemoteNotification -> didReceiveRemoteNotificationToUnity

applicationWillFinishLaunchingWithOptions も applicationWillFinishLaunchingWithOptionsToUnity に名前変更

 

Unity ver2020.3.38f1

xcode ver14.0.1

mac ver 12.6

 

一旦、エラーが消えてUP出来ていたが再度、謎エラー

The app references non-public selectors in Payload/*.app/Frameworks/UnityFramework.framework/UnityFramework: loadPlugink

最終的に、 xcode ver13.4.1  にDowngradeして無事アップ成功

Quickstart for Google Cardboard for Unity

https://developers.google.com/cardboard/develop/unity/quickstart

Unity ver.2020.3.38

Mac ver.12.6

Xcode ver.14.0.1

Google Cardboard のデモを iOS 用にビルドしたら以下のエラー

Showing Recent Messages
Undefined symbol: google::protobuf::MessageLite::ParseFromArray(void const*, int)
Undefined symbol: google::protobuf::RepeatedField<float>::InternalSwap(google::protobuf::RepeatedField<float>*)
Undefined symbol: google::protobuf::RepeatedField<float>::Add(float const&)
Undefined symbol: google::protobuf::RepeatedField<float>::Clear()
Undefined symbol: google::protobuf::RepeatedField<float>::MergeFrom(google::protobuf::RepeatedField<float> const&)
Undefined symbol: google::protobuf::RepeatedField<float>::RepeatedField(google::protobuf::Arena*)
Undefined symbol: google::protobuf::RepeatedField<float>::RepeatedField(google::protobuf::RepeatedField<float> const&)
Undefined symbol: google::protobuf::RepeatedField<float>::~RepeatedField()
Undefined symbol: google::protobuf::stringpiece_internal::StringPiece::LogFatalSizeTooBig(unsigned long, char const*)
Undefined symbol: google::protobuf::io::EpsCopyOutputStream::WriteRawFallback(void const*, int, unsigned char*)
Undefined symbol: google::protobuf::io::EpsCopyOutputStream::EnsureSpaceFallback(unsigned char*)
Undefined symbol: google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliasedOutline(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned char*)
Undefined symbol: google::protobuf::Arena::AllocateAlignedWithHook(unsigned long, std::type_info const*)
Undefined symbol: google::protobuf::Arena::AllocateAlignedWithCleanup(unsigned long, std::type_info const*)
Undefined symbol: google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)
Undefined symbol: google::protobuf::internal::LogMessage::~LogMessage()
Undefined symbol: google::protobuf::internal::LogMessage::operator<<(char const*)
Undefined symbol: google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)
Undefined symbol: google::protobuf::internal::WriteVarint(unsigned int, unsigned long long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)
Undefined symbol: google::protobuf::internal::ArenaStringPtr::DestroyNoArenaSlowPath()
Undefined symbol: google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, google::protobuf::Arena*)
Undefined symbol: google::protobuf::internal::ArenaStringPtr::Mutable(google::protobuf::internal::ArenaStringPtr::EmptyDefault, google::protobuf::Arena*)
Undefined symbol: google::protobuf::internal::LookUpEnumName(google::protobuf::internal::EnumEntry const*, int const*, unsigned long, int)
Undefined symbol: google::protobuf::internal::LookUpEnumValue(google::protobuf::internal::EnumEntry const*, unsigned long, google::protobuf::stringpiece_internal::StringPiece, int*)
Undefined symbol: google::protobuf::internal::ReadTagFallback(char const*, unsigned int)
Undefined symbol: google::protobuf::internal::ThreadSafeArena::~ThreadSafeArena()
Undefined symbol: void google::protobuf::internal::InternalMetadata::DoMergeFrom<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
Undefined symbol: void google::protobuf::internal::InternalMetadata::DoClear<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >()
Undefined symbol: google::protobuf::internal::PackedFloatParser(void*, char const*, google::protobuf::internal::ParseContext*)
Undefined symbol: google::protobuf::internal::UnknownFieldParse(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)
Undefined symbol: google::protobuf::internal::VarintParseSlow64(char const*, unsigned int)
Undefined symbol: google::protobuf::internal::EpsCopyInputStream::DoneFallback(int, int)
Undefined symbol: google::protobuf::internal::InitializeEnumStrings(google::protobuf::internal::EnumEntry const*, int const*, unsigned long, google::protobuf::internal::ExplicitlyConstructed<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >*)
Undefined symbol: google::protobuf::internal::InitProtobufDefaultsSlow()
Undefined symbol: google::protobuf::internal::InlineGreedyStringParser(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)
Undefined symbol: google::protobuf::internal::fixed_address_empty_string
Undefined symbol: google::protobuf::internal::init_protobuf_defaults_state
Undefined symbol: google::protobuf::MessageLite::InitializationErrorString() const
Undefined symbol: google::protobuf::RepeatedField<float>::Get(int) const
Undefined symbol: google::protobuf::RepeatedField<float>::data() const
Undefined symbol: google::protobuf::RepeatedField<float>::size() const
Undefined symbol: typeinfo for google::protobuf::MessageLite
Undefined symbol: vtable for google::protobuf::MessageLite

google::protobuf が見つからない

対応としては、iOS 用のビルドフォルダに移動

pod init
pod install

podfile を以下に変更

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

target 'Unity-iPhone' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for Unity-iPhone

  target 'Unity-iPhone Tests' do
    inherit! :search_paths
    # Pods for testing
  end

end

target 'UnityFramework' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  # add
  pod 'Protobuf-C++', '3.18.0'

  # Pods for UnityFramework

end

# add
post_install do |installer|
  installer.pods_project.targets.each do |target|
    # print "target=", target, "\n"
    if target.name == "Protobuf-C++"
      target.build_configurations.each do |config|
        config.build_settings['HEADER_SEARCH_PATHS'] = '$(SRCROOT)/Protobuf-C++/src'
      end
    end
  end
end

xcworkspace が作成されるので以下のコマンドで open

pod update
open Unity-iPhone.xcworkspace

あとは、署名してビルド

 

appium desktop を起動してサーバを起動

appium inspector を起動

iOS

{
  "platformName": "iOS",
  "appium:udid": "0943D45A-B772-4C36-B738-2931C093D6F1",
  "appium:deviceName": "iPhone",
  "appium:platformVersion": "15"
}

Android

{
  "platformName": "Android"
}

Xcode を起動してプロジェクトを開く

Product  -> show build folder in finder から app ファイルを取得する

 

 

 

/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 &amp;lt;SharkORM/SharkORM.h&amp;gt;

#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]?) -&amp;gt; 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;
}
© 2023 Falco Tech Blog Suffusion theme by Sayontan Sinha