UNPKG

textiot

Version:

A framework for building web and native (IoT) Dapps on the IPFS network

241 lines (168 loc) 8.03 kB
# textiot A framework for building web and native (IoT) Dapps on the IPFS network. An monorepo textiot.git was combined with https://github.com/textileio/go-textile and related git repos for easier development. ## Usage ### react-native npm install textiot --save For RN < 0.60, run `react-native link textiot`. For RN < 0.60 or >= 0.60, then: #### Android Add below into `android/settings.gradle` androidx not android: ``` include ':textile-pb' project(':textile-pb').projectDir = new File(rootProject.projectDir, '../node_modules/textiot/android-textile/pb-androidx') include ':textile-mobile' project(':textile-mobile').projectDir = new File(rootProject.projectDir, '../node_modules/textiot/android-textile/mobile') include ':android-textile' project(':android-textile').projectDir = new File(rootProject.projectDir, '../node_modules/textiot/react-native-sdk/textile-androidx') ``` and `cd node_modules/textiot; ./android2androidx.sh` android not androidx: ``` include ':textile-pb' project(':textile-pb').projectDir = new File(rootProject.projectDir, '../node_modules/textiot/android-textile/pb-android') include ':textile-mobile' project(':textile-mobile').projectDir = new File(rootProject.projectDir, '../node_modules/textiot/android-textile/mobile') include ':android-textile' project(':android-textile').projectDir = new File(rootProject.projectDir, '../node_modules/textiot/react-native-sdk/textile-android') ``` and `cd node_modules/textiot; ./androidx2android.sh` require('textiot/react-native-sdk').default; Because can not `npm publish` full 300MB package, so you have to install tools described below and cd node_modules/textiot/ ./build-post-npm.sh results: ``` go-textile/textile go-textile/textile.exe go-textile/textile-arm android-textile/mobile react-native-sdk/textile-androidx react-native-sdk/textile-android ``` #### iOS Because can not `npm publish` full 300MB package, so you have to install tools described below and cd node_modules/textiot/ ./build-mac.sh results: ``` go-textile/textile-mac go-textile/mobile/dist/ios/Mobile.framework/ go-textile/mobile/dist/ios/protos/ ``` Add below (after `pod 'Folly'`) into `ios/Podfile` ``` pod 'Textile', :path => '../node_modules/textiot/ios-textile' pod 'TextileCore', :path => '../node_modules/textiot/go-textile/mobile/dist/ios' ``` cd ios pod install require('textiot/react-native-sdk').default; ### web npm install textiot --save require('textiot/js-http-client').default; ## Docs ### textile [tour of Textile](docs/docs/a-tour-of-textile.md) ## Develop ### Install tools #### golang >= 1.14.15 go get golang.org/x/mobile/cmd/gomobile export PATH=~/go/bin:$PATH gomobile init if `unrecognized import path "golang.org/x/mobile/cmd/gomobile` , then mkdir -p ~/go cd ~/go mkdir -p src/github.com/golang mkdir -p src/golang.org cd src/golang.org ln -s ../github.com/golang x cd ~/go/src/github.com/golang git clone https://github.com/golang/mobile git clone https://github.com/golang/tools git clone https://github.com/golang/mod git clone https://github.com/golang/sys git clone https://github.com/golang/xerrors go get golang.org/x/mobile/cmd/gomobile gomobile init and also export GO111MODULE=on export GOPROXY=https://goproxy.io #### android sdk #### android ndk r20 #### nodejs <=10.15.3 With `go-textile/release/@textile/js-types/dist/index.d.ts` generated by `./node_modules/protobufjs/bin/pbts` running in nodejs 12.13.0 , will cause error in `npm run build` of react-native-sdk . #### `protoc --version` to match change `com.google.protobuf:protobuf-java:3.6.1` on Linux sudo apt install protobuf-compiler on macOS brew install protobuf to install protoc, and protoc --version to get its version e.g. `3.12.4`. Then need change `com.google.protobuf:protobuf-java:3.6.1` to `com.google.protobuf:protobuf-java:3.12.4` in `go-textile/release/PBProject/pb/build.gradle`, otherwise will cause `error: cannot find symbol UnusedPrivateParameter` when `./gradlew pb:build` in `go-textile/release/PBProject/`, just as `sed` in `./build-post-npm.sh`. Then need change `com.google.protobuf:protobuf-java:3.6.1` to `com.google.protobuf:protobuf-java:3.12.4` in `android-textile/textile/build.gradle` and `android/build.gradle`, just as `sed` in `./build-post-npm.sh`, otherwise the APP will crash `E AndroidRuntime: java.lang.NoSuchMethodError: No static method internalBuildGeneratedFileFrom([Ljava/lang/String;[Lcom/google/protobuf/Descriptors$FileDescriptor;)Lcom/google/protobuf/Descriptors$FileDescriptor; in class Lcom/google/protobuf/Descriptors$FileDescriptor; or its super classes` when run into `list.toByteArray()` of `final Model.ThreadList list` in `textiot/react-native-sdk/android/src/main/java/io/textile/rnmobile/ThreadsBridge.java`. All will be built by `build.sh` on Linux except `mobile/dist/ios/protos` and `mobile/dist/ios/Mobile.framework/` by `build-mac.sh` on macOS. Similarly, if `protoc --version` return `3.13.0` on macOS, then need change `s.dependency 'Protobuf', '~> 3.7'` to `s.dependency 'Protobuf', '3.13.0'` in `ios-textile/Textile.podspec` and `go-textile/mobile/dist/ios/TextileCore.podspec`, just as `sed` in `./build-mac.sh`. #### protoc-gen-go 7e65e51 If you modify `go-textile/pb/protos/*.proto`, then you also need regenerate `go-textile/pb/*.pb.go` by an exact version of protoc-gen-go which match protoc 3.x (or `protoc-gen-go@7e65e51` described below) go get -d -u github.com/golang/protobuf/protoc-gen-go cd ~/go/src/github.com/golang/protobuf/protoc-gen-go git checkout 7e65e51 go build mv protoc-gen-go ~/go/bin/ or just go install github.com/golang/protobuf/protoc-gen-go@7e65e51 regenerate: cd go-textile make protos #### google.golang.org/protobuf v1.26.1-0.20210525005349-febffdd88e85 There is exact 1.26-dev version google.golang.org/protobuf v1.26.1-0.20210525005349-febffdd88e85 in `go.mod`, if miss it or even a bigger version e.g. google.golang.org/protobuf v1.27.0 will cause `panic: proto: file "message.proto" is already registered` when run `./textile`, ref to [proto: file is already registered with different packages](https://stackoverflow.com/questions/67693170/proto-file-is-already-registered-with-different-packages) and [reflect/protoregistry: restore conflicting file names check](https://github.com/protocolbuffers/protobuf-go/commit/21e33cc91079beb975323466e237f2486ea29c10). Maybe can use `protoc-gen-go` with the same version with `go.mod`, because the key to resolve the panic is should only about `go.mod` not about the `protoc-gen-go`, and I validate the result of protoc is same between `protoc-gen-go@7e65e51` above and `protoc-gen-go@febffdd` below. go install google.golang.org/protobuf/cmd/protoc-gen-go@febffdd If can't install above for network reason, install below is also ok cd ~/go/pkg/mod/google.golang.org/protobuf@v1.26.1-0.20210525005349-febffdd88e85/cmd/protoc-gen-go/ go build -o ~/go/bin regenerate: cd go-textile make protos #### suod apt install mingw-w64 gcc-arm-linux-gnueabihf #### Xcode on macOS ### Build on Linux ./build.sh results: ``` go-textile/textile go-textile/textile.exe go-textile/textile-arm android-textile/pb-androidx android-textile/pb-android android-textile/mobile react-native-sdk/textile-androidx react-native-sdk/textile-android react-native-sdk/dist/index.js ``` ### Build on macOS ./build-mac.sh results: ``` go-textile/textile-mac go-textile/mobile/dist/ios/Mobile.framework/ go-textile/mobile/dist/ios/protos/ ``` ### Build on macOS ./build-web.sh results: ``` js-http-client/dist/index.js ``` ## Changelog ### textiot@2.0.0 `go-ipfs v0.8.0` And no ipfs repo migration from `0.4.22` to `0.8.0` support here, so you need migrate with ipfs official migration tool by yourself if you want. ### textiot@1.0.0 `go-ipfs v0.4.22-0.20191002225611-b15edf287df6`