[ad_1]
I’m making an attempt to construct a framework that makes use of the geopackage-ios CocoaPods dependency and which ought to then be capable of be statically embedded into an app.
Related questions have been requested earlier than, however I could not discover a answer to my downside. Here is what I have been making an attempt to date:
First Strategy: Constructing Manually
On this strategy, I might create a static library utilizing Xcode, add the CocoaPods dependencies to it and construct it. The issue with this strategy, nevertheless, is that the ensuing framework is not going to have the CocoaPods dependencies embedded into it.
- Create a brand new static library from Xcode (File > New > Mission… > iOS: Static Library) named “MyLibrary” with language Swift.
- Create a
Podfilewithin the venture root listing with the next content material:
goal 'MyLibrary' do
pod 'geopackage-ios', '~> 7.2.1'
finish
- Run
pod set up. (This may set up thegeopackage-iospod and 10 relying pods.) - Open the newly created
MyLibrary.xcworkspaceand add aBridgingHeader.hto the “MyLibrary” group having the next content material:
#ifndef BridgingHeader_h
#outline BridgingHeader_h
#import "geopackage-ios-Bridging-Header.h"
#endif
- Reference the bridging header by clicking on the “MyLibrary” venture within the venture navigator, choosing the “MyLibrary” goal and, within the Construct Settings, specifying
MyLibrary/BridgingHeader.hbecause the “Goal-C Bridging Header”. - Modify
MyLibrary.swiftto make use of the GeoPackage dependency:
public class MyLibrary {
public init() {}
public func check() {
let supervisor = GPKGGeoPackageFactory.supervisor()!
print("Supervisor:", supervisor)
}
}
- Construct the library for the iOS simulator by urgent
Cmd + B. - Optionally, create a static framework utilizing a shell script just like the one in this text (which is able to compile the library as soon as for the simulator and as soon as for bodily units after which mix the 2 outcomes to a common framework utilizing the
lipocommand).
After I embed both the static library (together with the MyLibrary.swiftmodule) or the common framework into an app, linking will fail for this app:
Undefined symbols for structure x86_64:
"_OBJC_CLASS_$_GPKGGeoPackageManager", referenced from:
objc-class-ref in libMyLibrary.a(MyLibrary.o)
"_OBJC_CLASS_$_GPKGGeoPackageFactory", referenced from:
objc-class-ref in libMyLibrary.a(MyLibrary.o)
ld: image(s) not discovered for structure x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I may additionally add the geopackage_ios.framework (discovered within the construct folder of “MyLibrary”) to the app (ensuring to decide on the Embed & Signal embedding possibility), which is able to permit the app to be constructed efficiently. Then, nevertheless, the app will crash upon launch:
dyld[79209]: Library not loaded: @rpath/ogc_api_features_json_ios.framework/ogc_api_features_json_ios
Referenced from: /Customers/admin1/Library/Developer/CoreSimulator/Units/C3D61224-CFE8-45CC-951B-7B6AB54BC8B3/knowledge/Containers/Bundle/Utility/D41A82D6-4E69-4BB6-AC59-6BC28AE58795/TestApp.app/Frameworks/geopackage_ios.framework/geopackage_ios
One would possibly be capable of repair this by including all eleven pod frameworks to the app, which, nevertheless, is what I am making an attempt to keep away from.
Second Strategy: Utilizing PodBuilder
A second strategy could be to make use of PodBuilder, which goals at automating this explicit form of construct activity. This strategy, nevertheless, fails with a construct error, the reason for which I am unable to fairly make out.
- Once more, I might begin out with a brand new Xcode venture. This time, I might create an iOS Swift app named “MyApp”.
- I might create a
Podfilewith nearly the identical content material as above:
use_frameworks!
goal 'MyApp' do
pod 'geopackage-ios', '~> 7.2.1'
finish
- Then, I might run
pod set up. - Subsequent, I might set up PodBuilder, create an empty Git repository (which PodBuilder requires for some cause), initialize PodBuilder, and begin the construct activity:
sudo gem set up pod-builder
git init
pod_builder init
pod_builder construct geopackage-ios
- The construct will fail, nevertheless, with errors like these written to
/tmp/pod_builder/pod_builder.err:
Undefined symbols for structure arm64:
"_PROJ_WEB_MERCATOR_MAX_LAT_RANGE", referenced from:
+[GPKGTileBoundingBoxUtils toWebMercatorWithBoundingBox:] in GPKGTileBoundingBoxUtils.o
+[GPKGTileBoundingBoxUtils boundDegreesBoundingBoxWithWebMercatorLimits:] in GPKGTileBoundingBoxUtils.o
-[GPKGTileDao isXYZTiles] in GPKGTileDao.o
-[GPKGTileGenerator adjustXYZBounds] in GPKGTileGenerator.o
"_PROJ_UNDEFINED_CARTESIAN", referenced from:
-[GPKGSpatialReferenceSystemDao createIfNeededWithSrs:andOrganization:andCoordsysId:] in GPKGSpatialReferenceSystemDao.o
"_PROJ_AUTHORITY_NONE", referenced from:
-[GPKGSpatialReferenceSystemDao createIfNeededWithSrs:andOrganization:andCoordsysId:] in GPKGSpatialReferenceSystemDao.o
[…]
- This appears to be an issue with the
geopackage-iospod itself, which could be fastened by cloning our personal model of the repo …
cd ..
git clone --branch 7.2.1 https://github.com/ngageoint/geopackage-ios.git
- …, putting in the pods …
cd geopackage-ios
pod set up
- … manually copying the
proj-iossupply recordsdata …
cp -r Pods/proj-ios/proj-ios geopackage-ios
-
…, and opening the
geopackage-ios.xcodeprojto reference theproj-iosrecordsdata within thegeopackage-iosgroup inside that venture. -
Then telling CocoaPods to make use of our native model of the pod …
use_frameworks!
goal 'MyApp' do
pod 'geopackage-ios', :path => '../geopackage-ios'
finish
- …, reinitializing PodBuilder …
cd ../MyApp
pod_builder deintegrate
pod deintegrate
pod set up
pod_builder init
- … and permitting PodBuilder to make use of native pods by enhancing the
./PodBuilder/PodBuilder.jsonfile:
{
…,
"allow_building_development_pods": true,
…
}
- Then, one can attempt to rebuild:
pod_builder construct geopackage-ios
This time, the construct will fail with a distinct error:
The next construct instructions failed:
CompileC /tmp/pod_builder/construct/Pods.construct/Launch-iphoneos/sf-proj-ios.construct/Objects-normal/arm64/SFPGeometryTransform.o /tmp/pod_builder/Pods/sf-proj-ios/sf-proj-ios/SFPGeometryTransform.m regular arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in goal 'sf-proj-ios' from venture 'Pods')
(1 failure)
The SFPGeometryTransform.m file, nevertheless, appears to be like fantastic.
The complete construct log is out there right here.
Third Strategy: Utilizing Rome
The third strategy could be to make use of cocoapods-rome.
- To make use of it, one would set up Rome …
sudo gem set up cocoapods-rome
- …, do away with the PodBuilder stuff …
pod_builder deintegrate
pod deintegrate
- …, shortly modify the
Podfile:
use_frameworks!
platform :ios, '13.0'
plugin 'cocoapods-rome', { :pre_compile => Proc.new
config.build_settings['SWIFT_VERSION'] = '5.0'
finish
finish
installer.pods_project.save
,
dsym: false,
configuration: 'Launch'
}
goal 'MyApp' do
pod 'geopackage-ios', :path => '../geopackage-ios'
finish
- … and set up the pods:
pod set up
This, nevertheless, will fail with the very same error as PodBuilder.
Can anybody give me some recommendation on any of those approaches? Or does anybody maybe have a complete completely different concept on the right way to construct such a framework?
[ad_2]
