Tuesday, February 16, 2016
[iOS]Cocoapods Packager: publish pods framework from a library
When you created iOS/Mac OS library project as well as the sample app to use the library, one day you want to make the library as a framework:
- Install Cocoapods by $ sudo gem install cocoapods
- Install Cocoapods packager by $ sudo gem install cocoapods-packager
- Create you framework class to include all the public header files
- Public the header files by adding them to target library > Build Phases > Copy Files, you have to import those files in the library project like #import <FRAMEWORK_NAME/CLASS_NAME.h> instead of #import "CLASS_NAME.h", otherwise you would get a lot of duplicated constants and classes.
- Make you .podspec file
Pod::Spec.new do |s| s.name = 'FRAMEWORK_NAME' s.version = '0.0.1' s.license = 'MIT' s.summary = 'name' s.homepage = 'https://github.com' s.authors = { 'Phunware' => 'info@company.com' } s.source = { :git => 'https://github.com/**.git', :branch => 'BB' } s.requires_arc = true s.dependency 'PODS_NAME' s.default_subspec = 'Production' s.ios.deployment_target = '8.0' s.public_header_files = 'FRAMEWORK_NAME/**/PUBLIC_CLASS.h', 'FRAMEWORK_NAME/**/PUBLIC_CLASS.h' s.source_files = 'FRAMEWORK_NAME/**/*.{h,m}' s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"$(PODS_ROOT)/PWCore/**"', 'ENABLE_BITCODE' => 'YES' } s.subspec 'Production' do |prod| prod.public_header_files = 'FRAMEWORK_NAME/**/PUBLIC_CLASS.h', 'FRAMEWORK_NAME/**/PUBLIC_CLASS.h' prod.source_files = 'FRAMEWORK_NAME/**/*.{h,m}' prod.prefix_header_contents = <<-eos data-blogger-escaped-__objc__="" data-blogger-escaped-configuration_production="" data-blogger-escaped-define="" data-blogger-escaped-end="" data-blogger-escaped-endif="" data-blogger-escaped-eos="" data-blogger-escaped-foundation="" data-blogger-escaped-ifdef="" data-blogger-escaped-import="" data-blogger-escaped-pre="" data-blogger-escaped-uikit=""> Then you can make the framework locally by $ pod package FRAMEWORK_NAME.podspec --subspecs=Production --spec-sources=PRIVATE_SPECS --verbose
Valid your framework before publishing by $ pod spec lint FRAMEWORK_NAME.podspec --sources= PRIVATE_SPECS --use-libraries --verbose --allow-warnings
Publish you framework to cocoapods repo $ pod trunk push FRAMEWORK_NAME.podpec
Note: When do package locally you may meet issues, just upgrade the cocoapads to latest version. Like upgrade ruby to the version you want by $ rvm upgrade current_version version_you_wanted
Wednesday, May 6, 2015
[iOS]Generice Xcode Archive vs iOS App Archive
The type of Generice Xcode Archive can't be submit to Apple store or Crashlytics, but you directly debug running on device and simulator, it's in the Other Items rather than iOS Apps in Archives(Xcode > Window > Organizer) window.
Check the settings below when this happened:
Check the settings below when this happened:
- Skip install is NO for the main project target
- Skip install is YES for framework (sub-projects) targets
- In Build Phases for sub-projects, Copy Headers needs to be in Project, not Public (does not apply if building static library)
- Installation Directory under Deployment is valid (/Applications for example)
NOTE: since Xcode 7, the solution above doesn't work, what you have to do is to remove all the reference library sources from app target > Build Phases > Target Dependencies & Linked Binary with Libraries
Thursday, April 30, 2015
[iOS]Appledoc Shell Script Example
It's very easy to generate objc documentation for you with AppleDoc, here are the steps to setup in Xcode:
- Select you project name
- Try add add a target, and in the popped window select iOS > Other > Aggregate to create target named PROJECTDocs
- Then select new added target, to add "New Run Script Shell" to add the script like the below:
export HOMEDIR=`pwd` echo "Generating AppleDocs!" echo "Current directory is $HOMEDIR" /usr/local/bin/appledoc \ --project-name "$PROJECT_NAME" \ --project-company "Company, Inc." \ --company-id "com.company" \ --output "${HOMEDIR}/build_products/" \ --logformat xcode \ --keep-undocumented-objects \ --keep-undocumented-members \ --keep-intermediate-files \ --no-repeat-first-par \ --no-warn-invalid-crossref \ --ignore "*.m" \ --ignore "*Private.h" \ "$SOURCE_ROOT/$PROJECT_NAME"
Thursday, November 6, 2014
[iOS]Cocoapods: manage library dependencies for your Xcode projects
CocoaPods manages library dependencies for your Xcode projects
1. $ sudo gem install cocoapods
It requires your ruby is >= v1.9.x, if it isn't, you need to upgrade as the following steps:
1.1. Suggest to install rvm (Ruby Version Manager) with the following command line:
$ curl -L https://get.rvm.io | bash -s stable --ruby
1.2. Check available version
$ rvm list known
1.3. Select one to install
$ rvm install ruby-2.1.1
2. $ sudo gem install cocoapods again if update needed.
3. Go to you project directory to do the following command
I suppose there's been a Podfile there:
$ pod intall
it will automatically generate the *.xworkspace project and Pods project for your project.
Reference URL: http://guides.cocoapods.org/using/getting-started.html
1. $ sudo gem install cocoapods
It requires your ruby is >= v1.9.x, if it isn't, you need to upgrade as the following steps:
1.1. Suggest to install rvm (Ruby Version Manager) with the following command line:
$ curl -L https://get.rvm.io | bash -s stable --ruby
1.2. Check available version
$ rvm list known
1.3. Select one to install
$ rvm install ruby-2.1.1
2. $ sudo gem install cocoapods again if update needed.
3. Go to you project directory to do the following command
I suppose there's been a Podfile there:
$ pod intall
it will automatically generate the *.xworkspace project and Pods project for your project.
Reference URL: http://guides.cocoapods.org/using/getting-started.html
Monday, November 3, 2014
[Android] Add gradle environment constant
Add gradle environment constant:
1. Create ~/.gradle/gradle.properties
2. Add content like: env=stage
Add environment constant for running time:
$ gradle assembleDebug -Penv=stage
Use in gradle file
1. $buildEnv
2. project.ext['buildEnv']
Thursday, October 30, 2014
[iOS] Create NSArray for non-object data types
Example:
MKMapPoint *points;
points = malloc(2 * sizeof(MKMapPoint));
points[0] = MKMapPointForCoordinate(CLLocationCoordinate2DMake(0, 1));
points[1] = MKMapPointForCoordinate(CLLocationCoordinate2DMake(1, 1));
....
free(points);
Subscribe to:
Posts (Atom)
